Should we consistently hit the server in AJAX to check if it's now complete, or is there a better way of doing this.
No you shouldn't and yes there is a better way. Callback pages/webhooks would make sense if you didn't have an asp.net server handing the transaction, but they aren't necessary here.
How can we have the order webpage update/move the user onto to order
complete?
The stripe payment process only takes a couple seconds to respond with a status code. It's not the same as Paypal where the user is directed to a Paypal site and then back to your site.
The process is supposed to go:
The user enters their payment information into stripe generated
elements on your page.
Stripe gives your front end javascript a
token that represents the customer's payment data.
You post that information to your server using ajax or even a regular old fashioned form request.
- The server side script handling the call uses the asp.net stripe library to send the payment and gets an answer back like the one below.
Save the transaction result to your database as needed.
a. If the stripe resonse includes "status":"succeeded" then you can serve the customer with a new page with the paid receipt.
b. If it failed for some reason you can reload the payment page and use the "failure_message" to tell the customer why their card is no good.
Let the user wait until stripe replies with a message regarding the success or failure of the payment and send him because it only takes a second.
/* SAMPLE RESPONSE FROM STRIPE
{
"id": "ch_1D658SDJ46dzUiasdfsdfaDq",
"object": "charge",
"amount": 2125,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"balance_transaction": "txn_1D658SDJ46dzUilftNXRCz64",
"captured": true,
"created": 1565431460,
"currency": "usd",
"customer": null,
"description": "856 addresses",
"destination": null,
"dispute": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"order": null,
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"receipt_email": null,
"receipt_number": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/charges/ch_1D658SDJ46dzUilfalFFraDq/refunds"
},
"review": null,
"shipping": null,
"source": {
"id": "card_1D658RDJ46dzUilfbkLSOIwp",
"object": "card",
"address_city": "test",
"address_country": "US",
"address_line1": "123 test",
"address_line1_check": "pass",
"address_line2": "",
"address_state": null,
"address_zip": "32121",
"address_zip_check": "pass",
"brand": "Visa",
"country": "US",
"customer": null,
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 12,
"exp_year": 2033,
"fingerprint": "fNMgYIntTkOnLVzk",
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": "Test",
"tokenization_method": null
},
"source_transfer": null,
"statement_descriptor": null,
"status": "succeeded",
"transfer_group": null
}