diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang
index f5b5d3fca91..50f3e8325a7 100644
--- a/htdocs/langs/en_US/stripe.lang
+++ b/htdocs/langs/en_US/stripe.lang
@@ -75,4 +75,4 @@ STRIPE_CARD_PRESENT=Card Present for Stripe Terminals
TERMINAL_LOCATION=Location (address) for Stripe Terminals
RequestDirectDebitWithStripe=Request Direct Debit with Stripe
STRIPE_SEPA_DIRECT_DEBIT=Enable the Direct Debit payments through Stripe
-
\ No newline at end of file
+StripeConnect_Mode=Stripe Connect mode
\ No newline at end of file
diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php
index 332f05aad5d..98c5757699a 100644
--- a/htdocs/stripe/admin/stripe.php
+++ b/htdocs/stripe/admin/stripe.php
@@ -243,26 +243,34 @@ if (empty($conf->stripeconnect->enabled)) {
print '
';
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID)) {
- \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
- $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
- $endpoint->enabled_events = $stripearrayofwebhookevents;
- if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
- if (!GETPOST('status', 'alpha')) {
- $endpoint->disabled = true;
- } else {
- $endpoint->disabled = false;
+ if (utf8_check($conf->global->STRIPE_TEST_SECRET_KEY)) {
+ try {
+ \Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
+ $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
+ $endpoint->enabled_events = $stripearrayofwebhookevents;
+ if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
+ if (!GETPOST('status', 'alpha')) {
+ $endpoint->disabled = true;
+ } else {
+ $endpoint->disabled = false;
+ }
+ }
+ $endpoint->url = $url;
+ $endpoint->save();
+
+ if ($endpoint->status == 'enabled') {
+ print '';
+ print img_picto($langs->trans("Activated"), 'switch_on');
+ } else {
+ print '';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ }
+ } catch (Exception $e) {
+ print $e->getMessage();
}
- }
- $endpoint->url = $url;
- $endpoint->save();
- if ($endpoint->status == 'enabled') {
- print '';
- print img_picto($langs->trans("Activated"), 'switch_on');
} else {
- print '';
- print img_picto($langs->trans("Disabled"), 'switch_off');
+ print 'Bad value for the secret key. Reenter and save it again to fix this.';
}
- //print $endpoint;
} else {
print img_picto($langs->trans("Inactive"), 'statut5');
}
@@ -307,37 +315,38 @@ if (empty($conf->stripeconnect->enabled)) {
print ' | ';
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID)) {
- \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
- $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
- $endpoint->enabled_events = $stripearrayofwebhookevents;
- if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID) {
- if (empty(GETPOST('status', 'alpha'))) {
- $endpoint->disabled = true;
- } else {
- $endpoint->disabled = false;
+ if (utf8_check($conf->global->STRIPE_TEST_SECRET_KEY)) {
+ try {
+ \Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
+ $endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
+ $endpoint->enabled_events = $stripearrayofwebhookevents;
+ if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID) {
+ if (empty(GETPOST('status', 'alpha'))) {
+ $endpoint->disabled = true;
+ } else {
+ $endpoint->disabled = false;
+ }
+ }
+ $endpoint->url = $url;
+ $endpoint->save();
+ if ($endpoint->status == 'enabled') {
+ print '';
+ print img_picto($langs->trans("Activated"), 'switch_on');
+ } else {
+ print '';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ }
+ } catch (Exception $e) {
+ print $e->getMessage();
}
}
- $endpoint->url = $url;
- $endpoint->save();
- if ($endpoint->status == 'enabled') {
- print '';
- print img_picto($langs->trans("Activated"), 'switch_on');
- } else {
- print '';
- print img_picto($langs->trans("Disabled"), 'switch_off');
- }
- //print $endpoint;
} else {
print img_picto($langs->trans("Inactive"), 'statut5');
}
}
print ' | ';
-} else {
- print '| '.$langs->trans("StripeConnect").' | ';
- print ''.$langs->trans("StripeConnect_Mode").' | |
';
}
-
print '';
print '';