@waffo/waffo-node 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -229,7 +229,7 @@ app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res)
229
229
 
230
230
  const webhookHandler = waffo.webhook()
231
231
  .onPayment((notification) => {
232
- console.log('Payment received:', notification.acquiringOrderId);
232
+ console.log('Payment received:', notification.result?.acquiringOrderId);
233
233
  });
234
234
 
235
235
  const result = await webhookHandler.handleWebhook(body, signature);
@@ -283,7 +283,7 @@ export class PaymentController {
283
283
  ) {
284
284
  const webhookHandler = this.waffo.webhook()
285
285
  .onPayment((notification) => {
286
- console.log('Payment received:', notification.acquiringOrderId);
286
+ console.log('Payment received:', notification.result?.acquiringOrderId);
287
287
  });
288
288
 
289
289
  const result = await webhookHandler.handleWebhook(body, signature);
@@ -318,7 +318,7 @@ fastify.post('/webhook', async (request, reply) => {
318
318
 
319
319
  const webhookHandler = waffo.webhook()
320
320
  .onPayment((notification) => {
321
- console.log('Payment received:', notification.acquiringOrderId);
321
+ console.log('Payment received:', notification.result?.acquiringOrderId);
322
322
  });
323
323
 
324
324
  const result = await webhookHandler.handleWebhook(body, signature);
@@ -688,28 +688,28 @@ const waffo = new Waffo({ /* config */ });
688
688
  const webhookHandler = waffo.webhook()
689
689
  .onPayment((notification) => {
690
690
  console.log('Payment notification received:');
691
- console.log(' Acquiring Order ID:', notification.acquiringOrderId);
692
- console.log(' Order Status:', notification.orderStatus);
693
- console.log(' Payment Amount:', notification.orderAmount);
694
- console.log(' Payment Currency:', notification.orderCurrency);
691
+ console.log(' Acquiring Order ID:', notification.result?.acquiringOrderId);
692
+ console.log(' Order Status:', notification.result?.orderStatus);
693
+ console.log(' Payment Amount:', notification.result?.orderAmount);
694
+ console.log(' Payment Currency:', notification.result?.orderCurrency);
695
695
 
696
696
  // Tip: First verify amount and currency match your records
697
697
  // Then handle based on orderStatus
698
698
 
699
- if (notification.orderStatus === 'PAY_SUCCESS') {
699
+ if (notification.result?.orderStatus === 'PAY_SUCCESS') {
700
700
  // Payment successful - update order status, deliver goods, etc.
701
701
  }
702
702
  })
703
703
  .onRefund((notification) => {
704
- console.log('Refund notification:', notification.acquiringRefundOrderId);
704
+ console.log('Refund notification:', notification.result?.acquiringRefundOrderId);
705
705
  // Handle refund notification
706
706
  })
707
707
  .onSubscriptionStatus((notification) => {
708
708
  console.log('Subscription status notification:');
709
- console.log(' Subscription ID:', notification.subscriptionId);
710
- console.log(' Subscription Status:', notification.subscriptionStatus);
709
+ console.log(' Subscription ID:', notification.result?.subscriptionId);
710
+ console.log(' Subscription Status:', notification.result?.subscriptionStatus);
711
711
 
712
- switch (notification.subscriptionStatus) {
712
+ switch (notification.result?.subscriptionStatus) {
713
713
  case 'ACTIVE':
714
714
  // Subscription activated - grant membership privileges
715
715
  break;
@@ -731,28 +731,28 @@ const webhookHandler = waffo.webhook()
731
731
  }
732
732
  })
733
733
  .onSubscriptionPeriodChanged((notification) => {
734
- console.log('Subscription period changed:', notification.subscriptionId);
734
+ console.log('Subscription period changed:', notification.result?.subscriptionId);
735
735
  // Key fields to track:
736
- // - notification.period: Current period number
737
- // - notification.nextChargeAt: Next billing time
738
- // - notification.subscriptionStatus: Subscription status
739
- // - notification.orderStatus: Current billing order status (SUCCESS/FAILED)
740
- // - notification.orderAmount: Billing amount
741
- // - notification.orderCurrency: Billing currency
736
+ // - notification.result?.period: Current period number
737
+ // - notification.result?.nextChargeAt: Next billing time
738
+ // - notification.result?.subscriptionStatus: Subscription status
739
+ // - notification.result?.orderStatus: Current billing order status (SUCCESS/FAILED)
740
+ // - notification.result?.orderAmount: Billing amount
741
+ // - notification.result?.orderCurrency: Billing currency
742
742
  })
743
743
  .onSubscriptionChange((notification) => {
744
744
  console.log('Subscription change notification:');
745
- console.log(' Change Request ID:', notification.subscriptionRequest);
746
- console.log(' Change Status:', notification.subscriptionChangeStatus);
747
- console.log(' Origin Subscription:', notification.originSubscriptionId);
748
- console.log(' New Subscription:', notification.subscriptionId);
745
+ console.log(' Change Request ID:', notification.result?.subscriptionRequest);
746
+ console.log(' Change Status:', notification.result?.subscriptionChangeStatus);
747
+ console.log(' Origin Subscription:', notification.result?.originSubscriptionId);
748
+ console.log(' New Subscription:', notification.result?.subscriptionId);
749
749
 
750
- if (notification.subscriptionChangeStatus === 'SUCCESS') {
750
+ if (notification.result?.subscriptionChangeStatus === 'SUCCESS') {
751
751
  // Subscription change successful
752
752
  // - Original subscription is now MERCHANT_CANCELLED
753
753
  // - New subscription is now ACTIVE
754
754
  // Update user's subscription level accordingly
755
- } else if (notification.subscriptionChangeStatus === 'CLOSED') {
755
+ } else if (notification.result?.subscriptionChangeStatus === 'CLOSED') {
756
756
  // Subscription change failed/closed
757
757
  // Original subscription remains unchanged
758
758
  }