JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr# 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 '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 '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 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 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 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 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 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 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 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](PaymentMethod/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 '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 getId(); // do things here with the callback } ``` [[Back to README]](../README.md)