Howto Stripe Payment integration

Helpful page as reference : https://www.codexworld.com/stripe-payment-gateway-integration-php/

Requirements / Installation:

  1. Register on Stripe. Download Stripe Classes https://github.com/stripe/stripe-php#manual-installation and extract it to your folder for example www\inc\YOUR-STRIPE-FOLDER
  2. You need a new Page where you add the Stripe Server Code and then add the required/include the stripe classes you downloaded and point to that folder with init.php like the screen here
    image
  3. On your page where you sell your products, lets call it productpage.php add the simple form button code which contains amount, public stripe token, currency etc. : image

Ok so far I’ve got now the Stripe Payment process but still need to catch the JSON payment results so I could store it into MYSQL db. Now what I’ve got is:

There are several methods of stripe integration. They even offer now a Beta with hosted landing page. So you’ll setup products on stripes side and just link your payment button to there.
Another way is to use the payment button (FORM), lets call it productpage.php where you’ll send that form with hidden price, public token etc via POST Action to a special prepared payment process with some php code. Lets call it paymentprocess.php where I’ll show you the screens below:

My productpage.php looks like :

My paymentprocess.php looks like that :

I’m getting back that JSON file as result:

Stripe\Charge JSON: { "id": "ch_xxxxxxxxxxxxI", "object": "charge", "amount": 999, "amount_refunded": 0, "application": null, "application_fee": null, "balance_transaction": "txn_xxxxxxxxxxxxxxxxx", "captured": true, "created": 1546070431, "currency": "usd", "customer": null, "description": "Example charge", "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", "risk_score": 14, "seller_message": "Payment complete.", "type": "authorized" }, "paid": true, "payment_intent": null, "receipt_email": null, "receipt_number": null, "refunded": false, "refunds": { "object": "list", "data": [], "has_more": false, "total_count": 0, "url": "\/v1\/charges\/ch_xxxxxxxxxxxxxxxI\/refunds" }, "review": null, "shipping": null, "source": { "id": "card_1xxxxxxxxxxxxxxxxx", "object": "card", "address_city": null, "address_country": null, "address_line1": null, "address_line1_check": null, "address_line2": null, "address_state": null, "address_zip": null, "address_zip_check": null, "brand": "Visa", "country": "US", "customer": null, "cvc_check": "pass", "dynamic_last4": null, "exp_month": 11, "exp_year": 2021, "fingerprint": "Mxxxxxxxxxx", "funding": "credit", "last4": "4242", "metadata": [], "name": "fda@dd.de", "tokenization_method": null }, "source_transfer": null, "statement_descriptor": null, "status": "succeeded", "transfer_group": null }

As you can see the payments are properly catched into Stripe and we see that fda@dd.de User here :

Now my question is how to store the values / catch them? As I can see that form is using post method. Maybe I can use DMX input fields instead of that strange Script Form injection.

Community Page
Last updated: