PayPal Sample Site

This sample site will try and show how to integrate with PayPal. Most PayPal API endpoints will be called via server-side endpoints that we have created as wrappers.

The only time a PayPal API endpoint is called directly is when we’re dealing with the 3DS flow.

Initial Flow

  1. Retrieve the Person ID of the logged in user. This will be needed when getting a client token.

  2. OPTIONAL - Call the PayPalGetSavedTokens endpoint. This will use Person ID from step 1 to get the list of saved payment tokens.

  3. Call the PayPalToken endpoint passing the Person ID from step 1 to get some information from Aptify. This will return:

    1. client_token - will be part of the script that will be placed in the <head> HTML tag.

    2. client_id - will also allow us to access PayPal’s API.

    3. auth_type: to know if we’re going to authorize or capture.

  4. Once you get that information and you set the <script> tag, PayPal will use the information to determine if the hosted CC fields are allowed to be showed.

At this point, the end user would select what to use to pay for the order. Either a SPM or CC. The flows are pretty much the same, except when confirming the payment source.

SPM Flow

  1. End User selects a SPM.

  2. End User clicks on the ‘Pay with SPM’ button.

  3. Call to PayPalCreateOrder endpoint. We pass minimum information like, the intent (Authorize or Capture), the amount and the currency. After calling this endpoint, PayPal returns a temporary order ID from their system.

  4. Call to PayPalConfirmPaymentSource endpoint. We pass the PayPal temporary order ID, and the ID of the saved token. This updates the temporary order with the saved payment information.

  5. Call the OrderSave endpoint. This endpoint call should be replaced with the endpoint from your current shopping cart. All we’re doing is creating an Aptify order with a PO Number that will be the PayPal order ID. This endpoint must return the Aptify order ID.

  6. Call the CreateRemotePayment endpoint. This endpoint will create a Remote Payment record in Aptify. We will pass the Aptify order ID, the PayPal order ID and the intent (Authorize or Capture).

    1. In Aptify, a Process Flow will trigger and use the information from this Remote Payment record to fully authorize or capture the PayPal payment. Once we get confirmation from PayPal, then we will create a Payment to pay the Aptify order.

Credit Cart Flow

The credit card flow follows a very similar set of steps:

  1. Client fills CC fields and billing address.

  2. Client clicks on ‘Pay’ button.

  3. Still call the PayPalCreateOrder endpoint.

  4. We DO NOT call a server-side endpoint (PayPalConfirmPaymentSource) like with SPMs, instead we call PayPal’s JavaScript SDK directly. The reason this is done is because the main CC fields (number, security code and expiration date) are all being handled by PayPal in an iframe. Also, calling this SDK might trigger the 3DS flow which happens on the client side. This is where an end-user will confirm with their bank if they approve the purchase.

  5. Once the confirmation flow is complete, we still call the OrderSave endpoint, which would be changed to your own shopping cart endpoint. It must return the Aptify order ID.

  6. Call the CreateRemotePayment endpoint.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.