SHASHANGKA SHEKHAR'S BLOG

Author, TechWriter

StripePayment-ASP.Net Core2.1

Hits: 76

In this post, we are going to implement stripe payment gateway with Asp.net Core 2.1. Based on previous post this article is extended to implement payment gateway. We are going to modify/extend existing sample application by downloading full source code from github.

Let’s get started by opening the existing application, first of all we are going to add Stripe.net package. Go to NuGet to install the latest version package. It is a portable class library for the Stripe API.

Configure API Key: 

In Startup.cs we need to add API key for stripe authorization. Without this configuration application throw StripeException.

Here’s the full function in Startup.cs after adding stripe configuration.

AngularJS Controller: In controller we are accessing the token id for server code to create customer.

Html View: This is stripe custom checkout button example, from below code there’s a checkout button to perform action.

WebAPI: From the below post method first customer is created then create charge to stripe with amount and customer id. Finally payment status is returned whether the transaction is failed or succeeded.

Pay: Test card number 4242 4242 4242 4242

Stripe: After successfully payment completion this is the payment details in stripe.

Downloads:

I’ve uploaded the full source code to download/clone @github, Thanks 🙂

Post a comment