I'm a little confused on how to process a subscription + fees payment with Stripe,
Here's what I got:
HTML:
<form id="req" action="/thank-you" method="post">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_RrE21sY9Xbtwq9ZvbKPpp0LJ"
data-name="Wizard.Build Hosting Package"
data-description=""
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto"
data-currency="usd">
</script>
...
Thank you page:
require_once('lib-stripe/init.php');
// create api key
\Stripe\Stripe::setApiKey("sk_TESTING");
// create customer
$customerO =\Stripe\Customer::create(array(
"email" => $_POST["e"]
));
$customer = $customerO->jsonSerialize();
//var_dump($customer);
//create subscription (Package Bronze, Silver or Gold)
$subscriptionO = \Stripe\Subscription::create(array(
"customer" => $customer["id"],
"items" => array(
array(
"plan" => $_POST["pack"],
),
)
));
$subscription = $subscriptionO->jsonSerialize();
//var_dump($subscription);
//create invoice (3rdparty cost)
$invoiceO = \Stripe\Invoice::create(array(
"customer" => $customer["id"],
"amount" =>$p3price,
"currency" => "usd",
"description" => "3rdp Cost",
"subscription" => $subscription["id"]
));
$invoice = $invoiceO->jsonSerialize();
//var_dump($invoice);
I'm clearly missing how the whole process work...
I will populate the email field, but how can I request a setup fees + subscription re-occurring every month in that popup form?
Ideally the workflow is as follows:
My Website page with form: User fills name, email, item name [need this meta data], item price, package name[need this meta data], package price
hits submit button, Stripe popup form appears prepopulated with email, user agrees to package monthly payment + item price, user enters card info, user submits stripe form,
user is now charged with 1st month of package + item price, payments will occur every month for package automatically.
return to a url with all metadata, prices, package, etc, with secret code or some kind of security form field, then I process order automatically from the return url data,
Please help, thanks community!