Card Refund
Refund a previously completed card transaction.
Amount: For refunds, the same rule applies as for Card Sale: use a string for
amountso the value sent to your signature API uses the exact same characters (including decimal places and fractional padding) assetAmount(). That way the computed signature matches the refund payload built by the SDK.
Example
var sid = FawrySDK.generateSessionId();
var clientTimeStamp = Date.now();
var amountStr = '150.00';
// Get signature from your backend (amount is required for refund signature)
var sigResponse = await fetch('/api/generate-signature', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
amount: amountStr,
merchantAccountNumber: 'YOUR_ACCOUNT_NUMBER',
sid: sid,
clientTimeStamp: clientTimeStamp,
}),
});
var sigData = await sigResponse.json();
try {
var result = await FawrySDK.requestRefund(FawrySDK.PaymentOptionType.CARD)
.setAmount(amountStr)
.setTransactionFCRN('ORIGINAL_FCRN_HERE')
.setSignature(sigData.signature)
.setSid(sid)
.setClientTimeStamp(clientTimeStamp)
.setPartnerCode('YOUR_PARTNER_CODE')
.setMerchantAccountNumber('YOUR_ACCOUNT_NUMBER')
.setBtc(99902)
.send();
if (result.isSuccess()) {
console.log('Refund successful! FCRN:', result.body.fcrn);
}
} catch (error) {
console.error('Refund failed:', error.message);
}
Parameters
| Parameter | Method | Required | Description |
|---|---|---|---|
| Amount | setAmount() |
Yes | Refund amount as a string (same as for signature) |
| Transaction FCRN | setTransactionFCRN() |
No | FCRN of the original transaction |
| Order ID | setOrderId() |
No | Order/reference ID |
| Split Payment | setSplitPayment() |
No | Enable split payment refund |
| Chain UID | setChainUID() |
No | Chain UID for split payments |
Plus all common builder methods (signature, sid, timestamp, setBtc, optional setPrintReceipt / setDisplayInvoice — default false, etc.).
Example successful response
{
"header": {
"messageCode": "refund",
"status": {
"statusCode": 1,
"statusDesc": "success",
"hostStatusCode": 0,
"hostStatusDesc": "Approved"
}
},
"body": {
"fcrn": "FCRN-REFUND-001",
"amount": "150.00",
"currency": "EGP"
}
}
Example failed response
{
"header": {
"messageCode": "refund",
"status": {
"statusCode": 0,
"statusDesc": "failed",
"hostStatusDesc": "Refund not allowed"
}
},
"body": {}
}
Notes
- The refund amount should match or be less than the original transaction amount.
- Use the
transactionFCRNfrom the original sale’sresult.body.fcrnto link the refund to the correct transaction. - Use the bill type code (
setBtc) required by Fawry for your refund flow (example value99902is illustrative only).