How to implement PayPal API payment

Implementation by PayPal’s API (SDK)PayPal check outI will explain the latest information of.

For PayPal checkout,

There are three mounting methods. This page describes how to implement using Braintree SDK.

* Braintree account itself is not necessary to use Braintree SDK.

For Client IntegrationThis Japanese informationSee also.



Install SDK

There are the following types of SDK on the client side and the server side.

  • Client side: JavaScript, iOS, Android
  • Server side: Java, .Net, Node.js, PHP, Python, Ruby

The installation method of each SDK is as follows.

  • JavaScript: Direct link or download of JS files, npm, Bower
  • iOS: CocoaPods, Catherage, Download
  • Android: Grandle
  • Java: Download, Maven
  • .Net: Download, NuGet
  • Node.js: npm
  • PHP: Download, composer
  • Python: pip, manual setup
  • Ruby: bundle

For details of the setup of each SDK, please refer to the following (Please select again as target language, please use the latest version of each SDK version as much as possible).

Client side:

https://developers.braintreepayments.com/guides/client-sdk/setup/javascript/v3

Mobile SDK

https://developers.braintreepayments.com/guides/client-sdk/setup/ios/v4

Server side:

https://developers.braintreepayments.com/start/hello-server/ruby

* In case of implementing without Braintree account (implemented PayPal alone), replace the “Braintree” object in the Braintree site code example with the “Gateway” instance written on the above server side page.

image.png



Acquire SDK authentication information (access token)

In order to use PayPal payment SDK (Braintree SDK), SDK authentication information (access token) is necessary to identify account. For details on obtaining SDK authentication information, see the following. The acquisition method differs between Sandbox (PayPal test environment) and production environment.

Sandbox:

Please access the dashboard of the developer site (login with production account is required), press [My Apps & Credentails] & gt; [Generate Sandbox Access Token], select the Sandbox account (business) to use for the test Then get an access token.

https://developer.paypal.com/developer/applications/

For information on how to create a Sandbox account, please see below.

https://qiita.com/PPJP/items/6ba65ed21da7fba65586

Production environment:

Like Sandbox, you can access it by visiting the developer site and clicking the production account displayed in [Live accounts] of [My Apps & Credentails].

Or you can also get it from PayPal production site and can also be obtained from [Account Settings] & gt; [Profile Settings] & gt; [Sales Tools] & gt; [API Access Update] (It may not be displayed in some accounts) .



Basic flow of settlement processing

The settlement processing is the flow below.

  1. Generate client token using access token (server side)
  2. Display of PayPal payment screen using client token (client side)
  3. Obtain nonce (and device data) (client side)
  4. Completion of settlement using nonce (and device data) (server side)

* Although it is necessary to use the device data when using Vault to be described later, we recommend that you always acquire and transmit as security measures other than Vault.

image.png



1. Generate a client token using an access token (server side)

To start PayPal payment, display the PayPal payment screen with the Client SDK. To display the payment screen, you need the client token generated by the server.

How to generate a client token (Please select again as a target language)

https://developers.braintreepayments.com/start/hello-server/ruby#generate-a-client-token



2. Display of PayPal payment screen using client token (client side)

Use the generated client token to display the settlement screen (Please select again as the target language)

Checkout (in the case of settlement each time):

https://developers.braintreepayments.com/guides/paypal/checkout-with-paypal/javascript/v3

Vault (in case you want automatic payment after pre-approval):

https://developers.braintreepayments.com/guides/paypal/vault/javascript/v3

※ Please see below for an overview of pre-approved settlement (separate application and examination are required).



















































onError




















































Leave a Reply