Stripe - ACH, Credit Card Single Payment
Stripe integration provide a set of tools to be able to collect payments from Users within the portal, this can be used for Training costs, store products, bills and invoices or membership fees.
This article tracks details about using the new version of Stripe API for Credit Card and ACH Bank Payments as well subscription or recurring payments.
ACH or Bank Payment - Single Payment
var chargeInfo = new ChargeInfo() {
AccountType = "individual",
RoutingNumber = "110000000",
AccountNumber = "000123456789",
BankName = "Test Bank Account",
NameOnAccount = "Jane Doe",
Amount = 150.00M,
Currency = "USD",
Country = "US",
Email = "jane.doe@gmail.com",
City = "Toronto",
Street1 = "Main Street",
ZipCode = "A1A1A1",
State = "Ontario",
Description = "Testing Stripe ACH"
};
var stripe = new Stripe2.SripeHelper("<STRIPE_CONNECTED_APP_NAME>");
var charge = stripe.ProcessAchPayment(chargeInfo);
if (charge.Status != "success")
{
}
else
{
var transactionId = charge.Id;
}
Testing ACH
The payment succeeds. AccountNumber = “000123456789”
The payment fails because the account is closed. AccountNumber = “000111111113”
The payment fails because no account is found. AccountNumber = “000111111116”
The payment fails due to insufficient funds. AccountNumber = “000222222227”
The payment fails because debits aren’t authorized. AccountNumber = “000333333335”
The payment fails due to invalid currency. AccountNumber = “000444444440”
The payment fails to send micro-deposits. AccountNumber = “000666666661”
Tokenized Bank Account Payment
var stripe = new Stripe2.SripeHelper("<STRIPE_CONNECTED_APP_NAME>");
var chargeObject = Stripe2Data.PrepareChargeObject(chargeInfo,
customerId,
bankAccountId);
var charge = stripe.Charge(chargeObject);
See Stripe Account Management to learn more about how you can tokenize bank accounts.
Charge Properties
| Property Name | Property Type |
|---|
| Id | string |
| ObjectName | string |
| Amount | decimal |
| AmountRefunded | decimal |
| Application | string |
| PaymentMethod | string |
Credit Card Single Payment
In order to charge a credit card, you need to use ChargeInfo class and populate the details in it.
var chargeInfo = new ChargeInfo() {
Firstname = "Jane",
Lastname = "Doe",
Amount = 505.00M,
Currency = "USD",
Country = "US",
CardNumber = "4242424242424242",
ExpMonth = 3,
ExpYear = 2030,
CardCvc = "123",
Email = "jane.doe@gmail.com",
City = "Toronto",
Street1 = "Main Street",
ZipCode = "A1A1A1",
State = "Ontario",
Description = "Testing Stripe Credit Card Single Payment"
};
var stripe = new Stripe2.SripeHelper("<STRIPE_CONNECTED_APP_NAME>");
var paymentIntent = stripe.ProcessCreditCardPayment(chargeInfo);
if (paymentIntent.Status != "success")
{
}
else
{
var transactionId = charge.Id;
}
Testing Credit Card Payments
Successful Payment: CardNumber = “4242424242424242”
Credit Card Declined. CardNumber = "4000000000000002"
Required 3D Secure validation. CardNumber = “4000000000003220”
SEPA Credit Single Payment
SEPA Direct Debit is used to debit bank accounts within the Single Euro Payments Area (SEPA) region.
In order to debit an account, businesses must collect their customer’s name and bank account number in IBAN format. During the payment flow, customers must accept a mandate that gives the business an authorization to debit the account. Stripe is able to generate this mandate for businesses to present to their customers.
SEPA Direct Debit payments are an asynchronous method, so funds are not immediately available. A charge created from a SEPA Direct Debit source can remain in a pending state for up to 14 business days from its creation, though the average time is around five business days. Once the charge is confirmed, its status is updated to succeed. Your integration must use Webhooks in order for you to receive notifications of status changes on PaymentIntent and Charge objects.
var chargeInfo = new ChargeInfo() {
AccountNumber = "IT40S0542811101000000123456",
NameOnAccount = "Jane Doe",
Amount = 25.00M,
Currency = "EUR",
Country = "IT",
Email = "zuleidy.briceno@magentrix.com",
City = "Toronto",
Street1 = "Main Street",
ZipCode = "A1A1A1",
State = "Ontario",
Description = "Testing Stripe Subscription SEPA Debit ONE"
};
var stripe = new Stripe2.SripeHelper("<STRIPE_CONNECTED_APP_NAME>");
var paymentIntent = stripe.ProcessSepaDebitPayment(chargeInfo);
if (paymentIntent.Status == "processing")
{
return View("Message", new {
Title = "Thank You",
Message = "Your payment is being processed. You will receive an email if the Payment is successful." });
}
NOTE: SEPA Credit Payment requires users' consent to create a mandate. So, consider adding the verbiage below on your UI, Users can read and agree with it before submitting the request.
By providing your IBAN and confirming this payment, you are authorizing COMPANY_NAME and Stripe, our payment service provider, to send instructions to your bank to debit your account and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.
Testing SEPA Credit Payment
To fully Test your integration, consider testing all possible scenarios:
The charge status transitions from pending to succeed. AccountNumber = "IT40S0542811101000000123456"
The charge status transitions from pending to failed. AccountNumber = “IT60X0542811101000000123456”
The charge status transitions from pending to succeeded, but a dispute is immediately created. AccountNumber = “IT83S0542811101000000123458”