$successUrl, 'cancel_url' => $errorUrl, 'payment_method_types' => ["card"], 'mode' => 'payment', 'client_reference_id' => $_SESSION['custId'], 'customer' => $_SESSION['custId'], 'line_items' => [ [ 'price' => $priceId,'quantity' => 1, ], ], 'locale' => $locale, ]); // ----------------------------------------------------- // On envoi le post // ----------------------------------------------------- header("Location: " .$checkout_session->url); } 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 (checkOutSessionAchatUnique.php)'; 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"; } ?>