javascript - Stripe Wordpress Config -
i'm trying recreate subscription example stripe uses here: https://stripe.com/docs/recipes/subscription-signup
when submit test payment, seems go thru on page, redirects www.mysite.com/create_subscription.php, , throws me 404 page doesn't exist. there easier way without using plugin?
form
<form action="/create_subscription.php" method="post"> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="test-key" data-image="images/marketplace.png" data-name="emma's farm csa" data-description="subscription 1 weekly box" data-amount="2000" data-label="sign me up!"> </script> </form>
server side code
<?php // manually load stripe contents require_once($_server['document_root'] . '/wp-content/themes/theme-name/stripe-php/init.php'); // (switch live key later) \stripe\stripe::setapikey("test-key"); try { $customer = \stripe\customer::create(array( 'email' => $_post['stripeemail'], 'source' => $_post['stripetoken'], 'plan' => 'test-plan(number)' )); header('location: thankyou.html'); exit; } catch(exception $e) { header('location:oops.html'); error_log("unable sign customer:" . $_post['stripeemail']. ", error:" . $e->getmessage()); }
Comments
Post a Comment