payment with stripe in php

Solutions on MaxInterview for payment with stripe in php by the best coders in the world

showing results for - "payment with stripe in php"
Matteo
12 Mar 2017
1<?php
2namespace PhpPot\Service;
3
4require_once 'vendor/stripe/autoload.php';
5
6use \Stripe\Stripe;
7use \Stripe\Customer;
8use \Stripe\ApiOperations\Create;
9use \Stripe\Charge;
10
11class StripePayment
12{
13
14    private $apiKey;
15
16    private $stripeService;
17
18    public function __construct()
19    {
20        require_once "config.php";
21        $this->apiKey = STRIPE_SECRET_KEY;
22        $this->stripeService = new \Stripe\Stripe();
23        $this->stripeService->setVerifySslCerts(false);
24        $this->stripeService->setApiKey($this->apiKey);
25    }
26
27    public function addCustomer($customerDetailsAry)
28    {
29        
30        $customer = new Customer();
31        
32        $customerDetails = $customer->create($customerDetailsAry);
33        
34        return $customerDetails;
35    }
36
37    public function chargeAmountFromCard($cardDetails)
38    {
39        $customerDetailsAry = array(
40            'email' => $cardDetails['email'],
41            'source' => $cardDetails['token']
42        );
43        $customerResult = $this->addCustomer($customerDetailsAry);
44        $charge = new Charge();
45        $cardDetailsAry = array(
46            'customer' => $customerResult->id,
47            'amount' => $cardDetails['amount']*100 ,
48            'currency' => $cardDetails['currency_code'],
49            'description' => $cardDetails['item_name'],
50            'metadata' => array(
51                'order_id' => $cardDetails['item_number']
52            )
53        );
54        $result = $charge->create($cardDetailsAry);
55
56        return $result->jsonSerialize();
57    }
58}
Liah
09 Nov 2017
1<?php if(!empty($successMessage)) { ?>
2<div id="success-message"><?php echo $successMessage; ?></div>
3<?php  } ?>
4<div id="error-message"></div>
5
6<form id="frmStripePayment" action="" method="post">
7    <div class="field-row">
8        <label>Card Holder Name</label> <span id="card-holder-name-info"
9            class="info"></span><br> <input type="text" id="name"
10            name="name" class="demoInputBox">
11    </div>
12    <div class="field-row">
13        <label>Email</label> <span id="email-info" class="info"></span><br>
14        <input type="text" id="email" name="email" class="demoInputBox">
15    </div>
16    <div class="field-row">
17        <label>Card Number</label> <span id="card-number-info"
18            class="info"></span><br> <input type="text" id="card-number"
19            name="card-number" class="demoInputBox">
20    </div>
21    <div class="field-row">
22        <div class="contact-row column-right">
23            <label>Expiry Month / Year</label> <span id="userEmail-info"
24                class="info"></span><br> <select name="month" id="month"
25                class="demoSelectBox">
26                <option value="08">08</option>
27                <option value="09">9</option>
28                <option value="10">10</option>
29                <option value="11">11</option>
30                <option value="12">12</option>
31            </select> <select name="year" id="year"
32                class="demoSelectBox">
33                <option value="18">2018</option>
34                <option value="19">2019</option>
35                <option value="20">2020</option>
36                <option value="21">2021</option>
37                <option value="22">2022</option>
38                <option value="23">2023</option>
39                <option value="24">2024</option>
40                <option value="25">2025</option>
41                <option value="26">2026</option>
42                <option value="27">2027</option>
43                <option value="28">2028</option>
44                <option value="29">2029</option>
45                <option value="30">2030</option>
46            </select>
47        </div>
48        <div class="contact-row cvv-box">
49            <label>CVC</label> <span id="cvv-info" class="info"></span><br>
50            <input type="text" name="cvc" id="cvc"
51                class="demoInputBox cvv-input">
52        </div>
53    </div>
54    <div>
55        <input type="submit" name="pay_now" value="Submit"
56            id="submit-btn" class="btnAction"
57            onClick="stripePay(event);">
58
59        <div id="loader">
60            <img alt="loader" src="LoaderIcon.gif">
61        </div>
62    </div>
63    <input type='hidden' name='amount' value='0.5'> <input type='hidden'
64        name='currency_code' value='USD'> <input type='hidden'
65        name='item_name' value='Test Product'> <input type='hidden'
66        name='item_number' value='PHPPOTEG#1'>
67</form>
Orlane
10 Aug 2020
1<?php
2use \PhpPot\Service\StripePayment;
3
4if (!empty($_POST["token"])) {
5    require_once 'StripePayment.php';
6    $stripePayment = new StripePayment();
7    
8    $stripeResponse = $stripePayment->chargeAmountFromCard($_POST);
9    
10    require_once "DBController.php";
11    $dbController = new DBController();
12    
13    $amount = $stripeResponse["amount"] /100;
14    
15    $param_type = 'ssdssss';
16    $param_value_array = array(
17        $_POST['email'],
18        $_POST['item_number'],
19        $amount,
20        $stripeResponse["currency"],
21        $stripeResponse["balance_transaction"],
22        $stripeResponse["status"],
23        json_encode($stripeResponse)
24    );
25    $query = "INSERT INTO tbl_payment (email, item_number, amount, currency_code, txn_id, payment_status, payment_response) values (?, ?, ?, ?, ?, ?, ?)";
26    $id = $dbController->insert($query, $param_type, $param_value_array);
27    
28    if ($stripeResponse['amount_refunded'] == 0 && empty($stripeResponse['failure_code']) && $stripeResponse['paid'] == 1 && $stripeResponse['captured'] == 1 && $stripeResponse['status'] == 'succeeded') {
29       $successMessage = "Stripe payment is completed successfully. The TXN ID is " . $stripeResponse["balance_transaction"];
30    }
31}
32?>
queries leading to this page
stripe php integration examplecheckout with stripe api laravelsetting up stripe with basic phpuse payment method again stripe laravel 5cstripe 5cpaymentintent in phpstripe pass data in phpstripe stripe refund php exampleadd stripe class phpstripe php referencephp stripe examplestripe php create chargestripe databased phpintegrate stripe payment in phpstripe api for phpphp stripe sdkphp stripe connectcreate customer in stripe phpstripe payment with card phpstripe 2fstripe php responsestripe php 2 4 1stripe bancontact payment php codeimplement stripe payment method in phpsimple stripe php classpayment status in stripe php packagepaymentintent stripe phpstripe php demoread stripe response in phpstripe php formstripe payment for phpstripe create payment method phpstripe generate payment link from pure phphow to add payment method in stripe using phpstripe php docusing stripe api implement php pagepayment using stripe api phpstripe php paymentphp stripe exasmplestripe php installstripe create charge example in phpstripe php runsubscription create stripe phpstripe api example phpstripe payment methods integration in laravel 8pay screen stripe phpinstall stripe phpstripe checkout and phpstripe payment integration in phpstripe create payment intent phpstripe php make paymentstripe connect api phpsetting up stripe with phpstripe paymentinstant using phpphp stripe checkout examplestripe payment gateway phpstripe plan listing phpstripe auto composerstripe 5cstripeclient 28 phpstripe jobsstripe library phpcreate stripe customer phpstripe sample phpstripe phpstripe stripe phphow to integreate stripe into phpstripe php charge examplehow to generate a payment in stripe using phpintegrated stripe payment using phpphp stripe achstripe one time payment phpstripe create account phpstripe payment intent phpstripe subscription tutorial in phpstripe payment gateway form in htmlstripe charges in phpstripe api for php 8how to set custom amount in stripe payment integration phpstripe payment gateway integration in php examplestripe tutorial phplaravel stripe phpstripe subscription using phpsimple stripe phpstripe pay and php tutorialsetapikey in stripe js v3 example php stripe get payment status in phpstripe payment php examplestripe paymentintent phphow stripe works phpphp interrogate stripestripe php phpstripe integration phpphp stripe integrationstripe 2fstripe php laravel 8stripe php payment examplestripe api integration in phpstripe checkout form in phpstripe subscription phpphp s stripesetuo stripe in phptutorial stripe phpstripe integration with phplaravel stripe 2fstripe phptake stripe payment phpstripe integration in phpstyripe phpstripe connect integration phpstripe checkout integration in phpstripe charges phpstripe composer dochow to add stripe checkout form in mysql databasestripe php apistripe php tutorialstripe payment intent example phpstripe connect php codehow to make subscriptions on stripe by php examplestripe add payment method to customer phpintegrate stripe in phpstripe payment method in phpstripe php masterphp for stripe 8integration stripe using php source give in stripe phpstripe php examplestripe payment in core phphow to set up stripe payments in core phpstripe php documentstripe custom checkout example phpcreate paymentmethods for customer stripe phpstripe custom payment form phpstripe connect phpstripe api account phpstripe integration plain phpcreate customer in stripe using phpstripe create subscription example php librarystripe php packagestripe make payment intent phpuse stripe gateway in phpintegrate stripe with php examplesstripe payment gateway php examplestripe php subscription examplestripe subscription api php exampleintegrar stripe phpstripe php library usage for process credit cardstrip payment example phpstripe api php create payment 22stripe com 22stripe in phpstripe payment example phpimplementar stripe en phpphp stripe integration examplestripe js and phpstripe card create phphow to integrate stripe payment method in php stripe into php 5cstripe 5ccharge 3a 3acreate phpphp stripe charge phpstripe database phppayment intent stripe phpcreate payment method stripe laravelstripe 2fstripe php response from stripe serverstripe api docsstripe payment gateway in phpstripe php connectpayment with specific card stripe phpstripe checkout integration phpstripe payment gateway in php demophp stripe payment intentstripe listing plan phpcreate account stripe phpstripe payment phpstripe make card payment phphow to make payment by stripe using js and phpmethods to integrate stripe payment gateway in phpstripe payment design in phpphp stripestripe php library phpstripe payment gatewayintegrate stripe payment gateway in phpstripe api phphstripe php 7 4stripe php integrationphp stripe add usagecreate payment form stripe stripe php chargesstripe payment gateway php integration withdebit card phpimplement stripe in phpstripe create payout method phpstripe php cliethow to integrate stripe payment gateway in phpstripe integration php documentationstripe payment intent javascript and phpstripe payment gateway examples in phpstripe payment using php docsstripe payment php get customerstripe payment gateway on a php pageadd stripe in class phpstripe card add code phpstripe with phpstripe with pure php examplestripe payment in phpphp stripe tagstripe store tutorial phphow to connect stripe account in phpstripe subscription example phpcharge and pay latter stripe phpstripe payout api phphow stripe works in phpstripe 2fstripe php laravelstripe pay button phpphp stripe payment examplestripe payment intents example phpstripe php apistripe payment gateway integration server side phpstripe php library subscriptionstripe subscription example php demostripe php create customerhow to integrate the stripe payment gateway in using phphow to stripe payment hold until when i done in phpcreate stripe address in phpstripe php versionsubscription payment stripe phphow to do table stripe in phpphp add stripe to websiteplaid with stripe in phpstripe single payment phphow to purchase item using stripe phpstripe intergration phpstripe integration plain php v3stripe checkout phpstripeplaid 3a 3amake phpstripe php examplestripe example phpphp script to integrate stripephp stripe librarystripe payment gateway integration in phpstripe payment gateway integration phpstripe checkout integrations phpstripe checkout payment response phpstripe form phpstripe create charge link via phppayment stripe phpstripe api php tutorialstripe documentation phpstripe create card stripe com example phpthe stripe php librarystripe install phphow to integrate stripe payment using phpstripe payment php 7 2stripe monthly payments phpstripe api php connectphp stripe apistripe payment api phpcreate subscription stripe phpintegration stripe connect in php demostripe php example codephp stripe singstripe payment sdk phpphp setup future payments stripe exampleuse stripe in phpstripe phpstripe phpstripe php librarystripe implementation in phpstripe paymentphp how to get a stripe price object examplestripe payment in 24stripe get phpstripe php documentationdisplay the response of stripe api in phphow to install the stripe php librarypayment form php stripestripe api phppayment api stripe in phpstripe refund php examplecreate the card pay payment button in phppayment with stripe php examplestripe create source phpphp add stripe payment button to websitephp stripe payout laravel stripe phppayment phpstripe subscription button phpphp stripe subscriptionstripe php payment poststripe client phpstripe payment methodsstripe get post data phphow to stripe payment with parameters after success in phpstripe api documentation phpget customer stripe phpstripe connect php documentationlaravel stripe paymentsubscription create using payment method in php striperequire stripe phpstripe php method liststripe payout 3a 3a php exampleset up stripe connect phphow to sve stripe key in php appphp payment stripe sdkstripe integration for phpstripe api payment phpphp integrate stripe into websitestripe cliente example phphow to implement stripe payment gateway phpadding stripe php how to create customer in stripe using phpstripe package for phpconfigure stripe phpstripe r phpcreate customer stripe phpintegrate stripe in php with taxall in one stripe payment integration php codestripe payment response phpphp stripe send paymentstripe 2fstripe php docinfo customer stripe phppayment with stripe in phpphp stripe payment hold examplestripe web integration phplatest stripe phpstripe subscription payment integration in phpstripe only phphow to implement stripe payment gateway in phpstripe subscription php examplestripe api php create paymentmakey payment with stripe phpstripe elemnts tutorial phpstripe integration php examplesubscritpion payment stripe phpstripe create customer phpstripe checkout payment phpstripe stripe php create sourcestripe how to connect stripe accounthow to integrate stripe payment gateway in to website phpstripe payout phpcharge stripe phpstripe stripe php docsstripe api php examplestripe payment checkout phpstripe paymentintent example phpstripe payment gateway integration in php demohow to rpitn stripe repsonse phpstripe full php etupstripe customer phpstripe integrations phpphp how to get a stripe price objectpay 28 29 php stripestripe php api librarystripe stripe php stripe integrate in phpstripe payment methpdstripe integration custom phphow to integrate stripe in phppayment with stripe in php