Using Cake's checkout page
Overview
Accepting payments in various currencies across the globe can pose a challenge due to the intricacies involved in managing diverse currencies and payment methods under a single application. However, with Cake, this hurdle can be effortlessly surmounted by enabling payments from your customers through an easy-to-setup checkout page. The checkout page is customisable to meet your requirements, offering the flexibility to alter its colour scheme and layout.
In this guide, we'll delve deeper into how Cake facilitates seamless acceptance of payments worldwide in multiple currencies, and how it can smoothly integrate with your platform, making the process as easy as a piece of Cake 🍰.
Prerequisites
Before getting started with accepting payments using your customised checkout page, there are some preliminary steps that need to be completed. Let's explore these essential steps in more detail.
A registered account with Cake
It's imperative to have an account created with Cake.
Registration as a company and completion of the onboarding process are required.
If you encounter any hurdles, feel free to reach out to a Cake admin for assistance.
Complete onboarding
Ask the Cake Admin's for a pre filled onboarding form which would allow us to enable Payment Acceptance for your account.
Merchant profile
Setting up a merchant profile is crucial for payment acceptance.
The profile primarily comprises of details which are essential for customising your checkout page.
Currently, a Cake admin will assist in setting up the merchant profile.
It's advisable to have the following details at your disposal:
- Legal company name
- Background colour hex code (for your checkout page)
- Company logo
- List of currencies you want to receive payment in
Client tokens
As of now you can get your client key pairs (client_id and client_secret) for both the sandbox and live environment through a Cake Admin. You can use these keys to get your own access token
Learn how to get your token using the client keys here.
This access token enables access to Cake's payment API's for various operations.
Capturing payment from the customer
By this point, it's presumed that all necessary prerequisites for integrating the checkout flow have been met. Now, let’s understand how to utilize this checkout page for capturing a payment from a customer.
Create a payment session
The process begins with the creation of a payment session.
Each session has a lifespan of 5 minutes within which the payment capture must be completed.
A session is dedicated to capturing a single payment.
An API call is needed to create a session, and this can be done using the programming language of your choice. Detailed information regarding the API call can be found here.
The 'Create session' API will provide a session ID and a link to redirect your customer to. Here is a description of the fields that we use for creating a session
Field | Description |
---|---|
amount | Payment amount to capture. |
currency | Currency for payment. |
first_name | First name of the customer. |
last_name | Last name of the customer. |
Email address of the customer. | |
order_id | Order Id for the entity for which payment is being captured. |
descriptor | Description that would be visible in the bank account transaction. (max length: 20 chars) |
cancel_url | The url to which the customer would be redirected in the case of payment failure. |
success_url | The url to which the customer would be redirected post successful payment capture. |
form_type | The type of payment form that would load on the checkout page. Possible values are card, bank and bank-and-card(default). |
You would get a session_id as part of a successful response from the create session API. Keep this handy, we would use them in the next step.
Accessing your checkout page
Using the session_id and the token (without Bearer) which we get after authentication with the keys, you can now redirect your customer to the following link of your own customised checkout page.
<https://sandbox.securelinks.co?session_id={SESSION_ID}&token={AUTH_TOKEN}>
Once redirected successfully the customer can enter their name, card number, card expiry month, card expiry year and cvc as part of their payment method and can proceed with the payment.
You can use the following card details to test out the flow.
Card Number | Card Expiry Month | Card Expiry Year | Card CVC |
---|---|---|---|
4012000300001003 | 01 | 2025 | 123 |
4035501000000008 | 06 | 2026 | 321 |
If the payment is successful your customer would be redirected to the success_url which you provided when creating the session with a transaction_id in the url param else they would be redirected to the cancel_url with a url param message which would contain the reason for the error.
Conclusion
By the time you reach here you have successfully captured a payment from your customer. Please feel free to reach out to us if you feel stuck somewhere or have some suggestions or improvements for us.
We really hope that setting up your own customised checkout page was a piece of cake 🍰 for you.
Updated 20 days ago