Split/Chained Payments


Scenario

Collect credit card information once and send money to more than one merchant.


Example

Let’s say you are a donation platform. When a donor makes a donation, in addition to their primary donation, you give the donor the opportunity to give an additional $5 to a second charity. Your platform only collects credit card information from the donor once but you can send the different amounts to the different charities.

At WePay, the fundraiser is the merchant and the donor is the payer and we’ll use those terms below.


Key Concepts

There are two options to facilitate collecting credit card information once and using it multiple times.

  • Iframe (Embedded) - The iframe uses the /preapproval/create API call to obtain a preapproval_id which can be used multiple times to send money to different payees (merchants). This method lets you use WePay’s pre-built and optimized form to collect credit card information. This method minimizes necessary PCI compliance, because information is shared securely between the browser and WePay.
  • Tokenization (Custom) - Tokenization uses WePay’s tokenization.js to obtain a credit card token which can be used multiple times to send money to different payees. This method lets you use your own form to collect credit card information. As there is exposure to developer error or fraud, there is more PCI compliance required than there is with iframe.

Solutions

Solutions include:


Iframe

Summary

  1. Call /preapproval/create with the client_id and client_secret (access_token and account_id removed).
  2. Use the resulting preapproval_uri to drive the user through the preapproval (checkout) flow.
  3. Use the resulting preapproval_id to send money (/checkout/create) to any charity (merchant) for which you hold an access_token.

Detailed Example

Step 1:

Call /preapproval/create with the client_id and client_secret. Note that you will NOT include the access_token and account_id parameters in this call (because you do not want to authorize a payment to one single specific merchant, but to potentially multiple merchants).

  • PHP
  • cURL
  • Ruby
  • Python

Step 2:

Use the resulting preapproval_uri to drive the user through the preapproval flow.

At this time, the donor should be presented with the flow provided by the resulting preapproval_uri in Step 1. This flow will act as the donor’s checkout experience. Upon completion of the flow, the donor will be sent to the redirect_uri with the preaproval_id appended as a GET parameter.

Step 3:

Use the resulting preapproval_id to send money (/checkout/create) to any merchant for which you hold an access_token.

Note: By including the preapproval_id in the /checkout/create call the checkout is executed immediately.

Make primary donation:

  • PHP
  • cURL
  • Ruby
  • Python

Once that payment has been completed, do the second one:

  • PHP
  • cURL
  • Ruby
  • Python

 


Tokenization

Summary

  1. Tokenize the credit card using WePay’s tokenization.js to obtain a credit_card_id.
  2. Once the trigger condition is met, charge the card with the /checkout/create call.
  3. Handle any failed payments.

Detailed Example

Step 1:

Tokenize the credit card using WePay’s tokenization.js.

Follow the steps in the tokenization tutorial to get a credit_card_id that represents the payer’s method of payment. You will use this credit_card_id in the next step to charge the credit card.

Step 2:

Use the resulting credit_card_id to send money (/checkout/create) to any payee for which you hold an access_token.

Note: By including the credit_card_id in the /checkout/create call the checkout is executed immediately.

Make primary donation:

  • PHP
  • cURL
  • Ruby
  • Python

Make second donation:

  • PHP
  • cURL
  • Ruby
  • Python