$privateSecretStripe, 'pubSecretPayStripe' => $pubSecretPayStripe, 'SESSSION[custId]' => $_SESSION['custId'], 'customer_email' => $_SESSION['adminMail'], 'successUrl' => $successUrl, 'errorUrl' => $errorUrl, 'priceId' => $priceId, 'locale' => $locale, 'host' => $host ],'stripeCheckOutSession.php'); } // ----------------------------------------------------- // On demande et recupere le token // ----------------------------------------------------- \Stripe\Stripe::setApiKey($privateSecretStripe); // ----------------------------------------------------- // On prepare le post // ----------------------------------------------------- if (isset($_SESSION['custId'])) $custID = $_SESSION['custId']; else $custID=''; try { $checkout_session = \Stripe\Checkout\Session::create([ 'success_url' =>$successUrl, 'cancel_url' => $errorUrl, 'payment_method_types' => ["card"], 'mode' => 'subscription', 'client_reference_id' => $_SESSION['custId'], 'customer_email' => $_SESSION['adminMail'], // 'customer' => $custID, 'line_items' => [ ['price' => $priceId,'quantity' => 1], ], 'locale' => $locale, ]); // ----------------------------------------------------- // On envoi le post // ----------------------------------------------------- header("Location: " .$checkout_session->url); exit(); } catch(\Stripe\Exception\CardException $e) { echo 'Status is:' .$e->getHttpStatus() . "\n"; echo 'Type is:' .$e->getError()->type . "\n"; echo 'Code is:' .$e->getError()->code . "\n"; // param is '' in this case echo 'Param is:' .$e->getError()->param . "\n"; echo 'Message is:' .$e->getError()->message . "\n"; } catch (\Stripe\Exception\RateLimitException $e) { echo ' Too many requests made to the API too quickly'; } catch (\Stripe\Exception\InvalidRequestException $e) { echo ' Invalid parameters were supplied to Stripe API (stripeCheckOutSession)'. "\n"; echo 'Param is:' .$e->getError()->param . "\n"; echo 'Message is:' .$e->getError()->message . "\n"; } catch (\Stripe\Exception\AuthenticationException $e) { echo ' Authentication with Stripe API failed '; echo ' maybe you changed API keys recently'; } catch (\Stripe\Exception\ApiConnectionException $e) { echo 'Network communication with Stripe failed'; } catch (\Stripe\Exception\ApiErrorException $e) { echo 'Display a very generic error to the user, and maybe send yourself an email'; } catch (Exception $e) { echo 'Status is : ' .print_r($e). "\n"; } // permet d'avor modifié le header ob_end_flush(); ?>