Accepting a payment

Integrate with the Yoco Checkout API to securely accept payments on your website.

Always call the Yoco Checkout API from your server, not directly from the browser or client-side code. This protects your secret API keys and ensures you can securely track and verify payment status on your server.

Steps to accept a payment

1

Register webhook

Register a webhook endpoint to receive payment success events.

For more information on registering the webhook, see the webhooks guide.

2

Create a checkout

Make an authenticated POST request from your server to https://payments.yoco.com/api/checkouts with the required details.

For more information on the request body, see the create a checkout API reference.

Example create checkout request
$curl --location --request POST 'https://payments.yoco.com/api/checkouts' \
>--header 'Content-Type: application/json' \
>--header 'Authorization: Bearer <secret-key>' \
>--data-raw '{
>"amount": 900,
>"currency": "ZAR"
>}'

For more information on authentication, see the authentication guide.

Do not use successUrl from the response to verify payment success. Always use webhooks for confirmation.

3

Redirect the customer

Use the redirectUrl from the response to send your customer to the Yoco Checkout page.

4

Verify payment success

Listen for the webhook event on your server to confirm the payment was successful before fulfilling the order.

For more information on payment notification webhook, see the API reference.

For more information on errors, see the errors documentation.