Use the Payment API to save payment details from a purchase. There are several use cases:
After the customer pays an order,store the payment details for future purchases.
Initiate the first payment of a series of recurring payments.
Charge reserved funds and store the details to charge the full amount later
1. Set up MoneyCollect
Firstly, make sure that you have set up an account name on the MoneyCollect Dashboard.
2. Create a customer before set up
To set up a payment method for future payments, you must attach it to a Customer. Create a customer object in MoneyCollect when your customer creates an account on your website. It is also possible to create a customer object in MoneyCollect before the customer is ready to pay. Customer objects allow for reusing payment methods and tracking across multiple payments.
3. Create Payment
To create a payment, specify the amount, currency, orderNo and customer.
After the Payment is created, only need to return the clientSecret in the returned result to the payment page. It is used to confirm the payment and update the card information on the client.
4. Collect card details
After the payment is created on the server and the clientSecret is transferred to the browser, you’re ready to collect Elements of the payment details on the client by using MoneyCollect.js. Elements is a set of prebuilt UI components that used to collect and verify card numbers, CVVs, and dates of expiration.
Include the moneycollect.js script on your checkout page by adding it to the head of your HTML file. Always load moneycollect.js directly from js.moneycollect.com to remain PCI compliant.
1. Set up MoneyCollect Elements
2. Add Elements to your page
3. Set billing details
Set billingDetails before submitting payment to MoneyCollect
5. Submit the payment to MoneyCollect
setupFutureUsage:
It is used to set whether the card information can be used for payments in the future.
Set setupFutureUsage to 'on' && customer is provided when payment is created, the card information will be automatically attached to the customer when the Payment is confirmed.
You can also set this parameter when creating a Payment on the server-side.
Confirm Payment may take several seconds to complete. During that time, disable your form from being resubmitted.If the customer must perform additional steps to complete the payment, such as authentication, moneycollect.js guides them through that process.
when a payment is successful, the returned status of Payment is succeeded . when a payment fails, you can check the returned error to determine the reason.
If the payment succeeded, you can use the stored customerId,paymentMethod from the responsive payment information to collect payments from your customer in the future without prompting them for their payment details again.
6. Charge using saved payment method
List all payment methods associated with your customer, and pick one of payment methods to charge.
Use customer and paymentMethod you pick.
Set up all related information of payments.
Setconfirm to "true": The payment will be automatically charged when the payment is created.
SetpaymentMethodto the ID of the PaymentMethod.
SetcustomerIdto the ID of the Customer.
There are two scenarios of charge failure: request failure and payment failure.
Request failure:Whencode is not success, request fails, msgdescribes the reason for charge failure.
Payment failure:statusis failed,errorCodeanderrorMessagedescribe the reason for charge failure.
For more Payment status, please check the description of Payment API's status.
There are several test cards you can use to make sure this integration is ready for production. Use them with any CVC, postal code, and future expiration date.
Succeeds and immediately processes the payment.
Succeeds and immediately processes the payment.
Succeeds and immediately processes the payment.
Succeeds and immediately processes the payment.
Succeeds and immediately processes the payment.
Always fails with a decline code of declined.