Customer Service - PaySimple/PaySimpleSDK GitHub Wiki
Home | Account Service | Customer Service | Payment Service | Payment Schedule Service | PagedResult | Exceptions
The Customer Service is used to create, get, update and delete Customer records. The Customer Service also provides methods to get Accounts, Payments and Schedules associated with a specific Customer. The SDK provides the following methods:
- CreateCustomerAsync
- DeleteCustomerAsync
- GetAchAccountsAsync
- GetAllAccountsAsync
- GetCreditCardAccountsAsync
- GetCustomerAsync
- GetCustomersAsync
- GetDefaultAchAccountAsync
- GetDefaultCreditCardAccountAsync
- GetPaymentPlansAsync
- GetPaymentsAsync
- GetPaymentSchedulesAsync
- GetRecurringPaymentSchedulesAsync
- MatchOrCreateCustomerAndCreditCardAccountAsync
- MatchOrCreateCustomerAndAchAccountAsync
- SetDefaultAccountAsync
- UpdateCustomerAsync
Parameter Name | Type | Description | Notes |
---|---|---|---|
settings | IPaySimpleSdkSettings | SDK Settings |
var settings = new PaySimpleSettings("AoOtRylA63570WmH3eqChyFRqwhTnA2g0dnsV7zzQko4s4yKWdBorA1WiT7dK2H2xz06P562Hqv0heYBdfNamfQyxX50drtpL8s7", "AUserName");
var customerService = new CustomerService(settings);
CreateCustomerAsync creates a new Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customer | Customer | Customer to create |
Customer
var customer = new Customer
{
FirstName = "Mal",
LastName = "Reynolds"
};
var customer = await customerService.CreateCustomerAsync(customer);
DeleteCustomerAsync deletes an existing Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | Id of the Customer to delete |
await customerService.DeleteCustomerAsync(123456);
GetAchAccountsAsync gets all Ach accounts associated with a Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer to get the accounts for |
IEnumerable<Ach>
var achAccounts = await customerService.GetAchAccountsAsync(123456);
GetAllAccountsAsync get all Ach & Credit Card accounts associated with a Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer to get the accounts for |
AccountList
var accounts = await customerService.GetAllAccountsAsync(123456);
GetCreditCardAccountsAsync gets all Credit Card accounts associated with a Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer to get the accounts for |
IEnumerable<CreditCard>
var creditCardAccounts = await customerService.GetCreditCardAccountsAsync(123456);
GetCustomerAsync gets a specifc Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer to get |
Customer
var customer = await customerService.GetCustomerAsync(123456);
GetCustomersAsync gets a list of Customers
Parameter Name | Type | Description | Notes |
---|---|---|---|
sortBy | CustomerSort | The field to sort the results by | Default: CustomerSort.LastName |
direction | SortDirection | The direction to sort the results by | Default: SortDirection.ASC |
page | int | The page to get | Default: 1 |
pageSize | int | The page size | Default: 200 |
lite | bool | Get a lite version of the returned object | Default: false |
PagedResult<IEnumerable<Customer>>
// Get the first page of customers sorted by FirstName, in Descending order
var customers = await customerService.GetCustomersAsync(CustomerSort.FirstName, SortDirection.DESC, 1);
// Get the third page of customers sorted by BillingAddressCity, in Ascending order, with lite Customer object
var customers = await customerService.GetCustomersAsync(CustomerSort.BillingAddressCity, page: 3, lite: true);
GetDefaultAchAccountAsync gets the default Ach Account associated with a Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer |
Ach
var achAccount = await customerService.GetDefaultAchAccountAsync(123456);
GetDefaultCreditCardAccountAsync gets the default CreditCard Account associated with a Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer |
CreditCard
var creditcardAccount = await customerService.GetDefaultCreditCardAccountAsync(123456);
GetPaymentPlansAsync gets Customer Payment Plans
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer | |
startDate | DateTime? | Start date of the payment plan | Default: null |
endDate | DateTime? | End date of the payment plan | Default: null |
status | ScheduleStatus | Status of the payment plan | Default: ScheduleStatus.None |
sortBy | ScheduleSort | Field to sort the resulting list by | Default: ScheduleSort.Id |
direction | SortDirection | The direction to sort the results by | Default: SortDirection.ASC |
page | int | The page to get | Default: 1 |
pageSize | int | The page size | Default: 200 |
lite | bool | Get a lite version of the returned object | Default: false |
PagedResult<IEnumerable<PaymentPlan>>
// Get all payment plans for customer id 123456 sorted by Id, ascending
var paymentPlans = await customerService.GetPaymentPlansAsync(123456);
// Get all active payment plans for customer id 123456 sorted by next payment date descending
var paymentPlans = await customerService.GetPaymentPlansAsync(123456, status: ScheduleStatus.Active, sortBy: ScheduleSort.NextPaymentDate, direction: SortDirection.DESC);
GetPaymentsAsync gets Customer Payments
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer | |
startDate | DateTime? | Start date of the payment plan | Default: null |
endDate | DateTime? | End date of the payment plan | Default: null |
status | IEnumerable | Stati of the payment plan | Default: null |
sortBy | PaymentSort | Field to sort the resulting list by | Default: PaymentSort.Id |
direction | SortDirection | The direction to sort the results by | Default: SortDirection.ASC |
page | int | The page to get | Default: 1 |
pageSize | int | The page size | Default: 200 |
lite | bool | Get a lite version of the returned object | Default: false |
PagedResult<IEnumerable<Payment>>
// Get all payments for customer id 123456 sorted by payment Id, ascending
var payments = await customerService.GetPaymentsAsync(123456);
// Get all payments between 3 days ago and today with a payment status of Authorized, Voided or Returned, sorted by Amount
var status = new List<PaymentStatus>
{
PaymentStatus.Authorized,
PaymentStatus.Voided,
PaymentStatus.Returned
};
var payments = await customerService.GetPaymentsAsync(123456, DateTime.Now.AddDays(-3), DateTime.Now, status, PaymentSort.Amount);
GetPaymentSchedulesAsync gets Customer Payment Schedules (PaymentPlans and RecurringPayments)
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer | |
startDate | DateTime? | Start date of the payment plan | Default: null |
endDate | DateTime? | End date of the payment plan | Default: null |
status | ScheduleStatus | Status of the payment plan | Default: ScheduleStatus.None |
sortBy | ScheduleSort | Field to sort the resulting list by | Default: ScheduleSort.Id |
direction | SortDirection | The direction to sort the results by | Default: SortDirection.ASC |
page | int | The page to get | Default: 1 |
pageSize | int | The page size | Default: 200 |
lite | bool | Get a lite version of the returned object | Default: false |
PagedResult<IEnumerable<PaymentScheduleList>>
// Get all payment schedules for customer id 123456 sorted by Id, ascending
var paymentSchedules = await customerService.GetPaymentSchedulesAsync(123456);
GetRecurringPaymentSchedulesAsync gets Customer Recurring Payment Schedules
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer | |
startDate | DateTime? | Start date of the payment plan | Default: null |
endDate | DateTime? | End date of the payment plan | Default: null |
status | ScheduleStatus | Status of the payment plan | Default: ScheduleStatus.None |
sortBy | ScheduleSort | Field to sort the resulting list by | Default: ScheduleSort.Id |
direction | SortDirection | The direction to sort the results by | Default: SortDirection.ASC |
page | int | The page to get | Default: 1 |
pageSize | int | The page size | Default: 200 |
lite | bool | Get a lite version of the returned object | Default: false |
PagedResult<IEnumerable<RecurringPayment>>
// Get all recurring payment schedules for customer id 123456 sorted by Id, ascending
var recurringSchedules = await customerService.GetRecurringPaymentSchedulesAsync(123456);
// Get all expired recurring payment schedules for customer id 123456 sorted by next payment amount ascending with a page size of 50 using lite records
var recurringSchedules = await customerService.GetRecurringPaymentSchedulesAsync(123456, status: ScheduleStatus.Expired, sortBy: ScheduleSort.PaymentAmount, pageSize: 50, lite = true);
MatchOrCreateCustomerAndCreditCardAccountAsync will match or create a customer and credit card with each other
Parameter Name | Type | Description | Notes |
---|---|---|---|
request | CustomerAndAccountRequest | Customer and credit card account information |
var customerAndCreditCard = new CustomerAndAccountRequest
{
Customer = new Customer
{
Email = "[email protected]"
},
CreditCardAccount = new CreditCard
{
CreditCardNumber = "4111111111111111",
BillingZipCode = "55555",
Issuer = Issuer.Visa
}
};
await customerService.MatchOrCreateCustomerAndCreditCardAccountAsync(customerAndCreditCard);
MatchOrCreateCustomerAndAchAccountAsync sets a Customer Account to be the default account for Ach and CreditCard
Parameter Name | Type | Description | Notes |
---|---|---|---|
request | CustomerAndAccountRequest | Customer and ach account information |
var customerAndAch = new CustomerAndAccountRequest
{
Customer = new Customer
{
Email = "[email protected]"
},
AchAccount = new Ach
{
RoutingNumber = "131111114",
AccountNumber = "751111111"
}
};
await customerService.MatchOrCreateCustomerAndAchAccountAsync(customerAndAch);
SetDefaultAccountAsync sets a Customer Account to be the default account for Ach and CreditCard
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerId | int | CustomerId of the customer | |
accountId | int | Id of the account to set as the default account |
await customerService.SetDefaultAccountAsync(123456, 654321);
UpdateCustomerAsync updates an existing Customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
customer | Customer | Customer to update |
Customer
var customer = new Customer
{
Id = 123456,
FirstName = "Mal",
LastName = "Reynolds",
ShippingSameAsBilling = false
};
var customer = await customerService.UpdateCustomerAsync(customer);