Payment Intents
Create, process, and track payments through their lifecycle
A Payment Intent represents a single payment attempt. The typical flow is:
- Create a payment intent with the amount and currency
- Proceed with a selected payment method
- Handle any redirects (3DS, OTP verification)
- Check the payment status
Create Payment Intent
Creates a new payment intent. Returns a paymentId and clientSecret that you use in subsequent calls.
/payments/intentsQuery Parameters
countryCodestringrequiredDZARequest Body
actionIdstringrequiredamountnumberrequiredactionCurrencyCodestringrequiredDZD, MAD, USDactionCountryCodestringrequireduserIdstringrequiredmetaDataobjectoptionalpaymentCheckoutId for tracking.Required Headers
AuthorizationstringrequiredBasic base64(client_id:client_secret)x-platformstringrequiredAPIWEBANDROIDIOSx-servicestringrequiredContent-Typestringrequiredapplication/json.Example Request
curl -X POST "https://api.payment.yassir.com/payments/intents?countryCode=DZA" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "Content-Type: application/json" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-d '{
"actionId": "order_12345",
"amount": 1500.00,
"actionCurrencyCode": "DZD",
"actionCountryCode": "DZA",
"userId": "user_abc123"
}'curl -X POST "https://api.payment.yassir.com/payments/intents?countryCode=DZA" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "Content-Type: application/json" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-d '{
"actionId": "order_12345",
"amount": 1500.00,
"actionCurrencyCode": "DZD",
"actionCountryCode": "DZA",
"userId": "user_abc123"
}'Response
{
"data": {
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"clientSecret": "pa_abc123_secret_xyz789",
"status": "pending",
"amount": 1500.00,
"currency": "DZD"
},
"message": "payment initiated successfully"
}{
"data": {
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"clientSecret": "pa_abc123_secret_xyz789",
"status": "pending",
"amount": 1500.00,
"currency": "DZD"
},
"message": "payment initiated successfully"
}data.paymentIdstringrequireddata.clientSecretstringrequireddata.statusstringrequiredpending after creation.data.amountnumberrequireddata.currencystringrequiredProceed with Payment
Submits the payment for processing with the selected payment method. Depending on the payment method, the response may indicate that additional user action is required (e.g., OTP verification, 3DS redirect).
/payments/intents/:id/proceedURL Parameters
idstringrequiredpaymentId returned from the Create Payment Intent endpoint.Request Body
paymentMethodCodestringrequiredWALLET_V2secondaryPaymentMethodCodestringoptionalcardIdstringoptionalCREDIT_CARD payment method. The saved card identifier.Required Headers
AuthorizationstringrequiredBasic base64(client_id:client_secret)x-platformstringrequiredAPIWEBANDROIDIOSx-servicestringrequiredx-client-tokenstringrequiredExample Request
curl -X POST "https://api.payment.yassir.com/payments/intents/123e4567-e89b-12d3-a456-426614174000/proceed" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "Content-Type: application/json" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-H "x-client-token: user_token_here" \
-d '{
"paymentMethodCode": "WALLET_V2"
}'curl -X POST "https://api.payment.yassir.com/payments/intents/123e4567-e89b-12d3-a456-426614174000/proceed" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "Content-Type: application/json" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-H "x-client-token: user_token_here" \
-d '{
"paymentMethodCode": "WALLET_V2"
}'Response - Direct Success
When the payment completes immediately (e.g., wallet with sufficient balance and no OTP):
{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "The amount was deposited successfully",
"statusCode": 2,
"require3DS": false,
"metadata": {}
},
"message": "payment proceeded successfully"
}{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "The amount was deposited successfully",
"statusCode": 2,
"require3DS": false,
"metadata": {}
},
"message": "payment proceeded successfully"
}Response - Requires Action (OTP / 3DS)
When the payment method requires additional verification (OTP, 3DS, or bank redirect), the response includes a payUrl that the user must be redirected to:
{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "Pending 3DS Verification",
"statusCode": 12,
"require3DS": true,
"metadata": {
"payUrl": "https://payment-otp.yassir.com/otp/verify?requestId=txn_abc123&phone=213555123456&amount=1500¤cy=DZD&paymentMethod=WALLET_V2"
}
},
"message": "payment proceeded successfully"
}{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "Pending 3DS Verification",
"statusCode": 12,
"require3DS": true,
"metadata": {
"payUrl": "https://payment-otp.yassir.com/otp/verify?requestId=txn_abc123&phone=213555123456&amount=1500¤cy=DZD&paymentMethod=WALLET_V2"
}
},
"message": "payment proceeded successfully"
}Handling Redirects
require3DS is true, you must redirect the user to the payUrl. Append a returnUrl query parameter so the user is redirected back to your app after completing verification. Example:payUrl + &returnUrl=https://yourapp.com/payment-success?paymentId=...Response - Rejected
When the payment is rejected by the provider (e.g., insufficient balance):
{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "Transaction was rejected",
"statusCode": 3,
"require3DS": false,
"metadata": {}
},
"message": "payment proceeded successfully"
}{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "Transaction was rejected",
"statusCode": 3,
"require3DS": false,
"metadata": {}
},
"message": "payment proceeded successfully"
}Status Codes
| statusCode | Meaning | Action Required |
|---|---|---|
2 | Success | Payment completed. Show success to user. |
3 | Rejected | Payment failed. Show error and allow retry. |
12 | Requires Action | Redirect user to payUrl for verification. |
Check Payment Status
Retrieves the current status of a payment intent. Use this after the user returns from a redirect to confirm the payment result.
/payments/intents/:id/checkURL Parameters
idstringrequiredpaymentId to check.Required Headers
AuthorizationstringrequiredBasic base64(client_id:client_secret)x-platformstringrequiredAPIWEBANDROIDIOSx-servicestringrequiredx-client-tokenstringrequiredExample Request
curl -X GET "https://api.payment.yassir.com/payments/intents/123e4567-e89b-12d3-a456-426614174000/check" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-H "x-client-token: user_token_here"curl -X GET "https://api.payment.yassir.com/payments/intents/123e4567-e89b-12d3-a456-426614174000/check" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-H "x-client-token: user_token_here"Response
{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "The amount was deposited successfully",
"statusCode": 2,
"amount": 1500.00,
"currency": "DZD",
"paymentMethodCode": "WALLET_V2"
},
"message": "payment checked successfully"
}{
"data": {
"id": "txn_abc123",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"status": "The amount was deposited successfully",
"statusCode": 2,
"amount": 1500.00,
"currency": "DZD",
"paymentMethodCode": "WALLET_V2"
},
"message": "payment checked successfully"
}Refund Payment
Refund a completed payment, either fully or partially.
/payments/:paymentId/refundURL Parameters
paymentIdstringrequiredRequest Body
descriptionstringrequiredamountnumberoptionalreasonstringoptionalExample Request
curl -X POST "https://api.payment.yassir.com/payments/123e4567-e89b-12d3-a456-426614174000/refund" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "Content-Type: application/json" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-d '{
"description": "Customer requested refund",
"amount": 500.00
}'curl -X POST "https://api.payment.yassir.com/payments/123e4567-e89b-12d3-a456-426614174000/refund" \
-H "Authorization: Basic $(echo -n 'your_client_id:your_client_secret' | base64)" \
-H "Content-Type: application/json" \
-H "x-platform: API" \
-H "x-service: YOUR_SERVICE" \
-d '{
"description": "Customer requested refund",
"amount": 500.00
}'{
"data": {
"id": "refund_xyz789",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"amount": 500.00,
"status": "completed",
"reason": "Customer requested refund"
},
"message": "payment refunded successfully"
}{
"data": {
"id": "refund_xyz789",
"paymentId": "123e4567-e89b-12d3-a456-426614174000",
"amount": 500.00,
"status": "completed",
"reason": "Customer requested refund"
},
"message": "payment refunded successfully"
}