· 9 years ago · Dec 30, 2016, 04:20 PM
1buynow page
2-------------
3
4<form action="annualForm-submit.php" method="POST">
5 <script
6 src="https://checkout.stripe.com/checkout.js" class="stripe-button"
7 data-key="pk_live_key"
8 data-amount="50"
9 data-name="removed"
10 data-description="1 Ticket"
11 data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
12 data-locale="auto"
13 data-zip-code="true">
14 </script>
15</form>
16
17
18annualForm-submit.php
19----------------------
20
21<?php require_once('config.php'); ?>
22<?php
23
24// Get the credit card details submitted by the form
25$token = $_POST['stripeToken'];
26
27// Create a charge: this will charge the user's card
28try {
29 $charge = \Stripe\Charge::create(array(
30 "amount" => 50, // Amount in cents
31 "currency" => "usd",
32 "source" => $token,
33 "description" => "Example charge"
34 ));
35} catch(\Stripe\Error\Card $e) {
36 // The card has been declined
37}
38
39
40?>
41<meta http-equiv="refresh" content="0; url=annualForm-thanks.php" />
42
43annualForm-thanks.php
44-----------------------
45
46just a thank you page
47
48
49config.php
50--------------
51
52<?php
53require_once('stripe-php-3.1.0/init.php');
54
55$stripe = array(
56 "secret_key" => "sk_live_secret",
57 "publishable_key" => "pk_live_secret"
58);
59
60\Stripe\Stripe::setApiKey($stripe['secret_key']);
61?>