You can use the APIs below to interface with Xendit's PaymentMethodApi
.
To start using the API, you need to configure the secret key and initiate the client instance.
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
All URIs are relative to https://api.xendit.co , except if the operation defines another base path.
createPaymentMethod()
Function
createPaymentMethod ($ for_user_id , $ payment_method_parameters ): \PaymentMethod \PaymentMethod
Creates payment method
This endpoint initiates creation of payment method
Request Parameters - CreatePaymentMethodRequestParams
Account linking for E-Wallet
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ payment_method_parameters = new Xendit \PaymentMethod \PaymentMethodParameters ([
'type ' => 'EWALLET ' ,
'reusability ' => 'MULTIPLE_USE ' ,
'customer ' => [
'reference_id ' => 'customer-123 ' ,
'type ' => 'INDIVIDUAL ' ,
'individual_detail ' => [
'given_names ' => 'John ' ,
'surname ' => 'Doe '
]
],
'ewallet ' => [
'channel_code ' => 'OVO ' ,
'channel_properties ' => [
'success_return_url ' => 'https://redirect.me/success ' ,
'failure_return_url ' => 'https://redirect.me/failure ' ,
'cancel_return_url ' => 'https://redirect.me/cancel '
]
],
'metadata ' => [
'sku ' => 'example-1234 '
]
]); // \Xendit\PaymentMethod\PaymentMethodParameters
try {
$ result = $ apiInstance ->createPaymentMethod ($ for_user_id , $ payment_method_parameters );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->createPaymentMethod: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
Account linking for PH Direct Debit
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ payment_method_parameters = new Xendit \PaymentMethod \PaymentMethodParameters ([
'type ' => 'DIRECT_DEBIT ' ,
'direct_debit ' => [
'channel_code ' => 'BPI ' ,
'channel_properties ' => [
'success_return_url ' => 'https://redirect.me/success ' ,
'failure_return_url ' => 'https://redirect.me/failure '
]
],
'reusability ' => 'MULTIPLE_USE ' ,
'customer ' => [
'reference_id ' => 'customer-123 ' ,
'type ' => 'INDIVIDUAL ' ,
'individual_detail ' => [
'given_names ' => 'John ' ,
'surname ' => 'Doe '
]
],
'email ' => '[email protected] ' ,
'mobile_number ' => 628774494404
]); // \Xendit\PaymentMethod\PaymentMethodParameters
try {
$ result = $ apiInstance ->createPaymentMethod ($ for_user_id , $ payment_method_parameters );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->createPaymentMethod: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
getPaymentMethodByID()
Function
getPaymentMethodByID ($ payment_method_id , $ for_user_id ): \PaymentMethod \PaymentMethod
Get payment method by ID
Get payment method by ID
Request Parameters - GetPaymentMethodByIDRequestParams
Name
Type
Required
Default
payment_method_id
string
☑️
for_user_id
string
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ payment_method_id = "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822 " ; // string
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
try {
$ result = $ apiInstance ->getPaymentMethodByID ($ payment_method_id , $ for_user_id );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->getPaymentMethodByID: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
getPaymentsByPaymentMethodId()
Function
getPaymentsByPaymentMethodId ($ payment_method_id , $ for_user_id , $ payment_request_id , $ payment_method_id2 , $ reference_id , $ payment_method_type , $ channel_code , $ status , $ currency , $ created_gte , $ created_lte , $ updated_gte , $ updated_lte , $ limit ): object
Returns payments with matching PaymentMethodID.
Returns payments with matching PaymentMethodID.
Request Parameters - GetPaymentsByPaymentMethodIdRequestParams
Name
Type
Required
Default
payment_method_id
string
☑️
for_user_id
string
payment_request_id
string[]
payment_method_id2
string[]
reference_id
string[]
payment_method_type
PaymentMethodType
channel_code
string[]
status
string[]
currency
string[]
created_gte
\DateTime
created_lte
\DateTime
updated_gte
\DateTime
updated_lte
\DateTime
limit
int
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ payment_method_id = "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822 " ; // string
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ payment_request_id = array ('payment_request_id_example ' ); // string[]
$ payment_method_id2 = array ('payment_method_id_example ' ); // string[]
$ reference_id = array ('reference_id_example ' ); // string[]
$ payment_method_type = array (new \Xendit \PaymentMethod \PaymentMethodType ()); // \PaymentMethod\PaymentMethodType[]
$ channel_code = array ('channel_code_example ' ); // string[]
$ status = array ('status_example ' ); // string[]
$ currency = array ('currency_example ' ); // string[]
$ created_gte = new \DateTime ("2013-10-20T19:20:30+01:00 " ); // \DateTime
$ created_lte = new \DateTime ("2013-10-20T19:20:30+01:00 " ); // \DateTime
$ updated_gte = new \DateTime ("2013-10-20T19:20:30+01:00 " ); // \DateTime
$ updated_lte = new \DateTime ("2013-10-20T19:20:30+01:00 " ); // \DateTime
$ limit = 56 ; // int
try {
$ result = $ apiInstance ->getPaymentsByPaymentMethodId ($ payment_method_id , $ for_user_id , $ payment_request_id , $ payment_method_id2 , $ reference_id , $ payment_method_type , $ channel_code , $ status , $ currency , $ created_gte , $ created_lte , $ updated_gte , $ updated_lte , $ limit );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->getPaymentsByPaymentMethodId: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
patchPaymentMethod()
Function
patchPaymentMethod ($ payment_method_id , $ for_user_id , $ payment_method_update_parameters ): \PaymentMethod \PaymentMethod
Patch payment methods
This endpoint is used to toggle the status
of an e-Wallet or a Direct Debit payment method to ACTIVE
or INACTIVE
. This is also used to update the details of an Over-the-Counter or a Virtual Account payment method.
Request Parameters - PatchPaymentMethodRequestParams
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ payment_method_id = "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822 " ; // string
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ payment_method_update_parameters = new \Xendit \PaymentMethod \PaymentMethodUpdateParameters (); // \Xendit\PaymentMethod\PaymentMethodUpdateParameters
try {
$ result = $ apiInstance ->patchPaymentMethod ($ payment_method_id , $ for_user_id , $ payment_method_update_parameters );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->patchPaymentMethod: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
getAllPaymentMethods()
Function
getAllPaymentMethods ($ for_user_id , $ id , $ type , $ status , $ reusability , $ customer_id , $ reference_id , $ after_id , $ before_id , $ limit ): \PaymentMethod \PaymentMethodList
Get all payment methods by filters
Get all payment methods by filters
Request Parameters - GetAllPaymentMethodsRequestParams
Name
Type
Required
Default
for_user_id
string
id
string[]
type
string[]
status
PaymentMethodStatus
reusability
PaymentMethodReusability
customer_id
string
reference_id
string
after_id
string
before_id
string
limit
int
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ id = array ('id_example ' ); // string[]
$ type = array ('type_example ' ); // string[]
$ status = array (new \Xendit \PaymentMethod \PaymentMethodStatus ()); // \PaymentMethod\PaymentMethodStatus[]
$ reusability = new \Xendit \PaymentMethod \PaymentMethodReusability (); // PaymentMethodReusability
$ customer_id = "'customer_id_example' " ; // string
$ reference_id = "'reference_id_example' " ; // string
$ after_id = "'after_id_example' " ; // string
$ before_id = "'before_id_example' " ; // string
$ limit = 56 ; // int
try {
$ result = $ apiInstance ->getAllPaymentMethods ($ for_user_id , $ id , $ type , $ status , $ reusability , $ customer_id , $ reference_id , $ after_id , $ before_id , $ limit );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->getAllPaymentMethods: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
expirePaymentMethod()
Function
expirePaymentMethod ($ payment_method_id , $ for_user_id , $ payment_method_expire_parameters ): \PaymentMethod \PaymentMethod
Expires a payment method
This endpoint expires a payment method and performs unlinking if necessary
Request Parameters - ExpirePaymentMethodRequestParams
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ payment_method_id = "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822 " ; // string
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ payment_method_expire_parameters = new \Xendit \PaymentMethod \PaymentMethodExpireParameters (); // \Xendit\PaymentMethod\PaymentMethodExpireParameters
try {
$ result = $ apiInstance ->expirePaymentMethod ($ payment_method_id , $ for_user_id , $ payment_method_expire_parameters );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->expirePaymentMethod: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
authPaymentMethod()
Function
authPaymentMethod ($ payment_method_id , $ for_user_id , $ payment_method_auth_parameters ): \PaymentMethod \PaymentMethod
Validate a payment method's linking OTP
This endpoint validates a payment method linking OTP
Request Parameters - AuthPaymentMethodRequestParams
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ payment_method_id = "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822 " ; // string
$ for_user_id = "5f9a3fbd571a1c4068aa40cf " ; // string
$ payment_method_auth_parameters = new \Xendit \PaymentMethod \PaymentMethodAuthParameters (); // \Xendit\PaymentMethod\PaymentMethodAuthParameters
try {
$ result = $ apiInstance ->authPaymentMethod ($ payment_method_id , $ for_user_id , $ payment_method_auth_parameters );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->authPaymentMethod: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
simulatePayment()
Function
simulatePayment ($ payment_method_id , $ simulate_payment_request )
Makes payment with matching PaymentMethodID.
Makes payment with matching PaymentMethodID.
Request Parameters - SimulatePaymentRequestParams
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \PaymentMethod \PaymentMethodApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new PaymentMethodApi ();
$ payment_method_id = "pm-1fdaf346-dd2e-4b6c-b938-124c7167a822 " ; // string
$ simulate_payment_request = new \Xendit \PaymentMethod \SimulatePaymentRequest (); // \Xendit\PaymentMethod\SimulatePaymentRequest
try {
$ apiInstance ->simulatePayment ($ payment_method_id , $ simulate_payment_request );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling PaymentMethodApi->simulatePayment: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
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
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \PaymentMethod \PaymentMethodCallback ;
$ payment_method_callback = new PaymentMethodCallback ([
'event ' => 'payment_method.activated ' ,
'data ' => [
'id ' => 'pm-6ff0b6f2-f5de-457f-b08f-bc98fbae485a ' ,
'card ' => null ,
'type ' => 'DIRECT_DEBIT ' ,
'status ' => 'ACTIVE ' ,
'country ' => 'PH ' ,
'created ' => '2022-08-12T13=>30=>26.579048Z ' ,
'ewallet ' => null ,
'qr_code ' => null ,
'updated ' => '2022-08-12T13=>30=>58.908220358Z ' ,
'metadata ' => null ,
'customer_id ' => 'e2878b4c-d57e-4a2c-922d-c0313c2800a3 ' ,
'description ' => null ,
'reusability ' => 'MULTIPLE_USE ' ,
'direct_debit ' => [
'type ' => 'BANK_ACCOUNT ' ,
'debit_card ' => null ,
'bank_account ' => [
'bank_account_hash ' => 'b4dfa99c9b60c77f2e3962b73c098945 ' ,
'masked_bank_account_number ' => 'XXXXXX1234 '
],
'channel_code ' => 'BPI ' ,
'channel_properties ' => [
'failure_return_url ' => 'https://your-redirect-website.com/failure ' ,
'success_return_url ' => 'https://your-redirect-website.com/success '
]
],
'failure_code ' => null ,
'reference_id ' => '620b9df4-fe69-4bfd-b9d4-5cba6861db8a ' ,
'virtual_account ' => null ,
'over_the_counter ' => null ,
'billing_information ' => null ,
'direct_bank_transfer ' => null
],
'created ' => '2022-08-12T13=>30=>59.074277334Z ' ,
'business_id ' => '5f27a14a9bf05c73dd040bc8 '
]);
You may then use the callback object in your webhook or callback handler like so,
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
function simulatePaymentMethodCallback (PaymentMethodCallback $ payment_method_callback ) {
echo $ payment_method_callback ->getId ();
// do things here with the callback
}
[Back to README]