Requirements
To refund a payment, you need to:- Access your API credentials on the Yuno Dashboard, which consist of:
public-api-keyprivate-secret-key
- Have the payment identification data received after creating the payment using the Create Payment endpoint and the capture data from the capture operation executed using the Capture Payment:
id: The unique identifier of the payment, obtained from the parameteridafter creating the payment.transaction_id: The unique identifier of the transaction. You will use a different source for this information, depending on how you captured the payment.- If you created and captured the payment using only one operation, you obtain the
transaction_idfrom the parametertransaction.idafter creating the payment with the Create Payment endpoint. - If you performed the authorization and then the payment capture, you will use the
transaction_idfrom the parameteridreceived after capturing the payment using the Capture Payment endpoint. - If you retrieve the payment later with the Retrieve Payment by ID endpoint, take the
idof the transaction whosetypeisPURCHASEorCAPTUREfrom thetransactionsarray. Theidof aREFUNDtransaction cannot be used to refund.
- If you created and captured the payment using only one operation, you obtain the
Explore Yuno Postman CollectionsYuno provides Postman Collections that you can use to replicate the use cases locally.
Refund a payment
If you initiate a refund, it will reimburse a charge created earlier but not yet refunded. The amount will be credited back to the original payment method that was charged. Yuno offers three endpoints to refund a payment. They share the same request body, and every call requires anX-Idempotency-Key header with a new value for each attempt:
- Refund Payment: Refunds a specific transaction. Provide the payment
idand thetransaction_id. Use it when you want to control exactly which transaction is refunded. - Cancel or Refund a Payment: Works at the payment level, so no
transaction_idis needed. Yuno cancels the payment if it has not been captured and refunds it if it has. Thereasonfield is required. - Cancel or Refund a Payment with Transaction: Applies the same automatic decision to a specific
transaction_id.
amount in the request body:
- Complete refund: Leave the
amountempty. - Partial refund: Provide the refund value using the parameter
amount.
Refund results
The response contains a new transaction withtransaction.type = REFUND. Use its status to interpret the result of the refund:
SUCCEEDED: The provider accepted the refund. For a complete refund, the payment moves tostatus = REFUNDEDandsub_status = REFUNDED. For a partial refund, the payment keepsstatus = SUCCEEDEDand itssub_statuschanges toPARTIALLY_REFUNDED.PENDING: The provider confirms the refund asynchronously. The payment showsstatus = REFUNDEDandsub_status = PENDING_PROVIDER_CONFIRMATIONuntil the confirmation arrives. Use webhooks or the retrieve endpoints to get the final status, as described in Check the payment status.DECLINEDorERROR: The provider, or the cardholder’s issuer, rejected the refund. No funds move and the payment keeps its previousstatusandsub_status. Check the transaction’sresponse_codeandresponse_messagefor the reason. Once the cause is solved, send the refund again with a newX-Idempotency-Key, or setsimplified_modetotruein the request so Yuno retries the refund automatically, as described in Transaction Retries.
Provider-dependent behaviorWhether a refund is confirmed synchronously or stays
PENDING, whether partial refunds and several refunds on the same transaction are allowed, and for how long after the purchase a refund is accepted all depend on the provider that processed the payment. Many card acquirers process a refund as an online transaction against the cardholder’s account and answer with a final status right away, which also means the issuer can decline it. If your integration relies on any of these behaviors, confirm them with Yuno for the providers in your routing.Refund Processing TimeRefunds processing time varies depending on the payment type. While in test mode, refunds are processed instantly in the Sandbox environment. If your sandbox connection points to the provider’s own test environment, the refund is sent to that environment and requires a successful test purchase first.
Check the payment status
If, for some reason, you need to confirm the payment refund:- Use the Retrieve Payment by ID or Retrieve Payment by merchant_order_id to get detailed information about the payment.
- Alternatively, set up webhooks to receive notifications for each event. Refer to the Webhooks guide to learn how to configure webhooks in Yuno.