Tipping Point Payments
Scenario
Get payers to pledge to pay a certain amount in the future. Collect their credit card information, but don’t charge payers until some trigger is met (such as reaching the pledge goal).
Note: This is different from Delayed Payouts where all the money can be collected upfront but the merchant isn’t able to withdraw the money until a trigger point is met.
Example
Assume you have a site where people can post projects that they want to fund. Payers can then pledge to donate some amount of money, but they won’t be charged immediately. The payers will only be charged once the project has enough pledges to push it past the tipping point (the pledge goal amount). Then, all the payers will be charged at once.
At WePay, the project fundraiser is the merchant and donors are payers and we’ll use those terms below.
Key Concepts
There are two options for collecting card information, but not charging immediately.
- Iframe (Embedded) - Iframe uses the /preapproval/create API call to obtain a
preapproval_id
which can be used to charge the payer at a later date. 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 to charge the payer at a later date. 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 (Embedded)
- Tokenization (Custom)
Iframe
Summary
- Call /preapproval/create to start the credit card authorization process.
- Embed the resulting
preapproval_uri
in an iframe on your site, so the payer can enter their payment info. - When the trigger condition is met, call /checkout/create with the
preapproval_id
to immediately charge the card. - Handle any failed payments.
Detailed Example
Step 1:
Call /preapproval/create with the access_token
and account_id
of the merchant and the maximum amount that you will want to charge in the future. You will be able to charge any amount up to the maximum.
- PHP
- cURL
- Ruby
- Python
Step 2:
Embed the preapproval_uri
from step 1 in an iframe on the page. Inside the iframe the payer will see the authorization flow where they will enter their payment details. Once they have confirmed the authorization, they will be sent to whatever redirect_uri
you specified with the preapproval_id
appended as a GET parameter. You should store the preapproval_id
in your database so that you can charge the payer with it later.
Step 3:
Once the trigger condition has been met (for example, enough people have pledged to the project), you will want to charge all of the payers who pledged. To do so, you will make the /checkout/create call with the preapproval_id
from step 1.
- PHP
- cURL
- Ruby
- Python
Step 4:
It is possible that in step 3, some payments may have failed. This can happen if the payment method no longer has sufficient funds to make the payment, or the issuing bank for the payment method declined the charge.
First, you can retry the same /checkout/create call with the preapproval_id
one day later. If that retry fails, then you should email the payer and ask them to re-confirm their pledge. You can either have them start at Step 1 again, or you can immediately have them go through the standard checkout process with /checkout/create.
Tokenization
Summary
- Tokenize the credit card using WePay’s tokenization.js to obtain a
credit_card_id
. - Once the trigger condition is met, charge the card with the /checkout/create call.
- 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 store this credit_card_id
in your database and use it to charge the card once the trigger conditions have been met.
Step 2:
Once the trigger condition is met (for example, enough people have pledged to the project), call /checkout/create to immediately charge the card.
- PHP
- cURL
- Ruby
- Python
Response:
Step 3:
It is possible that in step 3, some payments may have failed. This can happen if the payment method no longer has sufficient funds to make the payment, or the issuing bank for the payment method declined the charge.
First, you can retry the same /checkout/create call with the credit_card_id
one day later. If that retry fails, then you should email the payer and ask them to re-confirm their pledge. You can either have them start at Step 1 again, or you can immediately have them go through the standard checkout process with /checkout/create.