Example 1: payment with stripe in php


use \PhpPot\Service\StripePayment;

if (!empty($_POST["token"])) {
    require_once 'StripePayment.php';
    $stripePayment = new StripePayment();
    
    $stripeResponse = $stripePayment->chargeAmountFromCard($_POST);
    
    require_once "DBController.php";
    $dbController = new DBController();
    
    $amount = $stripeResponse["amount"] /100;
    
    $param_type = 'ssdssss';
    $param_value_array = array(
        $_POST['email'],
        $_POST['item_number'],
        $amount,
        $stripeResponse["currency"],
        $stripeResponse["balance_transaction"],
        $stripeResponse["status"],
        json_encode($stripeResponse)
    );
    $query = "INSERT INTO tbl_payment (email, item_number, amount, currency_code, txn_id, payment_status, payment_response) values (?, ?, ?, ?, ?, ?, ?)";
    $id = $dbController->insert($query, $param_type, $param_value_array);
    
    if ($stripeResponse['amount_refunded'] == 0 && empty($stripeResponse['failure_code']) && $stripeResponse['paid'] == 1 && $stripeResponse['captured'] == 1 && $stripeResponse['status'] == 'succeeded') {
       $successMessage = "Stripe payment is completed successfully. The TXN ID is " . $stripeResponse["balance_transaction"];
    }
}
?>

Example 2: payment with stripe in php

 if(!empty($successMessage)) { ?>
<div id="success-message"> echo $successMessage; ?>div>
  } ?>
<div id="error-message">div>

<form id="frmStripePayment" action="" method="post">
    <div class="field-row">
        <label>Card Holder Namelabel> <span id="card-holder-name-info"
            class="info">span><br> <input type="text" id="name"
            name="name" class="demoInputBox">
    div>
    <div class="field-row">
        <label>Emaillabel> <span id="email-info" class="info">span><br>
        <input type="text" id="email" name="email" class="demoInputBox">
    div>
    <div class="field-row">
        <label>Card Numberlabel> <span id="card-number-info"
            class="info">span><br> <input type="text" id="card-number"
            name="card-number" class="demoInputBox">
    div>
    <div class="field-row">
        <div class="contact-row column-right">
            <label>Expiry Month / Yearlabel> <span id="userEmail-info"
                class="info">span><br> <select name="month" id="month"
                class="demoSelectBox">
                <option value="08">08option>
                <option value="09">9option>
                <option value="10">10option>
                <option value="11">11option>
                <option value="12">12option>
            select> <select name="year" id="year"
                class="demoSelectBox">
                <option value="18">2018option>
                <option value="19">2019option>
                <option value="20">2020option>
                <option value="21">2021option>
                <option value="22">2022option>
                <option value="23">2023option>
                <option value="24">2024option>
                <option value="25">2025option>
                <option value="26">2026option>
                <option value="27">2027option>
                <option value="28">2028option>
                <option value="29">2029option>
                <option value="30">2030option>
            select>
        div>
        <div class="contact-row cvv-box">
            <label>CVClabel> <span id="cvv-info" class="info">span><br>
            <input type="text" name="cvc" id="cvc"
                class="demoInputBox cvv-input">
        div>
    div>
    <div>
        <input type="submit" name="pay_now" value="Submit"
            id="submit-btn" class="btnAction"
            onClick="stripePay(event);">

        <div id="loader">
            <img alt="loader" src="LoaderIcon.gif">
        div>
    div>
    <input type='hidden' name='amount' value='0.5'> <input type='hidden'
        name='currency_code' value='USD'> <input type='hidden'
        name='item_name' value='Test Product'> <input type='hidden'
        name='item_number' value='PHPPOTEG#1'>
form>