Processing a payment via Checkout.js
If you are using Checkout.js, you will need to exchange payment data for a one-time payment token in the library, then include this token in the payment creation request to the API.
Step 1. Get the payment token in Checkout.js.
Step 2. Send the token to your server.
Step 3. Create a payment , send the payment token in the
payment_token
parameter. If you’re planning to process the payment via 3-D Secure authentication, send the confirmation
object with the redirect
type and the URL of the page the user will return to.Example of request
curl https://api.yookassa.ru/v3/payments \ -X POST \ -u <Shop ID>:<Secret Key> \ -H 'Idempotence-Key: <Idempotence Key>' \ -H 'Content-Type: application/json' \ -d '{ "payment_token": "pt-28cd3959-0000-500c-a000-03b4de9b24a7", "amount": { "value": "2.00", "currency": "RUB" }, "confirmation": { "type": "redirect", "enforce": false, "return_url": "https://www.example.com/return_url" }, "capture": false, "description": "Order No. 72" }'
Step 4. If the payment status is
pending
, redirect the user to confirmation_url
.Example of a created payment object
{ "id": "23d93cac-000f-5000-8000-126628f15141", "status": "pending", "paid": false, "amount": { "value": "2.00", "currency": "RUB" }, "confirmation": { "type": "redirect", "confirmation_url": "<Link for 3-D Secure authentication>" }, "created_at": "2019-01-22T14:30:45.129Z", "description": "Order No. 72", "metadata": {}, "recipient": { "account_id": "100500", "gateway_id": "100700" }, "refundable": false, "test": false }
Step 5. Wait for the payment to be successfully completed: you will receive a notification from YooMoney, or you can send periodic requests for payment information .
See also