Skip to content

Latest commit

 

History

History
294 lines (245 loc) · 9.53 KB

PaymentMethod.md

File metadata and controls

294 lines (245 loc) · 9.53 KB

PaymentMethod

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.

Validate a payment method's linking OTP

Function Signature

Name Value
Function Name authPaymentMethod
Request Parameters AuthPaymentMethodRequest
Return Type PaymentMethod

Request Parameters — AuthPaymentMethodRequest

Field Name Required Type
paymentMethodId string
idempotencyKey string
data PaymentMethodAuthParameters

Usage Examples

Minimum API Usage

import { PaymentMethod } from 'xendit-node/payment_method/models'

const response: PaymentMethod = await xenditPaymentMethodClient.authPaymentMethod({ 
    paymentMethodId: "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822",
})

Creates payment method

Function Signature

Name Value
Function Name createPaymentMethod
Request Parameters CreatePaymentMethodRequest
Return Type PaymentMethod

Request Parameters — CreatePaymentMethodRequest

Field Name Required Type
data PaymentMethodParameters

Usage Examples

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
})

Expires a payment method

Function Signature

Name Value
Function Name expirePaymentMethod
Request Parameters ExpirePaymentMethodRequest
Return Type PaymentMethod

Request Parameters — ExpirePaymentMethodRequest

Field Name Required Type
paymentMethodId string
idempotencyKey string
data PaymentMethodExpireParameters

Usage Examples

Minimum API Usage

import { PaymentMethod } from 'xendit-node/payment_method/models'

const response: PaymentMethod = await xenditPaymentMethodClient.expirePaymentMethod({ 
    paymentMethodId: "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822",
})

Get all payment methods by filters

Function Signature

Name Value
Function Name getAllPaymentMethods
Request Parameters GetAllPaymentMethodsRequest
Return Type PaymentMethodList

Request Parameters — GetAllPaymentMethodsRequest

Field Name Required Type
id []string
type []string
status []PaymentMethodStatus
reusability PaymentMethodReusability
customerId string
referenceId string
afterId string
beforeId string
limit number
idempotencyKey string

Usage Examples

Minimum API Usage

import { PaymentMethodList } from 'xendit-node/payment_method/models'

const response: PaymentMethodList = await xenditPaymentMethodClient.getAllPaymentMethods({ })

Get payment method by ID

Function Signature

Name Value
Function Name getPaymentMethodByID
Request Parameters GetPaymentMethodByIDRequest
Return Type PaymentMethod

Request Parameters — GetPaymentMethodByIDRequest

Field Name Required Type
paymentMethodId string
idempotencyKey string

Usage Examples

Minimum API Usage

import { PaymentMethod } from 'xendit-node/payment_method/models'

const response: PaymentMethod = await xenditPaymentMethodClient.getPaymentMethodByID({ 
    paymentMethodId: "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822",
})

Returns payments with matching PaymentMethodID.

Function Signature

Name Value
Function Name getPaymentsByPaymentMethodId
Request Parameters GetPaymentsByPaymentMethodIdRequest
Return Type object

Request Parameters — GetPaymentsByPaymentMethodIdRequest

Field Name Required Type
paymentMethodId 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
idempotencyKey string

Usage Examples

Minimum API Usage

import {  } from 'xendit-node/payment_method/models'

const response: object = await xenditPaymentMethodClient.getPaymentsByPaymentMethodId({ 
    paymentMethodId: "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822",
})

Patch payment methods

Function Signature

Name Value
Function Name patchPaymentMethod
Request Parameters PatchPaymentMethodRequest
Return Type PaymentMethod

Request Parameters — PatchPaymentMethodRequest

Field Name Required Type
paymentMethodId string
idempotencyKey string
data PaymentMethodUpdateParameters

Usage Examples

Minimum API Usage

import { PaymentMethod } from 'xendit-node/payment_method/models'

const response: PaymentMethod = await xenditPaymentMethodClient.patchPaymentMethod({ 
    paymentMethodId: "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822",
})

Makes payment with matching PaymentMethodID.

Function Signature

Name Value
Function Name simulatePayment
Request Parameters SimulatePaymentOperationRequest
Return Type (void)

Request Parameters — SimulatePaymentOperationRequest

Field Name Required Type
paymentMethodId string
idempotencyKey string
data SimulatePaymentRequest

Usage Examples

Minimum API Usage

import {  } from 'xendit-node/payment_method/models'

const response:  = await xenditPaymentMethodClient.simulatePayment({ 
    paymentMethodId: "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822",
})