Retrieve Payment Data

You may need to retrieve a customer's cards on file, for example if you need to change their default payment card.

In order to do this, you will need to query the customer endpoint, which will retrieve the customer's information, including their cards. For this guide, we will focus on the card information.

Let's say that you have created a customer, using the Create Customer guide, and then attached two cards. We have the customer_id MKNDnpVNAnVA4jxP.

We willGEThttps://api.payarc.net/v1/customers/{customer_id}, and we won't need to pass any parameters other than the headers.

import http.client

conn = http.client.HTTPSConnection("https")
payload = ''
headers = {
  'Authorization': '{{bearer_token}}',
  'Accept': 'application/json'
}
conn.request("GET", "//api.payarc.net/api/v1/customers/{{customer_id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'https',
  'path': '//api.payarc.net/api/v1/customers/{{customer_id}}',
  'headers': {
    'Authorization': '{{bearer_token}}',
    'Accept': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.payarc.net/api/v1/customers/{{customer_id}}");
request.Headers.Add("Authorization", "{{bearer_token}}");
request.Headers.Add("Accept", "application/json");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

You will receive a customer object for our customer_id MKNDnpVNAnVA4jxP, which in our case will include two cards. Please see the table under the response for a description of every element.

{
    "data": {
        "object": "customer",
        "id": "MKNDnpVNAnVA4jxP",
        "name": "John Smith",
        "real_id": 95,
        "email": "[email protected]",
        "description": "John Smith is our test customer",
        "payment_overdue": 0,
        "send_email_address": "[email protected]",
        "cc_email_address": "[email protected]",
        "source_id": "2NLy9v0922L0m1MP",
        "address_1": "103 Mason Street",
        "address_2": "2nd Floor",
        "city": "New York",
        "state": "NY",
        "zip": "10469",
        "phone": "541754301",
        "country": "US",
        "created_at": "2023-10-29 07:04:57",
        "updated_at": "2023-11-29 09:40:43",
        "readable_created_at": "1 month ago",
        "readable_updated_at": "33 minutes ago",
        "invoice_prefix": "ADML",
        "card": {
            "data": [
                {
                    "object": "Card",
                    "id": "P19v20v519L10M5y",
                    "address_1": "103 Mason Street",
                    "address_2": "2nd Floor",
                    "card_holder_name": "John Smith",
                    "is_default": 1,
                    "exp_month": "12",
                    "exp_year": "2025",
                    "is_verified": 0,
                    "fingerprint": "my905PmvmPNmNP0M",
                    "city": "New York",
                    "state": "NY",
                    "zip": "10469",
                    "phone": "541754301",
                    "brand": "V",
                    "last4digit": "5439",
                    "first6digit": 401200,
                    "country": "US",
                    "avs_status": null,
                    "cvc_status": null,
                    "address_check_passed": 0,
                    "zip_check_passed": 0,
                    "customer_id": "MKNDnpVNAnVA4jxP",
                    "created_at": 1713630147,
                    "updated_at": 1713939112
                },
                {
                    "object": "Card",
                    "id": "P19v20v519L10M5y",
                    "address_1": "103 Mason Street",
                    "address_2": "2nd Floor",
                    "card_holder_name": "Laura Smith",
                    "is_default": 0,
                    "exp_month": "11",
                    "exp_year": "2024",
                    "is_verified": 0,
                    "fingerprint": "P10MvNy9P2yNm20m",
                    "city": "New York",
                    "state": "NY",
                    "zip": "10469",
                    "phone": "541754301",
                    "brand": "V",
                    "last4digit": "5228",
                    "first6digit": 408540,
                    "country": "US",
                    "avs_status": null,
                    "cvc_status": null,
                    "address_check_passed": 0,
                    "zip_check_passed": 0,
                    "customer_id": "MKNDnpVNAnVA4jxP",
                    "created_at": 1701819477,
                    "updated_at": 1704065877
                }
            ]
        },
        "charge": {
            "data": []
        }
    },
    "meta": {
        "include": [
            "card",
            "charge",
            "subscription",
            "invoice"
        ],
        "custom": []
    }
}

Explanation of response parameters

ParameterDescription
address_1
Optional
The customer's address for line 1.
Format: Alphanumeric, Min Length: 5, Max Length: 50
Example: 103 Mason Street
address_2
Optional
The customer's address for line 2.
Format: Alphanumeric, Min Length: 5, Max Length: 50
Example: 2nd Floor
card_holder_name
Optional
Name of the customer.
Format: Alphabetic and Whitespace, Min Length: 3, Max Length: 50
Example: John Smith
is_default
Optional
Flag showing if this is the default payment method for the customer. 0 stands for no, and 1 for yes.
Format: Integer, Allowable Values: 0, 1
Example: 0
exp_month
Optional
Card expiration month
Format: Numeric, Length: 2
Example: 12
exp_year
Optional
Card expiration year
Format: Numeric, Length: 4
Example: 2027
is_verified
Optional
TO BE ADDED AFTER DISCUSSION
fingerprint
Optional
TO BE ADDED AFTER DISCUSSION move this offline and ask why the developer should care about it.
city
Optional
The customer's city. Can be a City/District/Suburb/Town/Village.
Format: Alphabetic and Whitespace, Length: 2-50
Example: New York
state
Optional
The customer's state. Can be State/County/Province/Region.
Format: Alphabetic and Whitespace, Length: 2-50
Example: NY
zip
Optional
The customer's ZIP code.
Format: Numeric and Hyphen, Max Length: 10
Example: 10469, 10469-2345
phone
Optional
The customer's phone number.
Format: Numeric, Length: 2-11
Example: 541754301
brandCard brand
ALLOWABLE VALUES TO BE ADDED AFTER DISCUSSION
last4digitThe last 4 digits of the customer's card number.
Format: Numeric, Length: 4
Example: 5238
first6digitThe first 6 digits of the customer's card number.
Format: Numeric, Length: 4
Example: 405238
country
Optional
Customer's country.
Format: Alphabetic, Length: 2-50
Example: US
avs_status
Optional
TO BE ADDED AFTER DISCUSSION -> email
cvc_status
Optional
TO BE ADDED AFTER DISCUSSION
address_check_passed
Optional
TO BE ADDED AFTER DISCUSSION
zip_check_passed
Optional
TO BE ADDED AFTER DISCUSSION
customer_id
Optional
Customer's ID in the payarc system.
Format: Alphabetic, Length: 2-50
Example: MKNDnpVNAnVA4jxP
created_at
Optional
Creation timestamp in UNIX timestamp format: seconds since Jan 01 1970. (UTC).
Example: 1715639493
updated_at
Optional
Last update timestamp in UNIX timestamp format: seconds since Jan 01 1970. (UTC).
Example: 1715639493