#funk101

1 messages · Page 1 of 1 (latest)

latent sunBOT
mighty basin
#

It seems the mode should be kept at payment because the customer is purchasing a "product" which "is a subscription", correct?

blissful frost
mighty basin
#

but why would I create the subscription product in stripe dashboard then?

#

it seems if I create a subscription product in the Stripe dashboard, then the user is actually PURCHASING a "subscription product". Which the Stripe would recur that payment every billing cycle, no?

blissful frost
mighty basin
#

ok, so when I follow that doc and set "mode" => "subscription" it has failed

blissful frost
mighty basin
#

don't have it

#

I guess I'll try switching the mode again

#

see if it fails again and get request

#

this is my code:

#
require_once('vendor/autoload.php');
require_once('include/Common.inc.php');
extract($_POST);
/*
echo '<pre>'.var_dump($_POST).'</pre>';
exit;
*/
\Stripe\Stripe::setApiKey(STRIPE_SECRET_KEY);

header('Content-Type: application/json');

$checkout_session = \Stripe\Checkout\Session::create([
  'payment_method_types' => ['card'],
  'line_items' => [[
    'price_data' => [
        'product_data' => [
                'name' => $subscription_name
        ],
        'currency' => 'usd',
        'unit_amount' => $subscription_price
        ],
    'quantity' => 1
  ]],
  'mode' => 'subscription',
  'success_url' => BASE_URL.'/checkout-complete.php',
  'cancel_url' => BASE_URL.'/checkout-cancelled.php'
]);
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);
blissful frost
#

You can share any object id that is failing so I can further review this on my end

mighty basin
#

yes it fails again

blissful frost
#

What is the error?

mighty basin
#
This page isn’t workingstaging.lacgroup.com is currently unable to handle this request.
HTTP ERROR 500```
blissful frost
#

Can you share the checkout session id?

mighty basin
#

hmm, no

#

must be something wrong in script, like a typo, does that script look right?

#

this script works fine with mode => payment

#

it needs a price_id

#

"mode" => "subscription" needs a "price_id" parameter

blissful frost
mighty basin
#

thanks