PrimeiroPay
Search
K

One-Click Checkout

This guide allows you to achieve a significant speedup of the checkout process by re-using the data a customer entered for a previous transaction/registration. It's based on one of these two guides:
After the customer account details are stored, as part of the initial transaction/registration, you will need to keep a record of the associated registration IDs (token) that you can then use in step 1 below.

How it works

1. Prepare the checkout

NOTE: For demonstration purposes we have created a registration, which will be used in your one-click checkout, with id(s): 8ac7a4a0739e4f720173a048387d7a7c,8ac7a49f739e470f0173a048391e1c24. Following the guides above, you may add additional registrations options to the checkout.
First perform a server-to-server POST request to prepare the checkout, this should include the registration IDs of the customer as shown below.
The registration IDs should be sent in the registrations[n].id parameter, where n is a sequence number from zero, incrementing for each of the customer's registration IDs. For example, if the customer has two accounts on file, you would send registrations[0].id = {first registration.id} and registrations[1].id = {second registration.id}.
curl https://test.oppwa.com/v1/checkouts \
-d "entityId=8a8294184e736012014e78a17a5615ac" \
-d "amount=92.00" \
-d "currency=EUR" \
-d "paymentType=DB" \
-d "registrations[0].id=8ac7a4a0739e4f720173a048387d7a7c" \
-d "registrations[1].id=8ac7a49f739e470f0173a048391e1c24" \
-d "createRegistration=true" \
-H "Authorization: Bearer OGE4Mjk0MTg0ZTczNjAxMjAxNGU3OGExN2E2YTE1YjB8ZjJGRUtacXRCUA=="
Response:
{
"result":{
"code":"000.200.100",
"description":"successfully created checkout"
},
"buildNumber":"982467e36fd8bc9e74f536ba375c5d0be4fe48eb@2020-07-30 03:42:32 +0000",
"timestamp":"2020-07-30 15:23:37+0000",
"ndc":"B20EFF3A508805D585492DDFFE381BCC.uat01-vm-tx03",
"id":"B20EFF3A508805D585492DDFFE381BCC.uat01-vm-tx03"
}

2. Create the payment form

Then, to show the payment form you just need to add the following lines of HTML/Javascript to your page and populating the following variables
  • The checkout's id that you got in the response from step 1
    <script src="https://test.oppwa.com/v1/paymentWidgets.js?checkoutId={checkoutId}"></script>
  • The shopperResultUrl, which is the page on your site where the customer should be redirected to after the payment is processed and the brands that will be available.
    <form action="{shopperResultUrl}" class="paymentWidgets">VISA MASTER AMEX</form>
When Primeiro Pay builds up the payment form it automatically fetches the registrations data from the server and displays the pre-filled widgets to the shopper.
Require CVVShow initial payment from
  • html
<form action="https://primeiropay.docs.oppwa.com/tutorials/integration-guide/one-click#" class="paymentWidgets">VISA MASTER AMEX</form>
  • css
body {background-color:#f6f6f5;}
  • js
var wpwlOptions = { registrations: { requireCvv: false, hideInitialPaymentForms: true } }
  • result

3. Get the payment status

As usual, once the payment has been processed, the customer is redirected to your shopperResultUrl along with a GET parameter resourcePath.
IMPORTANT: The baseUrl must end in a "/", e.g. "https://test.oppwa.com/".
Then, to get the status of the payment, you should make a GET request to the baseUrl + resourcePath, including your authentication parameters.
Example for a resourcePath:
resourcePath=/v1/checkouts/{checkoutId}/payment
https://test.oppwa.com/v1/checkouts//payment
curl -G https://test.oppwa.com/v1/checkouts/{id}/payment \
-d "entityId=8a8294184e736012014e78a17a5615ac" \
-H "Authorization: Bearer OGE4Mjk0MTg0ZTczNjAxMjAxNGU3OGExN2E2YTE1YjB8ZjJGRUtacXRCUA=="
We recommend that you verify the following fields from the Payment Status response, by comparing the returned values with expected:
  • ID(s)
  • Amount
  • Currency
  • Brand
  • Type