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 willGET
https://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 {{Access-Token-From-Payarc-Dashboard}}',
'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
Parameter | Description |
---|---|
address_1 Optional | The customer's address for line 1.
|
address_2 | The customer's address for line 2. |
card_holder_name | Name of the customer.
|
is_default | Flag showing if this is the default payment method for the customer.
|
exp_month | Card expiration month
|
exp_year | Card expiration year
|
is_verified | TO BE ADDED AFTER DISCUSSION |
fingerprint |
|
city | The customer's city. Can be a City/District/Suburb/Town/Village.
|
state | The customer's state. Can be State/County/Province/Region.
|
zip | The customer's ZIP code.
|
phone | The customer's phone number.
|
brand | Card brand |
last4digit | The last 4 digits of the customer's card number.
|
first6digit | The first 6 digits of the customer's card number.
|
country | Customer's country.
|
avs_status |
|
cvc_status | TO BE ADDED AFTER DISCUSSION |
address_check_passed | TO BE ADDED AFTER DISCUSSION |
zip_check_passed | TO BE ADDED AFTER DISCUSSION |
customer_id | Customer's ID in the payarc system.
|
created_at | Creation timestamp in UNIX timestamp format: seconds since Jan 01 1970. (UTC).
|
updated_at | Last update timestamp in UNIX timestamp format: seconds since Jan 01 1970. (UTC).
|
Updated 10 days ago