xendit / xendit-node

Xendit REST API Client for Node.js - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets, QR Codes, Direct Debit
https://developers.xendit.co/api-reference/
112 stars 63 forks source link

p.setCallbackURL fail to set webhook in target business but response success #221

Closed alisaid-sm closed 1 month ago

alisaid-sm commented 1 month ago

I'm using xendit-node Version ^1.21.1

my setCallbackURL script

const { Platform } = x;
const platformSpecificOptions = {};
const p = new Platform(platformSpecificOptions);

//docs
//https://developers.xendit.co/api-reference/#set-webhook-urls

p.setCallbackURL({
  type: "ewallet",
  url: "https://api.invoice.xxxxx.com/online-payment/e_wallet/success",
  forUserID: "xxxxxb1a41caeec27a8da91c"
})
  .then(res => {
    console.log(res)
  }).catch(err => {
    console.log(err)
  })

p.setCallbackURL({
  type: "fva_paid",
  url: "https://api.invoice.xxxxx.com/online-payment/virtual_account/success",
  forUserID: "xxxxxb1a41caeec27a8da91c"
})
  .then(res => {
    console.log(res)
  }).catch(err => {
    console.log(err)
  })

xendit response

{
  status: 'SUCCESSFUL',
  user_id: 'xxxxxb1a41caeec27a8da91c',
  url: 'https://api.invoice.xxxxx.com/online-payment/virtual_account/success',
  environment: 'LIVE',
  callback_token: 'yTZSLqiR1gDTPyxSPFjWcPBOSopz84P89CkXMkopX6WRYewn'
}
{
  status: 'SUCCESSFUL',
  user_id: 'xxxxxb1a41caeec27a8da91c',
  url: 'https://api.invoice.xxxxx.com/online-payment/e_wallet/success',
  environment: 'LIVE',
  callback_token: 'yTZSLqiR1gDTPyxSPFjWcPBOSopz84P89CkXMkopX6WRYewn'
}

but when I create payment using e-wallet is keep using master account callback-url

my create payment using ewallet script

const { EWallet } = x;
const ewalletSpecificOptions = {};
const ew = new EWallet(ewalletSpecificOptions);

ew.createEWalletCharge({
  referenceID: 'test-reference-id',
  currency: 'IDR',
  amount: 50000,
  checkoutMethod: 'ONE_TIME_PAYMENT',
  channelCode: 'ID_OVO',
  channelProperties: {
    mobileNumber: "+xxxxxx9522962",
  },
  forUserID: "xxxxxb1a41caeec27a8da91c"
}).then(r => {
  console.log(r);
}).catch(err => {
  console.log(err);
});

Xendit response

{
  id: 'ewc_2a6f57c0-69ee-48c0-931f-e7099a05173c',
  business_id: 'xxxxxb1a41caeec27a8da91c',
  reference_id: 'test-reference-id',
  status: 'PENDING',
  currency: 'IDR',
  charge_amount: 50000,
  capture_amount: 50000,
  payer_charged_currency: null,
  payer_charged_amount: null,
  refunded_amount: null,
  checkout_method: 'ONE_TIME_PAYMENT',
  channel_code: 'ID_OVO',
  channel_properties: { mobile_number: '+xxxxxx9522962' },
  actions: null,
  is_redirect_required: false,
  callback_url: 'https://api.auth.xxxxx.com/license/online-payment/e_wallet/callback',
  created: '2024-07-30T08:23:57.782773Z',
  updated: '2024-07-30T08:23:57.782773Z',
  void_status: null,
  voided_at: null,
  capture_now: true,
  customer_id: null,
  customer: null,
  payment_method_id: null,
  failure_code: null,
  basket: null,
  metadata: null,
  shipping_information: null,
  payment_detail: { fund_source: null, source: null }
}

The callback-url is still using master account callback-url Expected callback_url: 'https://api.invoice.xxxxx.com/online-payment/e_wallet/success' Actual callback_url: 'https://api.auth.xxxxx.com/license/online-payment/e_wallet/callback',

Is any step I missing? Please help me ...

alisaid-sm commented 1 month ago

SetCallBackURL is only for MANAGED sub-account type and I'm using OWNED

https://docs.xendit.co/xenplatform/accounts