20 if (!defined(
'NOLOGIN')) define(
"NOLOGIN", 1);
21 if (!defined(
'NOCSRFCHECK')) define(
"NOCSRFCHECK", 1);
22 if (!defined(
'NOIPCHECK')) define(
'NOIPCHECK',
'1');
23 if (!defined(
'NOBROWSERNOTIF')) define(
'NOBROWSERNOTIF',
'1');
25 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
26 if (is_numeric($entity)) define(
"DOLENTITY", $entity);
28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/ccountry.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/includes/stripe/stripe-php/init.php';
40 require_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
46 if (isset($_GET[
'connect']))
48 if (isset($_GET[
'test']))
50 $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY;
51 $service =
'StripeTest';
54 $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY;
55 $service =
'StripeLive';
59 if (isset($_GET[
'test']))
61 $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY;
62 $service =
'StripeTest';
65 $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY;
66 $service =
'StripeLive';
80 $user =
new User($db);
81 $user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS);
88 $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
89 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE;
92 dol_syslog(
"Stripe confirm_payment was called");
97 header(
'Content-Type: application/json');
100 $json_str = file_get_contents(
'php://input');
101 $json_obj = json_decode($json_str);
105 if (isset($json_obj->payment_method_id)) {
107 $intent = \Stripe\PaymentIntent::create(array(
108 'payment_method' => $json_obj->payment_method_id,
111 'confirmation_method' =>
'manual',
115 if (isset($json_obj->payment_intent_id)) {
116 $intent = \Stripe\PaymentIntent::retrieve(
117 $json_obj->payment_intent_id
121 generatePaymentResponse($intent);
122 }
catch (\
Stripe\Error\Base $e) {
124 echo json_encode(array(
125 'error' => $e->getMessage()
135 function generatePaymentResponse($intent)
137 if ($intent->status ==
'requires_source_action' &&
138 $intent->next_action->type ==
'use_stripe_sdk') {
140 echo json_encode(array(
141 'requires_action' =>
true,
142 'payment_intent_client_secret' => $intent->client_secret
144 } elseif ($intent->status ==
'succeeded') {
150 echo json_encode(array(
155 http_response_code(500);
156 echo json_encode(array(
'error' =>
'Invalid PaymentIntent status'));
Class to manage Dolibarr users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...