In the Process phase of the payment processing workflow, the order processing web app charges the user's card, updates the ordering and inventory data, and returns the transaction's status (that is, whether it is approved or declined) to the user app on the user's device as an HTTP response to the app's original HTTP request. This web app uses the payment gateway's server-side API to communicate with it.
In the example order processing web app (a Node.js web app), the HTTP request from the user app is handled by the middleware, as follows:
// server_app/red.js // payment middleware server.post('/payment', function(request, response, next) { // 1. parse request var order_info_package= JSON.parse(request.body); // process charge token if (order_info_package.gateway == 'stripe') { // 2. charge payment card var charge= stripe.charges.create ( { amount : order_info_package.amount, currency : order_info_package...