Cashlesso enables you to accept payments from your customers in a swift manner. For this, you need to complete the integration process with our Standard Automatic Checkout. To do so, follow these steps:
Note: You need to generate Test API Keys and create a Cashlesso Account as a prerequisite for quick integration.
For invoking the ‘Checkout’ form, our Standard Automatic Checkout process provides you clients with a default Cashlesso Pay along with the Cashlesso button. The options for ‘Checkout’ form options are passed inside a <script> tag as data attributes. You can submit additional fields, visible or hidden, along with the form.
With this sample code given below, Cashlesso ‘Checkout’ options will be passed as the HTML data attributes.
Insert Codes
After the completion of the checkout process, an additional field <name=id> will be added to the form containing the script tag. Post this, the form is submitted automatically. With the authorisation of the payment made, the form along with the Cashlesso_payment_id to the action url.
Note: In the below mentioned code, replace the URL with the success callback URL of your website.
<form action=”https://www.example.com/payment/success/” method=”POST”>
Cashlesso provides its customers with the ‘Retry’ option in case of a failure.
The second step in quick integration is creation of an order in the backend. This is done using the Orders API. Below mentioned is a sample API request and the subsequent response for order creation.
Insert Codes
Once the order creation is completed successfully, the order_id is returned to be stored against the Order defined in your system.
Store the following objects in your database from Cashlesso:
cashlesso_order_id | string Order ID returned by Cashlesso Orders API. Returned once the payment is completed by the customer. |
cashlesso_payment_id | string Returned by Cashlesso API only for successful payments. |
cashlesso_signature | string A hexadecimal string used for verifying the payment |
Note: The unique identifier for an order in your system is not the the order_id returned by Cashlesso.
The order_id returned upon completion of the order, must be sent to the ‘Checkout’ form. In addition to this, an extra key-value pair must be sent as shown below.
Insert Codes
With the successful transaction, a cashlesso_order_id, cashlesso_signature and payment_id is received which is further used for verification of payment.
Signature verification is mandatory for successful verification of all authorised payments. Verify your payment using the signature verification step and decide if you want to complete it or not. The cashlesso_signature returned to you upon successful payment by the ‘Checkout’ form must be verified in your backend server.
For verification of payments, you must create a verification signature with SHA256 algorithm and verify it against the cashlesso_signature.
Create Signature
To create a signature in your server, use the attributes given below:
cashlesso_payment_id – Returned by Checkout
cashlesso_order_id – Returned by Checkout
key_secret – Available in your server
Using the SHA256 algorithm and cashlesso_order_id and cashlesso_payment_id, construct a HMAC hex digest as given below:
Insert Codes
Post Signature Verification Steps
Once the signatures are verified, you need to fetch the order in your system corresponding to cashlesso_order_id in your database. Process the order once it is marked as successful.
Note: cashlesso_order_id returned by successful order creation must be restored against the order created in the backend system. Once the signature is validated, mark the fetched order corresponding to cashlesso_order_id as successful.
To initiate payment, click ‘Pay’ with CashlessoPay button. In a test payment, no money will be deducted from your account but the transaction is reflected in the dashboard. To know follow Dashboard → Transactions → Payments.
Switch to the live mode if you have completed the integration process and tested it out. Create a Live Key from the Dashboard to replace the Test API Key.