javascript - Same amount charged with multiple stripe checkout forms -




i have 3 checkout forms on webpage let user choose between 3 plans (9,99 - 29,99 - 49,99). each of them processed different php script regardless plan user choosing, last plan being processed (49,99). i'm looking solution solve problem.

thanks

<div class="row m-t-30">      <!--pricing column-->     <article class="pricing-column col-md-4">         <div class="inner-box">             <div class="plan-header text-center">                 <h3 class="plan-title">up 10 members</h3>                 <h2 class="plan-price">9.99€</h2>                 <div class="plan-duration">per month</div>             </div>             <div class="text-center">                 <form id="formplan1" action="scripts/process-payment-plan1.php" method="post">                     <input type="hidden" id="stripetoken1" name="stripetoken1" />                     <input type="hidden" id="stripeemail1" name="stripeemail1" />                     <script src="https://checkout.stripe.com/checkout.js"></script>                     <button id="pay1" class="btn btn-custom btn-bordred waves-effect waves-light">choose plan</button>                     <script>                         var handler = stripecheckout.configure({                             key: 'pk_test_fc2ywheqja93ffr0mlnkraw4',                             image: '../assets/img/logos/logo_1_01.png',                             locale: 'auto',                             token: function(token) {                                 $("#stripetoken1").val(token.id);                                 $("#stripeemail1").val(token.email);                                 $("#formplan1").submit();                                 // can access token id `token.id`.                                 // token id server-side code use.                             }                         });                          document.getelementbyid('pay1').addeventlistener('click', function(e) {                             // open checkout further options:                             handler.open({                                 name: 'subscription',                                 description: 'up 10 members',                                 zipcode: false,                                 amount: 999,                                 currency: 'eur',                                 allowrememberme: true,                                 email: '<?php echo $userinfo['                                 useremail '] ;?>',                             });                             e.preventdefault();                         });                          // close checkout on page navigation:                         window.addeventlistener('popstate', function() {                             handler.close();                         });                     </script>                 </form>             </div>         </div>     </article>      <!--pricing column-->     <article class="pricing-column col-md-4">         <div class="inner-box">             <div class="plan-header text-center">                 <h3 class="plan-title">from 11 40 members</h3>                 <h2 class="plan-price">29.99€</h2>                 <div class="plan-duration">per month</div>             </div>             <div class="text-center">                 <form id="formplan2" action="scripts/process-payment-plan2.php" method="post">                     <input type="hidden" id="stripetoken2" name="stripetoken2" />                     <input type="hidden" id="stripeemail2" name="stripeemail2" />                     <script src="https://checkout.stripe.com/checkout.js"></script>                     <button id="pay2" class="btn btn-custom btn-bordred waves-effect waves-light">choose plan</button>                     <script>                         var handler = stripecheckout.configure({                             key: 'pk_test_fc2ywheqja93ffr0mlnkraw4',                             image: '../assets/img/logos/logo_1_01.png',                             locale: 'auto',                             token: function(token) {                                 $("#stripetoken2").val(token.id);                                 $("#stripeemail2").val(token.email);                                 $("#formplan2").submit();                                 // can access token id `token.id`.                                 // token id server-side code use.                             }                         });                          document.getelementbyid('pay2').addeventlistener('click', function(e) {                             // open checkout further options:                             handler.open({                                 name: 'subscription',                                 description: 'from 11 40 members',                                 zipcode: false,                                 amount: 2999,                                 currency: 'eur',                                 allowrememberme: true,                                 email: '<?php echo $userinfo['                                 useremail '] ;?>',                             });                             e.preventdefault();                         });                          // close checkout on page navigation:                         window.addeventlistener('popstate', function() {                             handler.close();                         });                     </script>                 </form>             </div>         </div>     </article>      <!--pricing column-->     <article class="pricing-column col-md-4">         <div class="inner-box">             <div class="plan-header text-center">                 <h3 class="plan-title">from 41 100 members</h3>                 <h2 class="plan-price">49.99€</h2>                 <div class="plan-duration">per month</div>             </div>             <div class="text-center">                 <form id="formplan3" action="scripts/process-payment-plan3.php" method="post">                     <input type="hidden" id="stripetoken3" name="stripetoken3" />                     <input type="hidden" id="stripeemail3" name="stripeemail3" />                     <script src="https://checkout.stripe.com/checkout.js"></script>                     <button id="pay3" class="btn btn-custom btn-bordred waves-effect waves-light">choose plan</button>                     <script>                         var handler = stripecheckout.configure({                             key: 'pk_test_fc2ywheqja93ffr0mlnkraw4',                             image: '../assets/img/logos/logo_1_01.png',                             locale: 'auto',                             token: function(token) {                                 $("#stripetoken3").val(token.id);                                 $("#stripeemail3").val(token.email);                                 $("#formplan3").submit();                                 // can access token id `token.id`.                                 // token id server-side code use.                             }                         });                          document.getelementbyid('pay3').addeventlistener('click', function(e) {                             // open checkout further options:                             handler.open({                                 name: 'subscription',                                 description: 'from 41 100 members',                                 zipcode: false,                                 amount: 4999,                                 currency: 'eur',                                 allowrememberme: true,                                 email: '<?php echo $userinfo['                                 useremail '] ;?>',                             });                             e.preventdefault();                         });                          // close checkout on page navigation:                         window.addeventlistener('popstate', function() {                             handler.close();                         });                     </script>                 </form>             </div>         </div>     </article>  </div> 

providing form handling through php

for form 1

   <?php // create customer using stripe token     require('../../stripe/init.php');     // sure replace actual test api key     // (switch live key later)     \stripe\stripe::setapikey("sk_test_saoftrf7qsqgjifa9swn33cw");      try     {       $customer = \stripe\customer::create(array(         'email' => $_post['stripeemail1'],         'source'  => $_post['stripetoken1'],         'plan' => '1'       ));        echo "payment processed";       //exit;     }     catch(exception $e)     {       echo "problem during payment processing<br>";       echo $e->getmessage();       //header('location:oops.html');       error_log("unable sign customer:" . $_post['stripeemail'].         ", error:" . $e->getmessage());     } ?> 

for form 2

    <?php // create customer using stripe token require('../../stripe/init.php');   // sure replace actual test api key // (switch live key later) \stripe\stripe::setapikey("sk_test_saoftrf7qsqgjifa9swn33cw");  try {   $customer = \stripe\customer::create(array(     'email' => $_post['stripeemail2'],     'source'  => $_post['stripetoken2'],     'plan' => 'plan2'   ));    echo "payment processed";   //exit; } catch(exception $e) {   echo "problem during payment processing<br>";   echo $e->getmessage();   //header('location:oops.html');   error_log("unable sign customer:" . $_post['stripeemail'].     ", error:" . $e->getmessage()); } ?> 

for form 3

    <?php // create customer using stripe token require('../../stripe/init.php');   // sure replace actual test api key // (switch live key later) \stripe\stripe::setapikey("sk_test_saoftrf7qsqgjifa9swn33cw");  try {   $customer = \stripe\customer::create(array(     'email' => $_post['stripeemail3'],     'source'  => $_post['stripetoken3'],     'plan' => 'plan3'   ));    echo "payment processed";   //exit; } catch(exception $e) {   echo "problem during payment processing<br>";   echo $e->getmessage();   //header('location:oops.html');   error_log("unable sign customer:" . $_post['stripeemail'].     ", error:" . $e->getmessage()); } ?> 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -