You can use the APIs below to interface with Xendit's PaymentMethod
API.
To start using the API, you need to destruct instantiated Xendit client or directly import the module and set the secret key.
import { Xendit , PaymentMethod as PaymentMethodClient } from 'xendit-node' ;
const xenditClient = new Xendit ( { secretKey : YOUR_SECRET_KEY } )
const { PaymentMethod } = xenditClient
const xenditPaymentMethodClient = new PaymentMethodClient ( { secretKey : YOUR_SECRET_KEY } )
// At this point, `PaymentMethod` and `xenditPaymentMethodClient` will have no usage difference, for example:
// PaymentMethod.
// or
// xenditPaymentMethodClient.
All URIs are relative to https://api.xendit.co , except if the operation defines another base path.
createPaymentMethod()
Function
Request Parameters - CreatePaymentMethodRequest
Account linking for E-Wallet
import { PaymentMethodParameters , PaymentMethod } from 'xendit-node/payment_method/models'
const data : PaymentMethodParameters = {
"ewallet" : {
"channelProperties" : {
"failureReturnUrl" : "https://redirect.me/failure" ,
"successReturnUrl" : "https://redirect.me/success" ,
"cancelReturnUrl" : "https://redirect.me/cancel"
} ,
"channelCode" : "OVO"
} ,
"metadata" : {
"sku" : "example-1234"
} ,
"reusability" : "MULTIPLE_USE" ,
"type" : "EWALLET" ,
"customer" : {
"type" : "INDIVIDUAL" ,
"referenceId" : "customer-123" ,
"individualDetail" : {
"surname" : "Doe" ,
"givenNames" : "John"
}
}
}
const response : PaymentMethod = await xenditPaymentMethodClient . createPaymentMethod ( {
data
} )
Account linking for PH Direct Debit
import { PaymentMethodParameters , PaymentMethod } from 'xendit-node/payment_method/models'
const data : PaymentMethodParameters = {
"mobileNumber" : 628774494404 ,
"reusability" : "MULTIPLE_USE" ,
"type" : "DIRECT_DEBIT" ,
"directDebit" : {
"channelProperties" : {
"failureReturnUrl" : "https://redirect.me/failure" ,
"successReturnUrl" : "https://redirect.me/success"
} ,
"channelCode" : "BPI"
} ,
"email" : "[email protected] " ,
"customer" : {
"type" : "INDIVIDUAL" ,
"referenceId" : "customer-123" ,
"individualDetail" : {
"surname" : "Doe" ,
"givenNames" : "John"
}
}
}
const response : PaymentMethod = await xenditPaymentMethodClient . createPaymentMethod ( {
data
} )
getPaymentMethodByID()
Function
Request Parameters - GetPaymentMethodByIDRequest
Field Name
Type
Required
Default
paymentMethodId
string
☑️
forUserId
string
import { PaymentMethod } from 'xendit-node/payment_method/models'
const response : PaymentMethod = await xenditPaymentMethodClient . getPaymentMethodByID ( {
paymentMethodId : "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822" ,
)
getPaymentsByPaymentMethodId()
Function
Request Parameters - GetPaymentsByPaymentMethodIdRequest
Field Name
Type
Required
Default
paymentMethodId
string
☑️
forUserId
string
paymentRequestId
string[]
paymentMethodId2
string[]
referenceId
string[]
paymentMethodType
PaymentMethodType[]
channelCode
string[]
status
string[]
currency
string[]
createdGte
Date
createdLte
Date
updatedGte
Date
updatedLte
Date
limit
number
const response : object = await xenditPaymentMethodClient . getPaymentsByPaymentMethodId ( {
paymentMethodId : "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822" ,
)
patchPaymentMethod()
Function
Request Parameters - PatchPaymentMethodRequest
import { PaymentMethod } from 'xendit-node/payment_method/models'
const response : PaymentMethod = await xenditPaymentMethodClient . patchPaymentMethod ( {
paymentMethodId : "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822" ,
)
getAllPaymentMethods()
Function
Request Parameters - GetAllPaymentMethodsRequest
import { PaymentMethodList } from 'xendit-node/payment_method/models'
const response : PaymentMethodList = await xenditPaymentMethodClient . getAllPaymentMethods ( { )
expirePaymentMethod()
Function
Request Parameters - ExpirePaymentMethodRequest
import { PaymentMethod } from 'xendit-node/payment_method/models'
const response : PaymentMethod = await xenditPaymentMethodClient . expirePaymentMethod ( {
paymentMethodId : "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822" ,
)
authPaymentMethod()
Function
Request Parameters - AuthPaymentMethodRequest
import { PaymentMethod } from 'xendit-node/payment_method/models'
const response : PaymentMethod = await xenditPaymentMethodClient . authPaymentMethod ( {
paymentMethodId : "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822" ,
)
simulatePayment()
Function
Request Parameters - SimulatePaymentOperationRequest
const response = await xenditPaymentMethodClient . simulatePayment ( {
paymentMethodId : "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822" ,
} )
Use the following callback objects provided by Xendit to receive callbacks (also known as webhooks) that Xendit sends you on events, such as successful payments. Note that the example is meant to illustrate the contents of the callback object -- you will not need to instantiate these objects in practice
PaymentMethodCallback Object
Callback for active or expired E-Wallet or Direct Debit account linking, Virtual Accounts or QR strings
Model Documentation: PaymentMethodCallback
Note that the example is meant to illustrate the contents of the callback object -- you will not need to instantiate these objects in practice
import { PaymentMethodCallback } from 'xendit-node/payment_method/models'
const paymentMethodCallback = {
"data" : {
"country" : "PH" ,
"metadata" : null ,
"failureCode" : null ,
"created" : "2022-08-12T13:30:26.579048Z" ,
"description" : null ,
"reusability" : "MULTIPLE_USE" ,
"type" : "DIRECT_DEBIT" ,
"billingInformation" : null ,
"directDebit" : {
"bankAccount" : {
"maskedBankAccountNumber" : "XXXXXX1234" ,
"bankAccountHash" : "b4dfa99c9b60c77f2e3962b73c098945"
} ,
"channelProperties" : {
"failureReturnUrl" : "https://your-redirect-website.com/failure" ,
"successReturnUrl" : "https://your-redirect-website.com/success"
} ,
"debitCard" : null ,
"type" : "BANK_ACCOUNT" ,
"channelCode" : "BPI"
} ,
"referenceId" : "620b9df4-fe69-4bfd-b9d4-5cba6861db8a" ,
"ewallet" : null ,
"directBankTransfer" : null ,
"qrCode" : null ,
"overTheCounter" : null ,
"customerId" : "e2878b4c-d57e-4a2c-922d-c0313c2800a3" ,
"id" : "pm-6ff0b6f2-f5de-457f-b08f-bc98fbae485a" ,
"updated" : "2022-08-12T13:30:58.908220358Z" ,
"virtualAccount" : null ,
"card" : null ,
"status" : "ACTIVE"
} ,
"created" : "2022-08-12T13:30:59.074277334Z" ,
"businessId" : "5f27a14a9bf05c73dd040bc8" ,
"event" : "payment_method.activated"
}
You may then use the callback object in your webhook or callback handler like so,
function SimulatePaymentMethodCallback ( paymentMethodCallback : PaymentMethodCallback ) {
const { id } = paymentMethodCallback
// do things here with the callback
}
[Back to README]