Making payments
Now that your user has a Payment Source - the next step is to create a Payment Intent.
When your user clicks transfer a call to your backend should be initiated expecting a payment_intent_id
as the response.
onClick={() => callMyApi(amount, currency, customer_id, payment_destination_id)}
Create the Payment Intent
Call:
curl -X POST 'https://sandbox.leantech.me/payments/v1/intents' \
--header 'Content-Type: application/json' \
--header 'lean-app-token: YOUR_APP_TOKEN' \
--data-raw '{
"amount": 1000.50,
"currency": "AED",
"payment_destination_id": "266733cc-6f46-4e87-af7e-9bb46b99601d",
"customer_id": "CUSTOMER_ID",
"description": "YOUR_TRANSACTION_REFERENCE" //optional
}'
amount
The amount you want to transfer - should be provided as a float
value.
currency
The currency to execute the transaction in - this affects the instruction made to the bank not the currency that is received. For example, if you are receiving into a USD destination account, a payment made in AED will be converted by the receiving bank.
payment_destination_id
The payment account details to send the transaction - stored as a Payment Destination see Creating a Payment Destination
customer_id
The Customer object tied to the transaction request.
description
Set a custom transaction description, this is optional and will be populated by the payment_intent_id
if left blank. Descriptions have a maximum length of 32 characters and is recommended to be as short as possible without any special characters.
Using custom transaction references
It's important to note that some banks only allow 12 characters for the reference. So if you want the description to be passed as it is and avoid having it trimmed, you need to restrict it to 12 characters on your side !!
Response:
{
"payment_intent_id": "9dafc6f5-37e8-4f72-aa0b-5323c0935c5f",
"customer_id": "6bc2336a-6d74-4e59-a492-65313423a8f8",
"amount": 1000.00,
"currency": "AED",
"payments": [],
"payment_destination": {
"id": "XXXXXX-c568-40d7-8710-3e330dXXXXXX",
"bank_identifier": "LEANMB1",
"name": "XXXXXX",
"iban": "AEXXXXXXXXXXXXXXXX",
"display_name": "XXXXXXX",
"account_number": "XXXXXXXX",
"swift_code": "BBMEAEAD",
"status": "CONFIRMED",
"address": "1234 1234",
"country": "ARE",
"city": "Dubai",
"default": true
}
}
You should take the payment_intent_id
received in the response and return back to your front-end to initiate the payment.
Initiate a Payment
Once an initiation has been completed, you will receive a payment.created webhook to your Webhook URL:
{
"payload": {
"id": "81f686b5-0cf3-4ee1-9250-9f8dae030a1d",
"customer_id": "e52d8b7e-7c4d-40af-b851-90ab5c061028",
"intent_id": "88f73a6d-f017-4fc6-85bf-2cc2804c2a4a",
"status": "ACCEPTED_BY_BANK",
"amount": 10.12,
"currency": "AED"
},
"type": "payment.created",
"message": "A payment object has been created.",
"timestamp": "2021-03-24T12:50:47.521324Z"
}
Payment Initiations can have three final statuses on the Lean platform.
FAILED: The bank rejected the payment initiation. This could be for a number of reasons such as insufficient balance to complete the transaction, or a connectivity failure.
PENDING_WITH_BANK: The bank accepted the initiation, but didn’t provide a transaction reference number. Pending payments may be processed by the bank at a future date and require manual reconciliation.
ACCEPTED_BY_BANK: The bank accepted the initiation and provided a transaction reference number. Transactions that are ACCEPTED_BY_BANK should not be treated as completed payments until the funds have been reconciled in your account. There are a rare number of circumstances when a delay may occur between a bank accepting a payment and the funds reaching your account and/or circumstances which may cause the payment to fail. For example, a bank may request additional KYC checks or there may be insufficient funds available for the transaction after the bank transfer fees are applied. We recommend that funds are reconciled in your account before making them available to the customer.
Testing Different Payment Responses
In order to test failed payments using your sandbox account/test users, please refer to the below details:
Status | Amount | Currency | Additional Details |
---|---|---|---|
PENDING_WITH_BANK | 12.34 | AED | Initiation successful - happy path |
FAILED | 34.56 | AED | This would return a generic failure message |
FAILED | Big amounts, i.e: 300000 | AED | This would return an insufficient funds message within the status_additional_info field |
ACCEPTED_BY_BANK | Any valid amount | Any valid currency | Initiation successful - happy path |
Updated 12 days ago