Integrate API

Integrate API - Header

Thursday, August 1, 2013

How to integrate Paypal API in your site

Paypal have changed their site features in recent days. They have now more usable online payment solutions. As though their outlook and functionality have been changed, i am going to write a short summery of  how to integrate paypal in your site.

First of all you need a paypal developer account(for test transaction) and live account(for real transaction).
  1. Go to http://developer.paypal.com and register here.
  2. Now log in developer.paypal.com
  3. After log in click "Dashboard" tab. Here you will get 02 options (Test and Live).
  4. Click Test->REST API transactions. you get "Test REST API transactions and responses". Click on this link "Create your first PayPal app and receive API credentials."
  5. You are now at "My appsREST API apps where from you can Create, edit and manage multiple PayPal apps. In each app, select the specific PayPal capabilities you want to offer to your customers. Every app gets a unique set of live and test API credentials. 
  6. You get there a button labeled "Create Application" click on it. Give Application name and select integration type(web/mobile app). Finally click "Create Application"
  7. Your application is immediately approved and ready for Accepts PayPal payments. From this page you can get application credentials by clicking "REST API CREDENTIALS". You get credentials like: 
Test credentials
Test account: yourname-facilitator@gmail.com
Endpoint: api.sandbox.paypal.com
Client ID: AWXUjxAgAxTmMjjv9yhNXZERa_zAxz4kWlB1CRMgTWUYtaVop5pQyi9uCy
Secret: EK9ZzRD2ciHJhk_GBLdaR7BP7PVSEX-tU0nyaVMJxIGDeylvVjP0uRamDvyp
Live credentials
Endpoint: api.paypal.com
Client ID: Aey2xBfKiEZWrk8Fgahd6Cw4KXL0Mu7eEsC6Pdxj45oaNhOPsbFLMSFo_tu
Secret: ENE0iBCsfgeWaUCK2ghzUCeK7afuIslW1XoGVi93gn6pjSsx-UUoCmqEwTWD
 
After create "My Application" successfully you get "Sandbox accounts" in left menu under Applications. Click on "Sandbox accounts". Here you get your business account. 
Click on "Profile" link under your account title. "Account Details" popup window will appear. From there "API Credential" tab you have to collect 3 things
API Username: yourname-facilitator_api1.gmail.com
Password: 1375222646
Signature: AFcWxV21CxE7Ev3bYYYRCpSSRl31AeHPKoPJmkyNgPh36GMZEZxToxth

Well, we have created merchant(seller) account successfully. Now we need to create some buyer account so that we can test buyer experience.
After log in developer.paypal.com click "Application" main tab on the top.
Click "Applications"->Sandbox accounts. Click "Create account" button (right middle corner).
Provide Account Detail information. For example:
Country: United States
Account Type: Personal(buyer account) or Business(seller account). i select here Personal
Email address: your-fake-email@something.com
Password: anypass
Payment Methods: Paypal balance Put here any amount say 5000USD
Bank verified account:  Yes
Select payment card: Discover
Credit card type: American Express
Lastly click "Create Account" button.

So you have created a buyer account for you. Now you can check your Applications and Sandbox Accounts by click on "Application" link on header after log in developer.paypal.com

How to activate your credit card?
=> After log in developer.paypal.com click "Application" -> "Sendbox accounts" -> Profile(under test account) -> Funding tab -> 'Paypal Payment Card' section - Card Status. Click here to activate your credit card.

How do i check whether i receive a payment from a buyer to my business account?
=> After log in developer.paypal.com click "Application" -> "Sendbox accounts" -> Click "Notifications" (under business account)-> You get 'Notification of Payment Received" with date. click on it to show detail of this transaction.

Shall i need to log in developer.paypal.com during test transactions?
=> No you don't need that. Before last upgrade of paypal it was mandatory.

