PayPal Payment Service Integration Tutorial

IMPLEMENT A PAYPAL PAYMENT SERVICE IN A WEBSITE.

Paypal is one of the best payment service solutions for websites. Using Paypal, one can easily integrate a fast and secure payment system in any website.

In this article i will explain about the Paypal API. I will review the major methods for Paypal integration, and go over some useful configs for our Paypal payment service.

There are three major integration methods:

  1. Express checkout – the regular payment flow, where the user is redirected to the Paypal website. It minimizes the number of steps a customer has to do in order to complete the order.
  2. In context – a Paypal payment flow within your website, keeping the user in the same context.
  3. Pro Paypal – a fully customizable checkout flow.

*There is another integration method called Digital Goods. This method is no longer available for new integrations. This feature remains available for merchant accounts that already have Express Checkout Digital Goods enabled.
 
In my app, I used the In-context express checkout method.
This method and the classic ExpressCheckout both have the same flow. The only difference is that when using In-context, the entire flow happens in an iframe popup window, without leaving the site.

Open a paypal account:

Go to this link and sign up. Afterwards, open business and personal account. In order to make In-context work, we will need to set the reign account to be from the countries list supported , or else the user will redirect to classic express checkout.
In order to make our API calls to Paypal succeed, we need to pass three credentials (see image below) in every API call. These credentials will be stored on the server. Another config we need is Merchant account id. We will use this config on the client side.

paypal1.1

 

There are three API calls we need to do in order to make the PayPal flow to succeed.

  1. SetExpressCheckout API call to get a token. There are requested fields we should send in order to get a positive response.
    In the response, we will get an object with ACK and TOKEN properties. We can check that the ACK value equals to ‘success’, just to be sure. The token value we need to return to the client for the In-context url. After we get the token in the client, we will run the PayPal function with a url that contains our token.
    Example: https://www.sandbox.paypal.com/checkoutnow?token=<our token>.
  2. GetExpressCheckoutDetails API call to get the order details. You can use this API call when you want to get the full info about the transaction, or before the DoExpressCheckout and then send the result in DoExpressCheckout API.
  3. DoExpressCheckoutPayment API call to finish the transaction, and charge customer account.

 

Useful configs:

In the SetExpressCheckout API call, we can use some custom values to customize our PayPal app to our needs.
SOLUTIONTYPE = sole : This config adds credit card payment option.
PAYMENTREQUEST_0_CUSTOM=”Your custom info”: this property gets a string value and return it in the SetExpressCheckout api call. This value limited to 256 chars. If you use this property, handle this issue to prevent errors. If you want to get the custom value as an associative array, you can convert the array to a URL-encoded query string, and then in the response (GetExpressCheckoutDetails) use parse_str to convert it back to an associative array (In case you use php).

In the my next blogpost I will build a PayPal app with full flow.

Check this and another Out-Of-Box features that are offered in our Bamboo Online Video platform.

Don’t hesitate to ask questions or comment on this article, here or by email: info@panda-os.com

Enjoy.

One thought on “PayPal Payment Service Integration Tutorial

  1. Pingback: Video Platform Development | Video Streaming Solutions | PandaOS

Leave a Reply

Your email address will not be published. Required fields are marked *