Payment Service - PaySimple/PaySimpleSDK GitHub Wiki
Home | Account Service | Customer Service | Payment Service | Payment Schedule Service | PagedResult | Exceptions
The Payment Service is used to create, get, reverse and void payments. The SDK provides the following methods:
- CreateNewAccountPaymentAsync
- CreateNewCustomerPaymentAsync
- CreatePaymentAsync
- GetCheckoutAsync
- GetPaymentAsync
- GetPaymentsAsync
- GetPaymentTokenAsync
- ReversePaymentAsync
- VoidPaymentAsync
Parameter Name | Type | Description | Notes |
---|---|---|---|
settings | IPaySimpleSdkSettings | SDK Settings |
var settings = new PaySimpleSettings("AoOtRylA63570WmH3eqChyFRqwhTnA2g0dnsV7zzQko4s4yKWdBorA1WiT7dK2H2xz06P562Hqv0heYBdfNamfQyxX50drtpL8s7", "AUserName");
var paymentService = new PaymentService(settings);
CreateNewAccountPaymentAsync is a convenience method that creates a new account and a new payment linked to an existing customer
Parameter Name | Type | Description | Notes |
---|---|---|---|
accountPayment | NewAccountPayment | Account and Payment to create | T is either Ach or CreditCard |
NewAccountPayment
var accountPayment = new NewAccountPayment<CreditCard>
{
Account = new CreditCard
{
CustomerId = 123456,
CreditCardNumber = "4111111111111111",
ExpirationDate = "12/2021",
Issuer = Issuer.Visa
},
Payment = new Payment
{
Amount = 50.00M,
Cvv = 996
}
};
var newAccountPayment = await paymentService.CreateNewAccountPaymentAsync<CreditCard>(accountPayment);
CreateNewCustomerPaymentAsync is a convenience method that creates a new customer, a new account and a new payment
Parameter Name | Type | Description | Notes |
---|---|---|---|
customerPayment | NewCustomerPayment | Customer, Account and Payment to create | T is either Ach or CreditCard |
NewCustomerPayment
var customerPayment = new NewCustomerPayment<CreditCard>
{
Customer = new Customer
{
FirstName = "Jayne",
LastName = "Cobb"
},
Account = new CreditCard
{
CreditCardNumber = "371449635398456",
ExpirationDate = "12/2021",
Issuer = Issuer.Amex
},
Payment = new Payment
{
Amount = 5.00M,
Cvv = 996
}
};
var newCustomerPayment = await paymentService.CreateNewCustomerPaymentAsync<CreditCard>(customerPayment);
CreatePaymentAsync creates a new payment
Parameter Name | Type | Description | Notes |
---|---|---|---|
payment | Payment | Payment to create |
Payment
var payment = new Payment
{
AccountId = 123456,
Amount = 42.00M,
}
var result = await paymentService.CreatePaymentAsync(payment);
GetCheckoutTokenAsync gets a token that will identify you during the checkout process
CheckoutToken
var checkoutToken = await paymentService.GetCheckoutTokenAsync();
GetPaymentAsync gets a specific payment
Parameter Name | Type | Description | Notes |
---|---|---|---|
paymentId | int | Id of the Payment to get |
Payment
var result = await paymentService.GetPaymentAsync(123456);
GetPaymentsAsync gets Payments
Parameter Name | Type | Description | Notes |
---|---|---|---|
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>
// Get all payments sorted by payment Id, ascending
var payments = await customerService.GetPaymentsAsync();
// Get all payments 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(status, PaymentSort.Amount);
GetPaymentTokenAsync gets a token that represents protected card data for a payment account
Parameter Name | Type | Description | Notes |
---|---|---|---|
request | PaymentTokenRequest | Information about the protected card data to get a token for |
PaymentToken
var tokenRequest = new PaymentTokenRequest
{
CustomerAccountId = 123456,
CustomerId = 44444,
Cvv = "999"
};
var paymentToken = await paymentService.GetPaymentTokenAsync(tokenRequest);
ReversePaymentAsync refunds a specific payment that has a status of Authorized (Credit Card) or ReversePosted (Ach)
Parameter Name | Type | Description | Notes |
---|---|---|---|
paymentId | int | Id of the Payment to refund |
Payment
var result = await paymentService.ReversePaymentAsync(123456);
VoidPaymentAsync refunds a specific payment that has a status of Authorized (Credit Card), Posted (Ach) and ReversePosted (Ach)
Parameter Name | Type | Description | Notes |
---|---|---|---|
paymentId | int | Id of the Payment to refund |
Payment
var result = await paymentService.VoidPaymentAsync(123456);