php - Send custom data via stripe.js -
path custom data stripe.js
i have 3 subscription courses, made 3 button such.
index.html.twig
<form action="{{ path('acme_payment_charge') }}" method="post"> <input type="hidden" name="plan" value="basic"><!-- wish works.--> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_fpfpjy1etetetetetete" data-amount="2980" data-name="basic" data-description="testtest" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-locale="ja" data-currency="jpy"> </script> <form action="{{ path('acme_payment_charge') }}" method="post"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_fpfpjy1etetetetetete" data-amount="2980" data-name="standard" data-description="testtest" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-locale="ja" data-currency="jpy"> </script> <form action="{{ path('acme_payment_charge') }}" method="post"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_fpfpjy1ertetetetetete" data-amount="2980" data-name="professional" data-description="testtest" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-locale="ja"> data-currency="jpy"> </script>
i catch request here in php, know button selected.
is possible send custom data via stripe.js??
(or if data-name
passed index.html.twig script.js in php.)
defaultcontroller.php
public function chargeaction(request $request){ var_dump($request) // there not either 'basic','standard' nor 'professional'. //only 'stripetoken','stripetokentype','stripeemail' returned. \stripe\stripe::setapikey("sk_test_xltetetetetete"); $token = $request->request->get('stripetoken'); $customer = \stripe\customer::create(array( "email" => $request->request->get('stripeemail'), "source" => $request->request->get('stripetoken'), "plan" => "professional" // want change here dynamically. ));
Comments
Post a Comment