C# UWP/WinRT Stripe: Retrieve a Customer

Back to Index

Retrieves the details of an existing customer. You need only supply the unique customer identifier that was returned upon customer creation.

Documentation: https://stripe.com/docs/api/curl#retrieve_customer

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbgVLJqv487Oq \
   -u STRIPE_SECRET_KEY:

C# UWP/WinRT Example

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

//  URL: https://api.stripe.com/v1/customers/cus_CBbgVLJqv487Oq
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = await rest.ConnectAsync("api.stripe.com",port,bTls,bAutoReconnect);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.SetAuthBasic("STRIPE_SECRET_KEY","");

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = await rest.FullRequestNoBodySbAsync("GET","/v1/customers/cus_CBbgVLJqv487Oq",sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

Chilkat.JsonObject jsonResponse = new Chilkat.JsonObject();
jsonResponse.LoadSb(sbResponseBody);

string id;
string object;
int account_balance;
int created;
string currency;
bool default_source;
bool delinquent;
bool description;
bool discount;
bool email;
bool livemode;
bool shipping;
string sourcesObject;
bool sourcesHas_more;
int sourcesTotal_count;
string sourcesUrl;
string subscriptionsObject;
bool subscriptionsHas_more;
int subscriptionsTotal_count;
string subscriptionsUrl;
int i;
int count_i;

id = jsonResponse.StringOf("id");
object = jsonResponse.StringOf("object");
account_balance = jsonResponse.IntOf("account_balance");
created = jsonResponse.IntOf("created");
currency = jsonResponse.StringOf("currency");
default_source = jsonResponse.IsNullOf("default_source");
delinquent = jsonResponse.BoolOf("delinquent");
description = jsonResponse.IsNullOf("description");
discount = jsonResponse.IsNullOf("discount");
email = jsonResponse.IsNullOf("email");
livemode = jsonResponse.BoolOf("livemode");
shipping = jsonResponse.IsNullOf("shipping");
sourcesObject = jsonResponse.StringOf("sources.object");
sourcesHas_more = jsonResponse.BoolOf("sources.has_more");
sourcesTotal_count = jsonResponse.IntOf("sources.total_count");
sourcesUrl = jsonResponse.StringOf("sources.url");
subscriptionsObject = jsonResponse.StringOf("subscriptions.object");
subscriptionsHas_more = jsonResponse.BoolOf("subscriptions.has_more");
subscriptionsTotal_count = jsonResponse.IntOf("subscriptions.total_count");
subscriptionsUrl = jsonResponse.StringOf("subscriptions.url");
i = 0;
count_i = jsonResponse.SizeOfArray("sources.data");
while (i < count_i) {
    jsonResponse.I = i;
    i = i + 1;
}

i = 0;
count_i = jsonResponse.SizeOfArray("subscriptions.data");
while (i < count_i) {
    jsonResponse.I = i;
    i = i + 1;
}

Sample JSON Response Body

{
  "id": "cus_CBbgVLJqv487Oq",
  "object": "customer",
  "account_balance": 0,
  "created": 1516662781,
  "currency": "usd",
  "default_source": null,
  "delinquent": false,
  "description": null,
  "discount": null,
  "email": null,
  "livemode": false,
  "metadata": {},
  "shipping": null,
  "sources": {
    "object": "list",
    "data": [
    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_CBbgVLJqv487Oq/sources"
  },
  "subscriptions": {
    "object": "list",
    "data": [
    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_CBbgVLJqv487Oq/subscriptions"
  }
}