How to change my Store Name in Sandbox/Test account?
=> log in sandbox.paypal.com using merchant account detail created at developer.paypal.com. Click "My Account" tab(first tab) of header menu. Click "Profile" tab which is right most tab appear in sub menu. Now Click "My Business Info" in left menu. First item her is name and click "Change" link (appear right to name). Select "Change Business Name" and press next. Enter here new business name and click "Continue". You are done.

What is developer.paypal.com?
=> Developer.paypal.com is a place where from you will be able to create test accounts(buyer & seller), get account API details, view their summery transactions. Moreover, you can create New Test Applications from here. In addition, you can even change buyer & sellers account password.

What is sandbox.paypal.com?
=> sandbox.paypal.com is purely a Test Platform where from you will be able to log in using account details(email and password) created at developer.paypal.com. Moreover, you can get detail transaction history of buyer/seller account.

Where from i get Paypal Live account API Credentials(Username, Password & Signature)?
=> Go to https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run and log in using your Live account userid and password. Immediately after you logged in, will get API username, Password and Signature.

Error Message: Could not resolve host: api-3t.paypal.com; Host not found
=> Check correctness of your Live account API Credentials(username, password & signature). In order to get correct credential follow former error & solution.

How to create a test account in Sandbox?
=> After login developer.paypal.com click Application. In left menu under Applications you will find out Sandbox accounts(click on it). Now click "Create Account" button on the right. Provide detail information here and click "Create Account". Keep in mind, in order to test buyer experience you have to set Account Type to Personal.

Where from i can check my Buyer Account Transactions & Payments?
=> Go to sandbox.paypal.com which is purely a Test Platform and from here you will be able to log in using test account details(email and password) created at developer.paypal.com. Moreover, you can get detail transaction as well as test account information(like first & last name, country etc) history of buyer/seller account.

What is Guest Checkout?
=> There are two ways of payment receive in paypal. First payment is not possible without having any paypal account and Second, pay using Credit Card (no need any paypal account). Guest checkout means second one.

How to enable Guest Checkout in Paypal Checkout
=> In your NVPSTR set &SOLUTIONTYPE=Sole to enable Guest Checkout. And optionally specify LANDINGPAGE=Billing for the billing page to be forced. If guest checkout is enabled then visitors will be able to pay using only their credit card (without having paypal account).
Moreover, in order to enable Guest Checkout you need to setup few parameter in your paypal merchant account as well. You must have 'PayPal Account Optional' set to 'On' with 'Website Preferences' section of PayPal account.
Profile > My selling tools (or: My selling preferences) > Website Preferences > Update > PayPal Account Optional: On.

How to turn off Paypal Shipping Address in Checkout
=> For sale digital goods and local pickup we don't need any shipping address. so we need not to display shipping address in paypal. In NVPSTR:
NOSHIPPING=1 leads buyer not asked for a shipping address in paypal.
Error & Solution:
The totals of the cart item amounts do not match order amounts
=> Please check your total amount(AMT) should be equal to sum of all item/product total amount (ITEMAMT) and Tax amount(TAXAMT) and shipping amount(SHIPPINGAMT) and subtract by shipping discount amount(SHIPDISCAMT).

Security header is not valid
=>Check your API_ENDPOINT. For sandbox it should be https://api-3t.sandbox.paypal.com/nvp and for live https://api-3t.paypal.com/nvp

Error Message: Unknown SSL protocol error in connection to api-3t.paypal.com:443
=> This error comes in localhost because of SSL not supported in localhost. In server you will not get this error.

This transaction has expired. Please return to the recipient's website to complete your transaction using their regular checkout flow.
=> Check your PAYPAL_URL. For Sandbox it's https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= and for Live it's https://www.paypal.com/webscr&cmd=_express-checkout&token=
     If you still getting problem please check API_ENDPOINT as well. For sandbox it should be https://api-3t.sandbox.paypal.com/nvp and for live https://api-3t.paypal.com/nvp


4 comments: