NAV Navbar
cURL .NET Java Go PHP Python Ruby

Payment Sources

A payment source represents a specific payment instrument owned by a customer that can be used for payments. We currently support credit cards and bank accounts as payment sources.

Card Object

Attributes

{
    "brand": "Visa",
    "exp_month": 2,
    "exp_year": 20,
    "funding": "credit",
    "id": 850,
    "last4": "4242",
    "object": "card",
    "updated_at": 1607152637
}
Parameter Type Description
id integer The card's unique ID
object string Object type, card
brand string Card brand
last4 string Last 4 digits of card
exp_month integer Expiry month
exp_year integer Expiry year
funding string Funding instrument, can be credit, debit, prepaid, or unknown

Bank Account Object

Attributes

{
    "bank_name": "Wells Fargo",
    "currency": "usd",
    "id": 4321,
    "last4": "7890",
    "object": "bank_account",
    "routing_number": "110000000",
    "updated_at": 1607152637,
    "verified": true
}
Parameter Type Description
id integer The bank account's unique ID
object string Object type, bank_account
bank_name string Bank name
last4 string Last 4 digits of bank account
routing_number string Bank routing number
verified boolean Whether the bank account has been verified with instant verification or micro-deposits
currency string 3-letter ISO code

Create a payment source

curl "https://api.invoiced.com/customers/:id/payment_sources" \
  -u {API_KEY}: \
  -d method="credit_card" \
  -d invoiced_token="abcdefghijklmnopqrstuvwxyz"
customer = invoiced.Customer.retrieve("{CUSTOMER_ID}")
customer.payment_sources.create(
  :method => "credit_card",
  :invoiced_token="abcdefghijklmnopqrstuvwxyz"
)
<?php

$customer = $invoiced->Customer->retrieve("{CUSTOMER_ID}");
$customer->paymentSources()->create([
  'method' => "credit_card",
  'invoiced_token' => "abcdefghijklmnopqrstuvwxyz"
]);
customer = client.Customer.retrieve("{CUSTOMER_ID}")
customer.payment_sources().create(
  method="credit_card",
  invoiced_token="abcdefghijklmnopqrstuvwxyz"
)
Customer customer = invoiced.newCustomer().retrieve({CUSTOMER_ID});
SourceRequest sourceRequest = new SourceRequest();
sourceRequest.method = "credit_card";
sourceRequest.invoicedToken = "abcdefghijklmnopqrstuvwxyz";

PaymentSource paymentSource = customer.createPaymentSource(sourceRequest);
var customer = invoiced.NewCustomer().Retrieve({CUSTOMER_ID});
var sourceRequest = new SourceRequest();
sourceRequest.Method = "credit_card";
sourceRequest.InvoicedToken = "abcdefghijklmnopqrstuvwxyz";

var paymentSource = customer.CreatePaymentSource(sourceRequest);
source, err := client.Customer.CreatePaymentSource({CUSTOMER_ID}, &invoiced.PaymentSourceRequest{
  Method: invoiced.String("credit_card"),
  InvoicedToken: invoiced.String("abcdefghijklmnopqrstuvwxyz"),
})

The above command returns JSON structured like this:

{
    "brand": "Visa",
    "exp_month": 2,
    "exp_year": 20,
    "funding": "credit",
    "id": 850,
    "last4": "4242",
    "object": "card",
    "updated_at": 1607152637
}

Associate a payment method with a customer using this endpoint.

Either invoiced_token or gateway_token is required, but not both.

HTTP Request

POST /customers/:id/payment_sources

Attributes

Parameter Type Description
method string Payment method, i.e. credit_card, ach
make_default boolean When true, makes the payment source the default
invoiced_token string Optional, generated by invoiced.js
gateway_token string Optional, generated by payment test

List payment sources

curl "https://api.invoiced.com/customers/:customer_id/payment_sources" \
  -u {API_KEY}
customer = invoiced.Customer.retrieve("{CUSTOMER_ID}")
payment_sources, metadata = customer.payment_sources.list(:per_page => 3)
<?php

$customer = $invoiced->Customer->retrieve("{CUSTOMER_ID}");
list($payment_sources, $metadata) = $customer->paymentSources()->all(['per_page' => 3]);
customer = client.Customer.retrieve("{CUSTOMER_ID}")
payment_sources, metadata = customer.payment_sources().list(per_page=3)
Customer customer = invoiced.newCustomer().retrieve({CUSTOMER_ID});
EntityList<PaymentSource> paymentSources = customer.listPaymentSources();
var customer = invoiced.NewCustomer().Retrieve({CUSTOMER_ID});
var paymentSources = customer.ListPaymentSources();
sources, err := client.Customer.ListAllPaymentSources({CUSTOMER_ID})

The above command returns JSON structured like this:

[
  {
     "brand": "Visa",
     "exp_month": 2,
     "exp_year": 20,
     "funding": "credit",
     "id": 850,
     "last4": "4242",
     "object": "card",
     "updated_at": 1607152637
 }
]

Retrieve payment sources associated with a certain customer using this endpoint.

HTTP Request

GET /customers/:customer_id/payment_sources

Delete a payment source

curl "https://api.invoiced.com/customers/:customer_id/cards/:id" \
  -u {API_KEY}: \
  -X DELETE
payment_source.delete
<?php

$paymentSource->delete();
payment_source.delete()
paymentSource.delete();
paymentSource.Delete();
client.Customer.DeleteCard({CUSTOMER_ID}, {CARD_ID})
// or
client.Customer.DeleteBankAccount({CUSTOMER_ID}, {ACCOUNT_ID})

The above command returns 204 No Content

This endpoint deletes a specific payment source. The endpoint differs by type.

When used, this endpoint also deletes the payment source from the connected payment test.

HTTP Request

DELETE /customers/:customer_id/cards/:id or

DELETE /customers/:customer_id/bank_accounts/:id