1, registered stripe account https://stripe.com
Initial account is the test mode, need to activate the account to enter the live mode, click "Your Accounts", "Accounts Settings", the following pop-up box appears:
If it is test mode, use Test Secret key and test publishable key, otherwise use live-related two key, and how to use it, keep looking down
2, installation Stripe
With NuGet installed stripe, search will find stripe and stripe.net two, please install stripe. Specific process Skip!
can go to https://github.com/nberardi/stripe-dotnet download source to see
3. Integrated Payment
<form action= "/chargecontroller/charge" <script src= "Https://checkout.stripe.com/checkout.js" type= " Text/javascript " data-key=" Your-test-publishable-key " data-image=" Your-website-image,size 128*128 " Data-name= "Demo Site" data-description= "2 widgets (£20.00)" data-currency= "GBP" data-amount= "2500"/ ></form>
Embed the above script in the form, one in the form, and, of course, you can use the custom button as needed, see the stripe official website.
Click the button, fill in the dialog in the pop-up payment information, fill in the correct, will produce a stripetoken, together with the other contents of the form to post to Chargecontroller/charge
4. Execution of payment
[HttpPost] public actionresult Charge (formcollection form) {String token = form["Stripet Oken "]; string email = form["Stripeemail"]; String ApiKey = "Sk_test_xxxxxxxxxxxxxxx"; var stripeclient = new Stripe.stripeclient (ApiKey); Dynamic response = Stripeclient.createchargewithtoken ($, token, "NOK", email); if (response. IsError = = False && response. Paid) {//success String id = response. id;//Payment ID BOOL Livemode = response. livemode;//Payment mode Long created = response. created;//payment Time String status = Response. status;//Payment Status Object Source = Response. source;//Payment Source (credit card, etc.) string source_id = Response. source.id;//Card Id String source_last4 = Response. source.last4;//card after four bit string source_brand = response. source.brand;//Card Brand (visa, etc.) string source_funding = ReSponse. source.funding;//funds (Creadit, etc.) int source_exp_month = response. Source.exp_month; Card expiration Month int source_exp_year = response. source.exp_year;//card expiration Year string source_name = Response. source.name;//payer's mailbox name return redirecttoaction ("Index", "Home"); } return View (); }
This is the completion of a payment process, compared to PayPal, I think it is more convenient!
ASP. NET MVC Integrated stripe payment