Storing the data during payment

Storing the data during payment

When a shopper is checking out for the first time, he has to fill in his complete payment- and address data. Use this option to automatically store his data during the payment for reuse in later transactions.

During the checkout process you can store the data by adding an additional parameter to the normal prepare checkout request as described in step 1 of the COPYandPAY checkout:

createRegistration=true

After the account holder has filled in their account information and are redirected back to your shopperResultUrl, you can retrieve the response information as usual (step 3). This time, however, the response will include a registrationId (token) and useful card information that you can store for future 'one-click payment' requests.

1. Prepare the checkout

First, perform a server-to-server POST request to prepare the checkout and set the with the createRegistration to true.

2. Create the payment form

To create 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/v2/paymentWidgets.js?checkoutId={checkoutId}"></script>

3. Get the payment status

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 registration, you should make a GET request to the baseUrl + resourcePath, including your authentication parameters.

4. Use the data for recurring payment

Based on the stored account details, recurring payments become very simple to achieve.

All you need to do is to add the parameter recurringType to your request to the /checkouts endpoint (see step1):

  • For the initial payment request you should send the recurringType with value INITIAL.
  • For any subsequent payment you should send the recurringType with value REPEATED.

The Recurring Payment tutorial explains this scenario in more detail.