Payment method endpoints

GET List payment methods

https://submarine.discolabs.com/api/v1/customers/{{ customer_id }}/payment_methods.json

Fetch a list of the current customer's active payment methods.

ParameterNameRequiredTypeDescription
Pathcustomer_idYesintegerID of the currently logged in customer.

Response:

{
  "data": [
    {
      "id": "75199384",
      "type": "customer_payment_method",
      "attributes": {
        "status": "active",
        "payment_data": {
          "brand": "Visa",
          "last4": "4242",
          "exp_year": 2022,
          "exp_month": 1,
          "processor": "stripe"
        },
        "payment_method_type": "credit-card",
        "authorized_payment_method_id": 825022
      }
    },
    {
      "id": "75199212",
      "type": "customer_payment_method",
      "attributes": {
        "status": "active",
        "payment_data": {
          "email": "[email protected]",
          "processor": "braintree"
        },
        "payment_method_type": "paypal",
        "authorized_payment_method_id": 221099
      }
    }
  ]
}

Successfully retrieved a list of payment methods.

POST Create new payment method

https://submarine.discolabs.com/api/v1/customers/{{ customer_id }}/payment_methods.json

Create a new payment method for the current customer. Body parameters should be passed as a JSON object wrapped in a payment_method namespace.

ParameterNameRequiredTypeDescription
Pathcustomer_idYesintegerID of the currently logged in customer.
Bodypayment_tokenYesstringA payment token retrieved from a payment processor's JS SDK.
Bodypayment_method_typeYesstringThe type of payment method. One of credit-card, paypal or sepa.
Bodypayment_processorYesstringThe payment processor. Either stripe or braintree.
BodystatusYesstringStatus of the new method. Should be active.

Response:

{  
  "data": {  
    "id": "5208432",
    "type": "customer_payment_method",
    "attributes": {  
      "status": "active",
      "payment_data": {
        "brand": "Visa",
        "last4": "4242",
        "exp_month": 1,
        "exp_year": 2022,
        "processor": "stripe"
      },
      "payment_method_type": "credit-card",
      "authorized_payment_method_id": 9012424
    }
  }
}

DELETE Remove existing payment method

https://submarine.discolabs.com/api/v1/customers/{{ customer_id }}/payment_methods/{{ id }}.json

Remove (disable) an existing payment method belonging to the current customer.

ParameterNameRequiredTypeDescription
Pathcustomer_idYesintegerID of the currently logged in customer.
PathidYesintegerID of the currently logged in customer.

Response:

{  
  "data": {  
    "id": "5208432",
    "type": "customer_payment_method",
    "attributes": {  
      "status": "disabled",
      "payment_data": {  
        "brand": "Visa",
        "last4": "1111",
        "exp_year": 2020,
        "exp_month": 1,
        "processor": "stripe"
      },
      "payment_method_type": "credit-card",
      "authorized_payment_method_id": 9012424
    }
  }
}