From b78eebaae279df5a8817bd12f360e8d57112707c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Jan 2023 12:44:56 +0100 Subject: [PATCH] Clean code --- htdocs/langs/en_US/stripe.lang | 10 +++++--- htdocs/stripe/admin/stripe.php | 37 +++++++++++----------------- htdocs/stripe/class/stripe.class.php | 33 +++++++++++++++++++++---- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 2a3f988cebf..b5dbfd656b6 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -41,7 +41,8 @@ STRIPE_LIVE_WEBHOOK_KEY=Webhook live key ONLINE_PAYMENT_WAREHOUSE=Stock to use for stock decrease when online payment is done
(TODO When option to decrease stock is done on an action on invoice and the online payment generate itself the invoice ?) StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode) StripeImportPayment=Import Stripe payments -ExampleOfTestCreditCard=Example of credit card for test: %s => valid, %s => error CVC, %s => expired, %s => charge fails +ExampleOfTestCreditCard=Example of credit card for SEPA test: %s => valid, %s => error CVC, %s => expired, %s => charge fails +ExampleOfTestBankAcountForSEPA=Example of bank account BAN for direct debit test: %s StripeGateways=Stripe gateways OAUTH_STRIPE_TEST_ID=Stripe Connect Client ID (ca_...) OAUTH_STRIPE_LIVE_ID=Stripe Connect Client ID (ca_...) @@ -70,5 +71,8 @@ ToOfferALinkForLiveWebhook=Link to setup Stripe WebHook to call the IPN (live mo PaymentWillBeRecordedForNextPeriod=Payment will be recorded for the next period. ClickHereToTryAgain=Click here to try again... CreationOfPaymentModeMustBeDoneFromStripeInterface=Due to Strong Customer Authentication rules, creation of a card must be done from Stripe backoffice. You can click here to switch on Stripe customer record: %s -TERMINAL_LOCATION=Location (address) for terminals -RequestDirectDebitWithStripe=Request Direct Debit with Stripe \ No newline at end of file +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 diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index b115d0453f0..11fb6c6e442 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -427,31 +427,16 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print ''; } -// Activate Payment Request API -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code - print ''; - print $langs->trans("STRIPE_PAYMENT_REQUEST_API").' ?? Not used, what is it for ??'; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, getDolGlobalString('STRIPE_PAYMENT_REQUEST_API')); - } - print ''; +print ''; +print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT')); } +print ''; -// Activate SEPA DIRECT_DEBIT -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code - print ''; - print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT')); - } - print ''; -} // Activate Klarna if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code @@ -608,6 +593,12 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php'; print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required, the off-session allowed)', '4000000000000101', '4000000000000069', '4000000000000341')); +if (getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT')) { + print info_admin($langs->trans("ExampleOfTestBankAcountForSEPA", 'AT611904300234573201 (pending->succeed) or AT861904300235473202 (pending->failed)')); +} + + + if (!empty($conf->use_javascript_ajax)) { print "\n".'