Skip to content

Commit

Permalink
Merge pull request #169 from alphamanuscript/128-fix-flw-transfer-not…
Browse files Browse the repository at this point in the history
…ification-error

Fix error processing flutterwave transfer notification
  • Loading branch information
habbes authored Oct 28, 2020
2 parents 1102219 + a0762df commit 912066e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/src/core/payment/flutterwave-payment-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ interface FlutterwaveTransactionResponse {
function extractTransactionInfo(data: FlutterwaveTransactionInfo): ProviderTransactionInfo {
const status: TransactionStatus = data.status === 'successful' ? 'success' :
data.status === 'failed' ? 'failed' : 'pending';

// phone number comes in in 07... format, strip the 0
const flwPhone = data.customer?.phone_number?.substring(1);

return {
userData: {
phone: `254${data.customer.phone_number.substring(1)}` // use internal instead of local format
phone: flwPhone ? `254${flwPhone}` : '' // convert to internal 254 format
},
status,
amount: data.amount,
Expand Down
1 change: 1 addition & 0 deletions server/src/webhooks/flutterwave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ flutterwaveRoutes.post('/', (req: AppRequest, res) => {
.then(_ => res.status(200).send())
.catch(e => {
console.error('Flutterwave notification error', e);
console.error('Notification payload', JSON.stringify(req.body, null, 2));
res.status(400).send();
});
});

0 comments on commit 912066e

Please sign in to comment.