Payment Methods

PaymentMethod objects represent your customer's payment instruments. You can use them with ChargeIntents to collect payments or save them to Customer objects to store instrument details for future payments.

The PaymentMethod object

Attributes
idstring

Unique identifier for the object.

customernullable string

The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer.

billingdictionary

Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.

typeenum

The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type.

livemodeboolean

Has the value true if the object exists in live mode or the value false if the object exists in test mode.

createdtimestamp

Time at which the object was created. Measured in seconds since the Unix epoch.

updatedtimestamp

Time at which the object was last updated. Measured in seconds since the Unix epoch.

objectstring

String representing the object's type. Objects of the same type share the same value.

cardnullable dictionary

If this is a card PaymentMethod, this hash contains the user's card details.

THE PAYMENTMETHOD OBJECT
{
  "id": "d0a736d3-0dba-4eda-99f6-dfe27849f282",
  "customer": null,
  "billing": null,
  "type": "card",
  "object": "payment_method",
  "created": 1712034831,
  "updated": 1712034831,
  "livemode": false,
  "card": {
    "brand": "visa",
    "exp_month": "12",
    "exp_year": "29",
    "issuer": null,
    "currency": null,
    "segment": null,
    "type": null,
    "last_four": "4242"
  }
}

Create a PaymentMethod

Creates a PaymentMethod object. Instead of creating a PaymentMethod directly, we recommend using the ChargeIntents API to accept a payment immediately.

Parameters
typeREQUIREDenum

The type of the PaymentMethod. We only accept card at the moment.

customerstring

The ID of the Customer to which this PaymentMethod is saved.

card_numberREQUIREDstring

The card number, as a string without any separators.

exp_monthREQUIREDstring

Two-digit number representing the card's expiration month.

exp_yearREQUIREDstring

The last two-digit number representing the card's expiration year.

cvcREQUIREDstring

The card's CVC. It is highly recommended to always include this value.

billingdictionary

Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.

citynullable string

City, district, suburb, town, or village.

countrynullable string

Two-letter country code (ISO 3166-1 alpha-2).

statenullable string

State, county, province, or region.

postal_codenullable string

ZIP or postal code.

line_1nullable string

Address line 1 (e.g., street, PO Box, or company name).

line_2nullable string

Address line 2 (e.g., apartment, suite, unit, or building).

Returns

Returns a PaymentMethod object.

POST/v1/payment_methods
curl --request POST \
  --url https://api.framepayments.com/v1/payment_methods \
  --header 'Authorization: Bearer API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "type": "card",
  "card_number": "4242424242424242",
  "exp_month": "12",
  "exp_year": "26",
  "cvc": "314"
}'
RESPONSE
{
  "id": "363aac3c-d651-407c-a52d-4292f20b56dc",
  "customer": null,
  "billing": null,
  "type": "card",
  "object": "payment_method",
  "created": 1721188469,
  "updated": 1721188469,
  "livemode": false,
  "card": {
    "brand": "visa",
    "exp_month": "12",
    "exp_year": "26",
    "issuer": null,
    "currency": null,
    "segment": null,
    "type": null,
    "last_four": "4242"
  }
}

Update a PaymentMethod

Updates a PaymentMethod object. A PaymentMethod must be attached to a customer before it can be updated.

Parameters
exp_monthinteger

Two-digit number representing the card's expiration month.

exp_yearinteger

The last two-digit number representing the card's expiration year.

billingdictionary

Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.

citynullable string

City, district, suburb, town, or village.

countrynullable string

Two-letter country code (ISO 3166-1 alpha-2).

statenullable string

State, county, province, or region.

postal_codenullable string

ZIP or postal code.

line_1nullable string

Address line 1 (e.g., street, PO Box, or company name).

line_2nullable string

Address line 2 (e.g., apartment, suite, unit, or building).

Returns

Returns a PaymentMethod object.

PATCH/v1/payment_methods/:id
curl --request PATCH \
  --url https://api.framepayments.com/v1/payment_methods/b4975329-8c9e-44b5-b9d2-155ffa9aaf56 \
  --header 'Authorization: Bearer API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "exp_year": 27
}'
RESPONSE
{
  "id": "b4975329-8c9e-44b5-b9d2-155ffa9aaf56",
  "customer": "fe0a0118-feb0-4aff-97b7-9248b7d57ebd",
  "billing": {...},
  "type": "card",
  "object": "payment_method",
  "created": 1721730874,
  "updated": 1721922879,
  "livemode": false,
  "card": {
    "brand": "amex",
    "exp_month": "12",
    "exp_year": "27",
    "issuer": null,
    "currency": null,
    "segment": null,
    "type": null,
    "last_four": "10005"
  }
}

Retrieve a PaymentMethod

Retrieves a PaymentMethod object attached to the FrameAccount. To retrieve a payment method attached to a Customer, you should use Retrieve a Customer's PaymentMethods

Parameters

No parameters.

Returns

Returns a PaymentMethod object.

GET/v1/payment_methods/:id
curl --request GET \
  --url https://api.framepayments.com/v1/payment_methods/d0a736d3-0dba-4eda-99f6-dfe27849f282 \
  --header 'Authorization: Bearer API_KEY'
