-
Notifications
You must be signed in to change notification settings - Fork 7
Webhooks Not Being Triggered #41
Description
Issue: Webhooks Not Being Triggered in Moyasar Node Package
Description
I am encountering an issue where webhooks are not being triggered after initiating a payment using the Moyasar Node package. Although the payment process works as expected and returns a valid response, there are no webhook attempts recorded, and my webhook endpoint is not being called.
Steps to Reproduce
-
Use the following code snippet to initiate a payment:
try { const response = await fetch("https://api.moyasar.com/v1/payments", { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Basic " + btoa(`***:`), }, body: JSON.stringify({ source: { type: "creditcard", name: "Jack Daron", number: "4201320111111010", cvc: "123", month: "12", year: "28", }, amount: "1001000", currency: "EUR", description: "Testing Moyasar payment", }), }); const result = await response.json(); if (response.ok) { alert("Payment Successful!"); console.log(result); } else { alert("Payment Failed: " + result.message); console.error(result); } } catch (error) { alert("An error occurred while processing the payment."); console.error(error); }
-
Observe the logged response, which shows the payment is initiated successfully:
{
"id": "",
"status": "initiated",
"amount": 1001000,
"fee": 0,
"currency": "EUR",
"refunded": 0,
"refunded_at": null,
"captured": 0,
"captured_at": null,
"voided_at": null,
"description": "Testing Moyasar payment ",
"amount_format": "10,010.00 EUR",
"fee_format": "0.00 EUR",
"refunded_format": "0.00 EUR",
"captured_format": "0.00 EUR",
"invoice_id": null,
"ip": "",
"callback_url": "",
"created_at": "2024-11-27T15:18:53.485Z",
"updated_at": "2024-11-27T15:18:53.485Z",
"metadata": null,
"source": {
"type": "creditcard",
"company": "mada",
"name": "Awd Awd",
"number": "4201-32XX-XXXX-1010",
"gateway_id": "moyasar_cc_MMWUsRSMzWtFLcsXYcvzDf7",
"reference_number": null,
"token": null,
"message": null,
"transaction_url": ""
}
}
3. Verify webhooks using the following command:
```bash
curl "https://api.moyasar.com/v1/webhooks" -u "***:"
Response:
{
"webhooks": [
{
"id": "****",
"http_method": "post",
"url": "****",
"created_at": "2024-11-27T14:58:35.510Z",
"events": [
"payment_paid",
"payment_failed",
"payment_voided",
"payment_authorized",
"payment_captured",
"payment_refunded",
"payment_abandoned",
"payment_verified",
"payment_canceled",
"payment_expired",
"balance_transferred",
"payout_initiated",
"payout_paid",
"payout_failed",
"payout_canceled",
"payout_returned"
...
]
}
]
}- Check webhook attempts:
Response:
curl "https://api.moyasar.com/v1/webhooks/attempts" -u "***:"
{ "webhook_attempts": [], "meta": { "current_page": 1, "total_count": 0 } }
Expected Behavior
The webhook endpoint should be called for the configured events (e.g., payment_paid, payment_failed) after the payment is initiated, and webhook attempts should be logged.
Actual Behavior
No webhook attempts are recorded, and the webhook endpoint is not called, even though the payment process completes successfully.
Additional Information
- The webhook is configured correctly and is visible in the response of
/v1/webhooks. - The issue persists despite valid payment data and a successful payment initiation.
- The webhook attempts list is empty.
- The webhook receive and object and immediately returns status 200
Environment
- Moyasar API version:
v1 - Node.js version:
23.3.0 - API key:
testing