-5

I have some basic PHP skills and I'm reading through the Stripe documentation, I want to charge customers $500 upfront and automatically enroll them into a $49/month subscription plan... I want this to be a button on my website. Seems to be a big lack of info on this extremely common payment situation.

Thanks in advance for any help!

Steve H
  • 21
  • 1
  • 4
  • 2
    we are not going to write the whole thing for you. –  Mar 21 '17 at 20:54
  • how are there no scripts for this from Stripe or on youtube etc? this seems like it is something standard that Stripe should provide a script for. You're making this sound like something totally custom, am I missing something? – Steve H Mar 21 '17 at 21:08

1 Answers1

1

Log into Stripe and you can create the plan. You set up the amount, recurring frequency, etc there.

You then use Stripe Checkout to create a button - https://stripe.com/docs/checkout - when the user clicks the button then this triggers the Stripe payment screen. Set the form action to point to your PHP script.

In here you'll need to take the stripeEmail and stripeToken that is passed back from Stripe. Also specify the ID of the package ($_POST['package'] in my example).

You'll also need to include the Stripe SDK - you can get this from https://github.com/stripe/stripe-php/releases

require_once('common/stripe/init.php');

$payment = array();
$payment['email'] = $_POST['stripeEmail'];
$payment['source'] = $_POST['stripeToken'];
$payment['plan'] = $_POST['package'];

\Stripe\Stripe::setApiKey("sk_live_xxxxxxxxxxxxxxxx");

try
{
  $customer = \Stripe\Customer::create($payment);
}
catch(Exception $e)
{
   echo 'error';
}

Hope this is enough to get you started. Good luck.

Chris
  • 4,672
  • 13
  • 52
  • 93