Delete a Payment Method

Use our API to delete a saved payment method from a Customer Vault profile.

Follow the instructions in this guide to delete a specific payment method that has been saved to a Customer Vault profile. Note that you cannot delete a payment method that has active subscriptions. See Delete a Payment Method in API Reference for field definitions.


Prerequisites

  1. See Create a Sandbox Account to sign up and log in to the Maast Manager portal.

  2. Follow the steps in Get Your API Credentials to save a sandbox ID and API key.

  3. See Authentication to format the credentials and generate your API token. (Alternatively, use the credentials as-is to test this endpoint with our 'Try It!' feature.)

  4. Follow the steps in the Add a Customer guide to add a customer profile to the Customer Vault. Save the customer_id.

  5. Add a payment method to the customer profile and save its card_id. You can do this through the Add a Customer request, or you can follow the steps in the Add a Payment Method guide.


Implement

  1. Write a PUT request. For the request endpoint, insert the customer_id value between customer/ and /billing/delete. The resulting endpoint is /platform/vault/customer/{customer_id}/billing/delete, where the value replaces {customer_id}.

  2. In the request body, add the card_id value of the payment method you wish to delete.

  3. If you are making this request on behalf of another merchant, add their merchant_id value to the request body.


Once configured, your code will resemble the sample code below:

curl --request PUT \
     --url https://api-test.maast.com/platform/vault/customer/JOHNDOE/billing/delete \
     --header 'accept: application/json' \
     --header 'authorization: Basic OjllZGVjMjFhMzFjMHh5ejc4OWUzMGEzNDE2YWJjMTIz' \
     --header 'content-type: application/json' \
     --data '
{
     "card_id": "86e1b00d9b0811e68df3069d8f743581",
     "merchant_id": 210000000289
}
'

Integrate

Send the configured PUT request to your customized endpoint.

Maast will return a response like the code below:

{
  "code": 0,
  "message": "Success",
  "data": {
    "customer_id": "JOHNDOE",
    "rec_id": 0,
    "node_id": 210000000289,
    "customer_first_name": "JOHN",
    "customer_last_name": "Doe",
    "customer_firm_name": "CompanyXYZ",
    "customer_phone": "999-999-9999",
    "customer_email": "[email protected]",
    "reference_id": "678909",
    "comments": "Test comment",
    "developer_id": "CompanyV2.0",
    "primary_card_number": "411111xxxxxx1111",
    "shipping_addresses": [
      {
        "shipping_id": 12345,
        "shipping_first_name": "John",
        "shipping_last_name": "John",
        "shipping_firm_name": "CompanyXYZ",
        "shipping_addr1": "123 Main Street",
        "shipping_addr2": "#1234",
        "shipping_city": "San Mateo",
        "shipping_state": "CA",
        "shipping_zip": "94402",
        "shipping_zip4": "1234",
        "shipping_country": "United States",
        "shipping_country_code": "840",
        "primary": true
      }
    ],
    "billing_cards": [
      {
        "card_number": "411111xxxxxx1111",
        "exp_date": "0420",
        "card_id": "86e1b00d9b0811e68df3069d8f743581",
        "billing_first_name": "John",
        "billing_last_name": "Doe",
        "billing_firm_name": "CompanyXYZ",
        "billing_email": [
          "[email protected]",
          "[email protected]"
        ],
        "billing_addr1": "123 Main Avenue",
        "billing_addr2": "#1234",
        "billing_city": "San Mateo",
        "billing_state": "CA",
        "billing_zip": "94402",
        "billing_zip4": "1234",
        "billing_country": "United States",
        "billing_country_code": "840",
        "primary": true,
        "card_type": "VS",
        "verified_date": "20160530000000"
      }
    ]
  }
}

Check the code field in the request response: 0 confirms that you have successfully deleted the payment method from the customer's profile in Customer Vault. If the value is something other than 0, check Platform API Response Codes in Reference.

The data field shows the customer's updated profile, including any saved payment methods that remain.

See Delete a Payment Method in API Reference for field definitions.


Test and Go Live

See our Test and Go Live guide to test your API integration and to start transacting with an active production account.