Store a customer's details in a customer object to reuse in future payments. When creating a customer, you can link payment instruments – the customer id returned can be passed as a source when making a payment.
NOTE: Specify a default instrument, otherwise the instruments array will not be saved on creation.
Customer created successfully
Unauthorized
Invalid data was sent
Internal Error
{- "email": "brucewayne@gmail.com",
- "name": "Bruce Wayne",
- "phone": {
- "country_code": "+1",
- "number": "415 555 2671"
}, - "metadata": {
- "coupon_code": "NY2018",
- "partner_id": 123989
}, - "default": "src_wmlfc3zyhqzehihu7giusaaawu"
}{- "id": "cus_y3oqhf46pyzuxjbcn2giaqnb44"
}Returns the details of a customer and their payment instruments.
required | string or string The customer's ID or email |
Customer retrieved successfully
Unauthorized
Customer not found
// For more information please refer to https://github.com/checkout/checkout-sdk-net using Checkout.Customers; //API keys ICheckoutApi api = CheckoutSdk.Builder().StaticKeys() .SecretKey("secret_key") .Environment(Environment.Sandbox) .EnvironmentSubdomain("{prefix}") // Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see https://www.checkout.com/docs/developer-resources/api/api-endpoints. .HttpClientFactory(new DefaultHttpClientFactory()) .Build(); //OAuth ICheckoutApi api = CheckoutSdk.Builder().OAuth() .ClientCredentials("client_id", "client_secret") .Scopes(OAuthScope.Vault) .Environment(Environment.Sandbox) .EnvironmentSubdomain("{prefix}") // Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see https://www.checkout.com/docs/developer-resources/api/api-endpoints. .HttpClientFactory(new DefaultHttpClientFactory()) .Build(); try { CustomerDetailsResponse response = await api.CustomersClient().Get("customer_id"); } catch (CheckoutApiException e) { // API error string requestId = e.RequestId; var statusCode = e.HttpStatusCode; IDictionary<string, object> errorDetails = e.ErrorDetails; } catch (CheckoutArgumentException e) { // Bad arguments } catch (CheckoutAuthorizationException e) { // Invalid authorization }
{- "id": "cus_y3oqhf46pyzuxjbcn2giaqnb44",
- "email": "brucewayne@gmail.com",
- "default": "src_wmlfc3zyhqzehihu7giusaaawu",
- "name": "Bruce Wayne",
- "phone": {
- "country_code": "+1",
- "number": "415 555 2671"
}, - "metadata": {
- "coupon_code": "NY2018",
- "partner_id": 123989
}, - "instruments": [
- {
- "type": "card",
- "id": "src_wmlfc3zyhqzehihu7giusaaawu",
- "fingerprint": "vnsdrvikkvre3dtrjjvlm5du4q",
- "expiry_month": 6,
- "expiry_year": 2025,
- "scheme": "VISA",
- "last4": "9996",
- "bin": "454347",
- "card_type": "CREDIT",
- "card_category": "CONSUMER",
- "issuer": "TEST STATE BANK",
- "issuer_country": "US",
- "product_id": "F",
- "product_type": "CLASSIC",
- "account_holder": {
- "first_name": "John",
- "last_name": "Smith",
- "billing_address": {
- "address_line1": "123 High St.",
- "address_line2": "Flat 456",
- "city": "London",
- "zip": "SW1A 1AA",
- "country": "GB"
}, - "phone": {
- "country_code": "+1",
- "number": "415 555 2671"
}
}, - "card_wallet_type": "applepay"
}
]
}Update the details of a customer and link payment instruments to them.
Customer updated successfully
Unauthorized
Customer not found
Invalid data was sent
{- "email": "brucewayne@gmail.com",
- "name": "Bruce Wayne",
- "phone": {
- "country_code": "+1",
- "number": "415 555 2671"
}, - "metadata": {
- "coupon_code": "NY2018",
- "partner_id": 123989
}, - "default": "src_wmlfc3zyhqzehihu7giusaaawu"
}{- "request_id": "0HL80RJLS76I7",
- "error_type": "request_invalid",
- "error_codes": [
- "payment_source_required"
]
}Delete a customer and all of their linked payment instruments.
Customer deleted successfully
Unauthorized
Customer not found or not associated with client
// For more information please refer to https://github.com/checkout/checkout-sdk-net //API keys ICheckoutApi api = CheckoutSdk.Builder().StaticKeys() .SecretKey("secret_key") .Environment(Environment.Sandbox) .EnvironmentSubdomain("{prefix}") // Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see https://www.checkout.com/docs/developer-resources/api/api-endpoints. .HttpClientFactory(new DefaultHttpClientFactory()) .Build(); //OAuth ICheckoutApi api = CheckoutSdk.Builder().OAuth() .ClientCredentials("client_id", "client_secret") .Scopes(OAuthScope.Vault) .Environment(Environment.Sandbox) .EnvironmentSubdomain("{prefix}") // Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see https://www.checkout.com/docs/developer-resources/api/api-endpoints. .HttpClientFactory(new DefaultHttpClientFactory()) .Build(); try { EmptyResponse response = await api.CustomersClient().Delete("customer_id"); } catch (CheckoutApiException e) { // API error string requestId = e.RequestId; var statusCode = e.HttpStatusCode; IDictionary<string, object> errorDetails = e.ErrorDetails; } catch (CheckoutArgumentException e) { // Bad arguments } catch (CheckoutAuthorizationException e) { // Invalid authorization }