1. Home
  2. Library
  3. SDK .NET
  4. Create and retrieve a client – .NET

Create and retrieve a client – .NET

CREATE A CLIENT HAS DIFFERENT PURPOSES, THE MAIN ONE IS BE ABLE TO SAVE TOKENS IN ORDER TO USE THEM MULTIPLE TIMES.

As we have said in the past, tokens tok_xxxxx  can be used only once, nevertheless, it’s probable that the application nature requieres tokens to be used more than once. In this case the first step to achieve recurrent tokens is to create a client.

Pre-requisites

Have installed and configured the SDK

Process

1. Import SrPago dependencies.

using SrPagoApi;
using SrPagoApi.Response;
SrPago.ApiKey = "APPLICATION KEY";
SrPago.ApiSecret = "APPLICATION SECRET";
SrPago.LiveMode = false;

2. Create an object with email and the client’s name.

Dictionary<string, object> customerParams = new Dictionary<string, object>
{
{ "name", <Nombre del cliente>},
{ "email", <Email del cliente> }
};

3. Use the object to create a client

CustomerService customerService = new CustomerService();
CustomerResponse customer = await customerService.Create(customerParams);

This method will return an array with a token cus_xxxxx in the position $customer[‘result’][‘id’]. It would be important to save this token in a DB for future operations.

4. To retrieve a client information we will need the token generated in point 4, the method is

CustomerService customerService = new CustomerService();
CustomerResponse customer = await customerService.Retreive(<Token del Paso anterior>);

This method will return an array with client information, included the active Credit Cards from that client. To know how to add additional cards please review the documentation

Note: To know more about the responses and possible error codes you may refer to the API docs

Was this article helpful to you? Yes 8 No