Simple Paypal Integration with Salesforce (Step by Step)
来源:互联网 发布:淘宝上卖什么最赚钱 编辑:程序博客网 时间:2024/06/05 17:15
Hi All,
Recently I got a need to implement Paypal integration with Salesforce for a basic payment for Merchant Type account, the payments would be from Customers using Credit Cards like Visa etc. I started looking into Paypal methods to find out which is best to implement using Apex, then i found one old blog post very helpful (Unfortunately that blog post is removed recently so not able to paste url here). The method which i preferred is DoDirectPayment. I did some modification in that code and provided in this blog.
The main problem i faced, was not the code, the testing. Like me, many new developers face this problem, thats why i came with this blog to describe step by step procedure to do a simple test with your paypal payment process using salesforce code. This might be useful for the developers who dealing with Paypal first time as well as want to integrate it with Salesforce.
1) Setup one sandbox account.
Go to http://developer.paypal.com and create one account there. After creating, login there only. In the left menu you will find "Test Accounts" link. Click on that.
From the right side screen, you can create multiple test accounts.
For testing purpose generally you need two type of accounts. One is "Seller" and one is "Buyer". Its always better to create preconfigured accounts.
Click on "PreConfigured" link to create one 'Buyer' account, set some amount there.
Click on "PreConfigured" link to create one 'Seller' account, set some amount there.
Click on "PreConfigured" link to create one 'Website Payments Pro' account, used for Merchant (Seller), set some amount there. Dont choose seller account this time because we going to use "DoDirectPayment" API method which need this type of account.
We dont need "Seller" account but i found after some struggle that if you not create any Seller account first then if you create any 'Website Payments Pro', then it will always be "unverified". I am not sure why it is like this. But this is "My Best Practice" that you should first create one Seller account, then create this ''Website Payments Pro' account. And verify, that one is marked as "Verified" as shown in the below screenshot.
2) Test Merchant Account API Setup
Now, select your 'website payments pro' account using radio button there and click 'Enter Sandbox Test Site'.
Login with your password.
Click on Profile link after you login. It will be on top right side.
Click on 'Request API Credentials' link in bottom left side.
Click on 'Set up PayPal API credentials and permissions' link.
Click on 'View API Signature' link and note down your API Username, API Password, API Signature
Click on 'Grant API Access' link on previous screen. Here give your API username and Check all checkboxes and Save
Now you ok with configuration.
2) Salesforce Code setup
Now copy paste following Apex Class code in your org.
Add "https://api-3t.sandbox.paypal.com/2.0/" url into "Remote Site Setting".
In the below code change your API Username, API Password and Signature.
3) Run and Test
Now you can use below code to do a sample payment. Run this code either on your VF screen or from System Log screen.
You will see that you got one Transaction Id and 'Success' message. If you dont find success message, then print "err" property to check whats wrong.
Log into your test pro account and check your balance, it might be increased. If so, its all fine :)
Thanks
Aslam Bari
Recently I got a need to implement Paypal integration with Salesforce for a basic payment for Merchant Type account, the payments would be from Customers using Credit Cards like Visa etc. I started looking into Paypal methods to find out which is best to implement using Apex, then i found one old blog post very helpful (Unfortunately that blog post is removed recently so not able to paste url here). The method which i preferred is DoDirectPayment. I did some modification in that code and provided in this blog.
The main problem i faced, was not the code, the testing. Like me, many new developers face this problem, thats why i came with this blog to describe step by step procedure to do a simple test with your paypal payment process using salesforce code. This might be useful for the developers who dealing with Paypal first time as well as want to integrate it with Salesforce.
Go to http://developer.paypal.com and create one account there. After creating, login there only. In the left menu you will find "Test Accounts" link. Click on that.
From the right side screen, you can create multiple test accounts.
For testing purpose generally you need two type of accounts. One is "Seller" and one is "Buyer". Its always better to create preconfigured accounts.
Click on "PreConfigured" link to create one 'Buyer' account, set some amount there.
Click on "PreConfigured" link to create one 'Seller' account, set some amount there.
Click on "PreConfigured" link to create one 'Website Payments Pro' account, used for Merchant (Seller), set some amount there. Dont choose seller account this time because we going to use "DoDirectPayment" API method which need this type of account.
We dont need "Seller" account but i found after some struggle that if you not create any Seller account first then if you create any 'Website Payments Pro', then it will always be "unverified". I am not sure why it is like this. But this is "My Best Practice" that you should first create one Seller account, then create this ''Website Payments Pro' account. And verify, that one is marked as "Verified" as shown in the below screenshot.
2) Test Merchant Account API Setup
Now, select your 'website payments pro' account using radio button there and click 'Enter Sandbox Test Site'.
Login with your password.
Click on Profile link after you login. It will be on top right side.
Click on 'Request API Credentials' link in bottom left side.
Click on 'Set up PayPal API credentials and permissions' link.
Click on 'View API Signature' link and note down your API Username, API Password, API Signature
Click on 'Grant API Access' link on previous screen. Here give your API username and Check all checkboxes and Save
Now you ok with configuration.
2) Salesforce Code setup
Now copy paste following Apex Class code in your org.
Add "https://api-3t.sandbox.paypal.com/2.0/" url into "Remote Site Setting".
In the below code change your API Username, API Password and Signature.
3) Run and Test
Now you can use below code to do a sample payment. Run this code either on your VF screen or from System Log screen.
You will see that you got one Transaction Id and 'Success' message. If you dont find success message, then print "err" property to check whats wrong.
Log into your test pro account and check your balance, it might be increased. If so, its all fine :)
Thanks
Aslam Bari
0 0
- Simple Paypal Integration with Salesforce (Step by Step)
- Step by Step with Duwamish
- Step-By-Step Guide to Get Started with Salesforce REST API using Java
- Android Studio and NDK Integration on Windows Step by Step with a Hello JNI example
- IR with Lemur,Step by step
- Spring MVC: step by step 3-Simple Controller
- Step by Step Do IOS Swift CoreData Simple Demo
- THE DEAD-SIMPLE STEP-BY-STEP GUIDE FOR FRONT-END DEVELOPERS TO GETTING UP AND RUNNING WITH NODE.JS,
- NHibernate Step by Step
- OGRE step by step
- step by step
- MinGW Step by Step
- 大杂烩---Step by Step
- sphinx4 STEP BY STEP
- EJB step by step
- NHibernate Step by Step
- Django Step by Step
- Eclipse: Step by Step
- vs2010开发linux平台C程序 开发环境配置
- Windows Server Web Deployment Tools Example
- Objective-C调用Swift
- 看对象是如何调用类成员变量的
- 类定义的
- Simple Paypal Integration with Salesforce (Step by Step)
- Oracle DB 11.2.0.4 中SYS.ALL_CONSTRAINTS的定义 和 SYS.ALL_CONS_COLUMNS的定义
- [LeetCode] Excel Sheet Column Number
- sqlserver检查死锁的sql
- ArcGIS创建发布地图服务
- Mongodb2.8的版本升级(从2.4升级到2.8)
- 协同过滤之ItemCF(c++实现)
- Swift语言IOS8开发战记1.Button与Alert
- zookeeper原理