Delete Payment Method
Delete a payment method from a customer profile.
This method triggers the Payment Method Canceled Webhook. This webhook contains more information than the response.
customer
ID of the
customer
. String starting with cus_.
payment_method
ID of the payment method to delete. String starting with card_ or other_.
deleted
Indicates whether the payment method was deleted.
id
ID of the payment method.
Code Samples
.NET
using System; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string customerId = "cus_217f61d6757465a9716666ccf4d3ec73"; string paymentMethod = "other_5d3555aa69ffd545ef56c5212cf0d3d1"; string result = RapydApiRequestSample.Utilities.MakeRequest("DELETE", $"/v1/customers/{customerId}/payment_methods/{paymentMethod}"); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const result = await makeRequest( 'DELETE', '/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/payment_methods/other_5d3555aa69ffd545ef56c5212cf0d3d1' ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); try { $object = make_request('delete', "/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/other_5d3555aa69ffd545ef56c5212cf0d3d1"); var_dump($object); } catch (Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request result = make_request(method='delete', path='/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/payment_methods/other_5d3555aa69ffd545ef56c5212cf0d3d1') pprint(result)
/v1/customers/:customer/payment_methods/:payment_method
Cash
curl -X delete https://sandboxapi.rapyd.net/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/payment_methods/other_5d3555aa69ffd545ef56c5212cf0d3d1 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "fcbf0539-159a-403a-8c78-796632d4fc81" }, "data": { "deleted": true, "id": "other_5d3555aa69ffd545ef56c5212cf0d3d1" } }
Bank transfer
curl -X delete https://sandboxapi.rapyd.net/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/payment_methods/other_35efe3a28d4900c435f9488f99970fe8 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "b3cfd8e5-a3cc-4fab-8ff1-d4669f089938" }, "data": { "deleted": true, "id": "other_3af575ae89918ad7381503edd549814d" } }
Bank redirect
curl -X delete https://sandboxapi.rapyd.net/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/payment_methods/other_a6b1661d8c620a8160797f30a8dfe4cb -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "acd5a19b-6629-4777-98a8-9bcfd9ed31d3" }, "data": { "deleted": true, "id": "other_a6b1661d8c620a8160797f30a8dfe4cb" } }
Card
curl -X delete https://sandboxapi.rapyd.net/v1/customers/cus_6881569f36924eb1c1c528f0d32418fd/payment_methods/card_dfb616c07f24fde89fbcf47e4f4335f1 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "c3cb259a-4ee5-43cd-9f6d-9c7a69fd4783" }, "data": { "deleted": true, "id": "card_dfb616c07f24fde89fbcf47e4f4335f1" } }