RESPONSE
{
  "id": "d0a736d3-0dba-4eda-99f6-dfe27849f282",
  "customer": null,
  "billing": null,
  "type": "card",
  "object": "payment_method",
  "created": 1712034831,
  "updated": 1712034831,
  "livemode": false,
  "card": {
    "brand": "visa",
    "exp_month": "12",
    "exp_year": "29",
    "issuer": null,
    "currency": null,
    "segment": null,
    "type": null,
    "last_four": "4242"
  }
}

List a Customer's PaymentMethods

Returns a list of PaymentMethods for a given Customer

Parameters
per_pageinteger

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50.

pageinteger

The page offset at which you'd like to resume fetching data.

Returns

A dictionary with a data property that contains an array of up to limit PaymentMethods of type type. Each entry in the array is a separate PaymentMethod object. If no more PaymentMethods are available, the resulting array will be empty.

GET/v1/customers/:id/payment_methods
curl --request GET \
  --url https://api.framepayments.com/v1/customers/4a8f3d27-08f0-4f87-82b8-c225c7d74cb7/payment_methods \
  --header 'Authorization: Bearer API_KEY'
RESPONSE
{
  "meta": {
    "page": 1,
    "url": "/v1/customers/4a8f3d27-08f0-4f87-82b8-c225c7d74cb7/payment_methods",
    "has_more": false,
    "prev": null,
    "next": null
  },
  "data": [
    {
      "id": "d0a736d3-0dba-4eda-99f6-dfe27849f282",
      "customer": "4a8f3d27-08f0-4f87-82b8-c225c7d74cb7",
      "billing": null,
      "type": "card",
      "object": "payment_method",
      "created": 1712034831,
      "updated": 1713624942,
      "livemode": false,
      "card": {
        "brand": "visa",
        "exp_month": "12",
        "exp_year": "29",
        "issuer": null,
        "currency": null,
        "segment": null,
        "type": null,
        "last_four": "4242"
      }
    },
    {...},
    {...}
  ]
}

List PaymentMethods

Returns a list of PaymentMethods for Treasury flows. If you want to list the PaymentMethods attached to a Customer for payments, you should use the List a Customer's PaymentMethods API instead.

Parameters
per_pageinteger

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50.

pageinteger

The page offset at which you'd like to resume fetching data.

Returns

A dictionary with a data property that contains an array of up to limit PaymentMethods of type type. Each entry in the array is a separate PaymentMethod object. If no more PaymentMethods are available, the resulting array will be empty.

GET/v1/payment_methods
curl --request GET \
  --url https://api.framepayments.com/v1/payment_methods \
  --header 'Authorization: Bearer API_KEY'
RESPONSE
{
  "meta": {
    "page": 1,
    "url": "/v1/payment_methods",
    "has_more": false,
    "prev": null,
    "next": null
  },
  "data": [
    {
      "id": "d0a736d3-0dba-4eda-99f6-dfe27849f282",
      "customer": null,
      "billing": null,
      "type": "card",
      "object": "payment_method",
      "created": 1712034831,
      "updated": 1712034831,
      "livemode": false,
      "card": {
        "brand": "visa",
        "exp_month": "12",
        "exp_year": "29",
        "issuer": null,
        "currency": null,
        "segment": null,
        "type": null,
        "last_four": "4242"
      }
    },
    {...},
    {...}
  ]
}

Attach a PaymentMethod to a Customer

Attaches a PaymentMethod object to a Customer.

Parameters
customerREQUIREDstring

The ID of the customer to which to attach the PaymentMethod.

Returns

Returns a PaymentMethod object.

POST/v1/payment_methods/:id/attach
curl --request POST \
  --url https://api.framepayments.com/v1/payment_methods/d0a736d3-0dba-4eda-99f6-dfe27849f282/attach \
  --header 'Authorization: Bearer API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "customer": "4a8f3d27-08f0-4f87-82b8-c225c7d74cb7"
}'
RESPONSE
{
  "id": "d0a736d3-0dba-4eda-99f6-dfe27849f282",
  "customer": "4a8f3d27-08f0-4f87-82b8-c225c7d74cb7",
  "billing": null,
  "type": "card",
  "object": "payment_method",
  "created": 1712034831,
  "updated": 1713624500,
  "livemode": false,
  "card": {
    "brand": "visa",
    "exp_month": "12",
    "exp_year": "29",
    "issuer": null,
    "currency": null,
    "segment": null,
    "type": null,
    "last_four": "4242"
  }
}

Detach a PaymentMethod from a Customer

Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer.

Parameters

No parameters.

Returns

Returns a PaymentMethod object.

POST/v1/payment_methods/:id/detach
curl --request POST \
  --url https://api.framepayments.com/v1/payment_methods/d0a736d3-0dba-4eda-99f6-dfe27849f282/detach \
  --header 'Authorization: Bearer API_KEY'
RESPONSE
{
  "id": "d0a736d3-0dba-4eda-99f6-dfe27849f282",
  "customer": null,
  "billing": null,
  "type": "card",
  "object": "payment_method",
  "created": 1712034831,
  "updated": 1713624621,
  "livemode": false,
  "card": {
    "brand": "visa",
    "exp_month": "12",
    "exp_year": "29",
    "issuer": null,
    "currency": null,
    "segment": null,
    "type": null,
    "last_four": "4242"
  }
}