Links

Custom payment flow

Learn how to accept a payment with Yorlet.
To create a transaction object you'll need a customer ID and a payment method ID that has previously been created. See our guides on creating customers and collecting a payment method.

1. Collect a payment method

Create a Payment Method Session on the server.
You must create the Payment Method Session on the server so you don't expose you API key.
curl https://api.yorlet.com/v1/payment_method_sessions \
-H "Authorization: Bearer {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"customer": "cus_kowie32023325",
"payment_method_types": ["card"],
"return_url": "https://example.com/success"
}'
Redirect to the returned url.
{
"object": "payment_method_session",
"created": 1607473397,
"url": "https://pay.yorlet.com/payment_methods/pmsess_kfpOalkieq092Pm"
}

2. Create a transaction

The Transaction object represents an attempt to collect a payment from a customer. Include the following code on your server to create a new Transaction.
You must create the Transaction on the server so you don't expose you API key.
curl https://api.yorlet.com/v1/transactions \
-H "Authorization: Bearer {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"amount": 10000,
"currency": "gbp",
"customer": "{{CUSTOMER_ID}}",
"payment_method": "{{PAYMENT_METHOD_ID}}",
"payment_method_types": ["card"],
"return_url": "https://example.com/success"
}'
Yorlet will return a transaction object or an error, your integration should handle errors gracefully for the best customer experience.

2. Handle next actions

Some payment methods like Cards and Alipay may require additional steps to be completed. The transaction object helps you manage those requirements through the next_action object.