[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: PaymentMethodApi.md
# PaymentMethodApi 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 <?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. | Method | HTTP request | Description | | ------------- | ------------- | ------------- | | [**createPaymentMethod()**](PaymentMethodApi.md#createpaymentmethod-function) | **POST** /v2/payment_methods | Creates payment method | | [**getPaymentMethodByID()**](PaymentMethodApi.md#getpaymentmethodbyid-function) | **GET** /v2/payment_methods/{paymentMethodId} | Get payment method by ID | | [**getPaymentsByPaymentMethodId()**](PaymentMethodApi.md#getpaymentsbypaymentmethodid-function) | **GET** /v2/payment_methods/{paymentMethodId}/payments | Returns payments with matching PaymentMethodID. | | [**patchPaymentMethod()**](PaymentMethodApi.md#patchpaymentmethod-function) | **PATCH** /v2/payment_methods/{paymentMethodId} | Patch payment methods | | [**getAllPaymentMethods()**](PaymentMethodApi.md#getallpaymentmethods-function) | **GET** /v2/payment_methods | Get all payment methods by filters | | [**expirePaymentMethod()**](PaymentMethodApi.md#expirepaymentmethod-function) | **POST** /v2/payment_methods/{paymentMethodId}/expire | Expires a payment method | | [**authPaymentMethod()**](PaymentMethodApi.md#authpaymentmethod-function) | **POST** /v2/payment_methods/{paymentMethodId}/auth | Validate a payment method's linking OTP | | [**simulatePayment()**](PaymentMethodApi.md#simulatepayment-function) | **POST** /v2/payment_methods/{paymentMethodId}/payments/simulate | Makes payment with matching PaymentMethodID. | ## `createPaymentMethod()` Function ```php createPaymentMethod($for_user_id, $payment_method_parameters): \PaymentMethod\PaymentMethod ``` Creates payment method This endpoint initiates creation of payment method | Name | Value | |--------------------|:-------------:| | Function Name | `createPaymentMethod` | | Request Parameters | [CreatePaymentMethodRequestParams](#request-parameters--CreatePaymentMethodRequestParams) | | Return Type | [**\Xendit\PaymentMethod\PaymentMethod**](PaymentMethod/PaymentMethod.md) | ### Request Parameters - CreatePaymentMethodRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **for_user_id** | **string** | | | | **payment_method_parameters** | [**PaymentMethodParameters**](PaymentMethod/PaymentMethodParameters.md) | | | ### Usage Example #### Account linking for E-Wallet ```php <?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 <?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' => 'testemail@email.com', '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 ```php getPaymentMethodByID($payment_method_id, $for_user_id): \PaymentMethod\PaymentMethod ``` Get payment method by ID Get payment method by ID | Name | Value | |--------------------|:-------------:| | Function Name | `getPaymentMethodByID` | | Request Parameters | [GetPaymentMethodByIDRequestParams](#request-parameters--GetPaymentMethodByIDRequestParams) | | Return Type | [**\Xendit\PaymentMethod\PaymentMethod**](PaymentMethod/PaymentMethod.md) | ### Request Parameters - GetPaymentMethodByIDRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **payment_method_id** | **string** | ☑️ | | | **for_user_id** | **string** | | | ### Usage Example ```php <?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 ```php 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. | Name | Value | |--------------------|:-------------:| | Function Name | `getPaymentsByPaymentMethodId` | | Request Parameters | [GetPaymentsByPaymentMethodIdRequestParams](#request-parameters--GetPaymentsByPaymentMethodIdRequestParams) | | Return Type | **object** | ### 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**](PaymentMethod/PaymentMethodType.md) | | | | **channel_code** | **string[]** | | | | **status** | **string[]** | | | | **currency** | **string[]** | | | | **created_gte** | **\DateTime** | | | | **created_lte** | **\DateTime** | | | | **updated_gte** | **\DateTime** | | | | **updated_lte** | **\DateTime** | | | | **limit** | **int** | | | ### Usage Example ```php <?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 ```php 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. | Name | Value | |--------------------|:-------------:| | Function Name | `patchPaymentMethod` | | Request Parameters | [PatchPaymentMethodRequestParams](#request-parameters--PatchPaymentMethodRequestParams) | | Return Type | [**\Xendit\PaymentMethod\PaymentMethod**](PaymentMethod/PaymentMethod.md) | ### Request Parameters - PatchPaymentMethodRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **payment_method_id** | **string** | ☑️ | | | **for_user_id** | **string** | | | | **payment_method_update_parameters** | [**PaymentMethodUpdateParameters**](PaymentMethod/PaymentMethodUpdateParameters.md) | | | ### Usage Example ```php <?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 ```php 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 | Name | Value | |--------------------|:-------------:| | Function Name | `getAllPaymentMethods` | | Request Parameters | [GetAllPaymentMethodsRequestParams](#request-parameters--GetAllPaymentMethodsRequestParams) | | Return Type | [**\Xendit\PaymentMethod\PaymentMethodList**](PaymentMethod/PaymentMethodList.md) | ### Request Parameters - GetAllPaymentMethodsRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **for_user_id** | **string** | | | | **id** | **string[]** | | | | **type** | **string[]** | | | | **status** | [**PaymentMethodStatus**](PaymentMethod/PaymentMethodStatus.md) | | | | **reusability** | [**PaymentMethodReusability**](PaymentMethod/PaymentMethodReusability.md) | | | | **customer_id** | **string** | | | | **reference_id** | **string** | | | | **after_id** | **string** | | | | **before_id** | **string** | | | | **limit** | **int** | | | ### Usage Example ```php <?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 ```php 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 | Name | Value | |--------------------|:-------------:| | Function Name | `expirePaymentMethod` | | Request Parameters | [ExpirePaymentMethodRequestParams](#request-parameters--ExpirePaymentMethodRequestParams) | | Return Type | [**\Xendit\PaymentMethod\PaymentMethod**](PaymentMethod/PaymentMethod.md) | ### Request Parameters - ExpirePaymentMethodRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **payment_method_id** | **string** | ☑️ | | | **for_user_id** | **string** | | | | **payment_method_expire_parameters** | [**PaymentMethodExpireParameters**](PaymentMethod/PaymentMethodExpireParameters.md) | | | ### Usage Example ```php <?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 ```php 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 | Name | Value | |--------------------|:-------------:| | Function Name | `authPaymentMethod` | | Request Parameters | [AuthPaymentMethodRequestParams](#request-parameters--AuthPaymentMethodRequestParams) | | Return Type | [**\Xendit\PaymentMethod\PaymentMethod**](PaymentMethod/PaymentMethod.md) | ### Request Parameters - AuthPaymentMethodRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **payment_method_id** | **string** | ☑️ | | | **for_user_id** | **string** | | | | **payment_method_auth_parameters** | [**PaymentMethodAuthParameters**](PaymentMethod/PaymentMethodAuthParameters.md) | | | ### Usage Example ```php <?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 ```php simulatePayment($payment_method_id, $simulate_payment_request) ``` Makes payment with matching PaymentMethodID. Makes payment with matching PaymentMethodID. | Name | Value | |--------------------|:-------------:| | Function Name | `simulatePayment` | | Request Parameters | [SimulatePaymentRequestParams](#request-parameters--SimulatePaymentRequestParams) | | Return Type | void (empty response body) | ### Request Parameters - SimulatePaymentRequestParams |Name | Type | Required |Default | |-------------|:-------------:|:-------------:|-------------| | **payment_method_id** | **string** | ☑️ | | | **simulate_payment_request** | [**SimulatePaymentRequest**](PaymentMethod/SimulatePaymentRequest.md) | | | ### Usage Example ```php <?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; } ``` ## Callback Objects 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](/PaymentMethodCallback.md) #### Usage Example 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 <?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 <?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]](../README.md)
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285