62 lines
2.1 KiB
PHP
Executable File
62 lines
2.1 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
// -----------------------------------------------------
|
|
// debug
|
|
// -----------------------------------------------------
|
|
if (isset($debug[1]) && $debug[1] == '1') { $debugMsg= .= monDebug (1, [
|
|
'privateSecretStripe' => $privateSecretStripe,
|
|
'pubSecretPayStripe' => $pubSecretPayStripe,
|
|
'SESSSION[custId]' => $_SESSION['custId']
|
|
],'stripePortalCreateSession.php');
|
|
}
|
|
try {
|
|
// -----------------------------------------
|
|
// Portal
|
|
// -----------------------------------------
|
|
\Stripe\Stripe::setApiKey($privateSecretStripe);
|
|
// $stripe = new \Stripe\StripeClient($privateSecretStripe);
|
|
header('Content-Type: application/json');
|
|
$return_url = $_SESSION['server']. '/admin/frmAdmin.php?affAdmin=17®lageExtension=1&codeRetourPaiement=2&checkOutSession_id={CHECKOUT_SESSION_ID}';
|
|
|
|
|
|
$portal = \Stripe\BillingPortal\Session::create([
|
|
'customer' => $_SESSION['custId'],
|
|
'return_url' => $return_url,
|
|
]);
|
|
// header("HTTP/1.1 303 See Other");
|
|
header("Location: " . $portal->url);
|
|
$checkOutPortal_id=$portal->id;
|
|
$_SESSION['checkOutPortal_id']=$checkOutPortal_id;
|
|
}
|
|
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 (stripePortalSession.php) ';
|
|
}
|
|
|
|
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';
|
|
}
|
|
|
|
exit();
|
|
?>
|