Refund a Payment
There are two ways to refund; through your payment gateway and mark it refunded in the Commerce Cloud dashboard, or directly through the Commerce Cloud dashboard or API.
- Mark as Refunded: You can manually mark a transaction as refunded. Before you can mark the order as refunded, you need to handle the actual refund on your side with your payment provider.
- Refund through Commerce Cloud: You can process a full or partial refund to a supported payment provider directly from the Elastic Path Commerce Cloud dashboard or API. When you start the refund process, the request is directly sent to the payment gateway.
POST
Refund a Full Payment
https://api.moltin.com/v2/orders/:orderId/transactions/:transactionId/refund
Path Parameters:
Name | Required | Type | Description |
---|---|---|---|
transactionId | Required | string | The UUID of the transaction you want to refund. |
orderId | Required | string | The UUID of the order. |
Headers:
Name | Required | Type | Description |
---|---|---|---|
Authorization | Required | string | The Bearer token to grant access to the API. |
200 OK
{
"data": {
"id": "6112f8b0-ce4e-4ef8-a117-cb741654efa5",
"type": "transaction",
"reference": "B8PP0D6ABE57",
"gateway": "<Your payment provider>",
"amount": 10000,
"refunded_amount": 10000,
"refund_mechanism": "automatic",
"currency": "USD",
"transaction_type": "refund",
"status": "complete",
"relationships": {
"order": {
"data": {
"type": "order",
"id": "1b031452-b048-43b9-a06c-feafe6e4bc31"
}
},
"timestamps": {
"created_at": "2020-07-03T21:07:45Z",
"updated_at": "2020-07-03T14:09:12-07:00"
}
},
"meta": {
"display_price": {
"amount": 10000,
"currency": "USD",
"formatted": "$100.00"
},
"display_refunded_amount": {
"total": {
"amount": 10000,
"currency": "USD",
"formatted": "$100.00"
}
},
"timestamps": {
"created_at": "2020-07-03T21:10:14Z",
"updated_at": "2020-07-03T14:11:59-07:00"
}
},
"meta": {
"display_price": {
"amount": 10000,
"currency": "USD",
"formatted": "$100.00"
},
"display_refunded_amount": {
"total": {
"amount": 10000,
"currency": "USD",
"formatted": "$100.00"
}
},
"timestamps": {
"created_at": "2020-07-03T21:10:14Z",
"updated_at": "2020-07-03T14:11:59-07:00"
}
}
}
}
Note: This is the pre-existing function. You must go to your payment provider’s gateway to complete the refund and then you can mark a transaction as refunded in the Commerce Cloud dashboard or the API.
curl -X POST https://api.moltin.com/v2/orders/:orderId/transactions/:transactionId/refund \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
Note: Ensure that you use the correct
option
parameter for your payment provider. For example, PayPal Express uses thenote
parameter where you can provide comments about the refund.
curl -X POST https://api.moltin.com/v2/orders/:orderId/transactions/:transactionId/refund \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"amount": <Total of captured amount>,
"options": {
"note": "PayPal Express users"
}
}'
POST
Refund a Partial Payment
https://api.moltin.com/v2/orders/:orderId/transactions/:transactionId/refund
Path Parameters:
Name | Required | Type | Description |
---|---|---|---|
transactionId | Required | string | The UUID of the transaction you want to refund. |
orderId | Required | string | The UUID of the order. |
Headers:
Name | Required | Type | Description |
---|---|---|---|
Authorization | Required | string | The Bearer token to grant access to the API. |
200 OK
{
"data": {
"id": "d1e0b7db-3112-47ee-aaf9-c96d6a94bbcc",
"type": "transaction",
"reference": "B8PP0D6494BD",
"gateway": "<Your payment provider>",
"amount": 10000,
"refunded_amount": 5000,
"refund_mechanism": "automatic",
"currency": "USD",
"transaction_type": "refund",
"status": "complete",
"relationships": {
"order": {
"data": {
"type": "order",
"id": "09a46cb9-4eb7-49c9-97f1-e0c8085017a6"
}
}
},
"meta": {
"display_price": {
"amount": 10000,
"currency": "USD",
"formatted": "$100.00"
},
"display_refunded_amount": {
"total": {
"amount": 5000,
"currency": "USD",
"formatted": "$50.00"
}
},
"timestamps": {
"created_at": "2020-06-26T23:06:02Z",
"updated_at": "2020-06-26T23:06:50Z"
}
}
}
Note: Ensure that you list the amount of the refund in cents. For example, for a refund of $10.00, put
1000
. Also ensure that you use the correctoption
parameter for your payment provider. For example, PayPal Express uses thenote
parameter where you can provide comments about the refund.
curl -X POST https://api.moltin.com/v2/orders/:orderId/transactions/:transactionId/refund \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $' {
"data": {
"amount": 100,
"options": {
"note": "PayPal Express users"
}
}'