From d3627c143808a01ba73979876ec05686e0b77216 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 15:49:54 +0100 Subject: [PATCH 1/8] NEW options for alternative method payment request api (ex apple pay) and sepa direct debit --- htdocs/stripe/admin/stripe.php | 56 ++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 100a85f6c30..056c993bcec 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov - * Copyright (C) 2018 ptibogxiv + * Copyright (C) 2018-2019 Thibault FOUCART * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -78,9 +78,6 @@ if ($action == 'setvalue' && $user->admin) $result = dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS", GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 'int'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; - $result = dolibarr_set_const($db, "STRIPE_MINIMAL_3DSECURE", GETPOST('STRIPE_MINIMAL_3DSECURE', 'int'), 'chaine', 0, '', $conf->entity); - if (! $result > 0) - $error ++; $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); if (! $result > 0) $error ++; @@ -166,17 +163,11 @@ print "\n"; print ''; print ''; print $langs->trans("StripeLiveEnabled").''; -if (!empty($conf->global->STRIPE_LIVE)) -{ - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; -} -else -{ - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_LIVE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); } print ''; @@ -272,16 +263,36 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? print ''; } -// Minimal amount for force 3Dsecure if it's optionnal +// 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").''; + 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, $conf->global->STRIPE_PAYMENT_REQUEST_API); +} + print ''; +} + +// Activate SEPA DIRECT_DEBIT if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code { print ''; - print $langs->trans("STRIPE_MINIMAL_3DSECURE").''; - print ''.$langs->getCurrencySymbol($conf->currency).''; + 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, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); +} + print ''; } // Warehouse for automatic decrement -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment { print ''; print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; @@ -329,7 +340,12 @@ print ''; print ''; print $langs->trans("SecurityTokenIsUnique").''; -print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE", (empty($conf->global->PAYMENT_SECURITY_TOKEN)?0:$conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE), 1); +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PAYMENT_SECURITY_TOKEN_UNIQUE'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE); +} print ''; print ''; From 97620e91c948c65808ea01cd490a0d3eaa0fccc5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 16:31:39 +0100 Subject: [PATCH 2/8] add link to webhook --- htdocs/stripe/admin/stripe.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 056c993bcec..dc63efbd99b 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2017 Olivier Geffroy * Copyright (C) 2017 Saasprov - * Copyright (C) 2018-2019 Thibault FOUCART + * Copyright (C) 2018 ptibogxiv * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -186,9 +186,14 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''; - print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; + print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; + $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForTestWebhook").'
'; + $url = dol_buildpath('/public/stripe/ipn.php?test', 2); + $out.= ''; + $out.= ajax_autoselect("onlinetestwebhookurl", 0); + print '
'.$out; print ''; } else { print ''.$langs->trans("StripeConnect").''; @@ -216,9 +221,14 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''; - print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; + print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; + $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForLiveWebhook").'
'; + $url = dol_buildpath('/public/stripe/ipn.php', 2); + $out.= ''; + $out.= ajax_autoselect("onlinelivewebhookurl", 0); + print '
'.$out; print ''; } else From 8e55802e92e55aa321dabc971dc8dc4050fc70e2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 19:40:47 +0100 Subject: [PATCH 3/8] Update stripe.php --- htdocs/stripe/admin/stripe.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index dc63efbd99b..ac86a893903 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -165,7 +165,7 @@ print ''; print $langs->trans("StripeLiveEnabled").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_LIVE'); -} else { + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); } @@ -193,7 +193,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php?test', 2); $out.= ''; $out.= ajax_autoselect("onlinetestwebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else { print ''.$langs->trans("StripeConnect").''; @@ -228,7 +228,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php', 2); $out.= ''; $out.= ajax_autoselect("onlinelivewebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else @@ -280,7 +280,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print $langs->trans("STRIPE_PAYMENT_REQUEST_API").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); -} else { + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); } @@ -294,7 +294,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); -} else { + } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); } From ea6e397d18a9bffc78d5e943e739151a9441295a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 22:28:26 +0100 Subject: [PATCH 4/8] Update stripe.php --- htdocs/stripe/admin/stripe.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index ac86a893903..4a3b189a71e 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -168,7 +168,7 @@ print $langs->trans("StripeLiveEnabled").''; } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); -} + } print ''; if (empty($conf->stripeconnect->enabled)) @@ -282,8 +282,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code 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, $conf->global->STRIPE_PAYMENT_REQUEST_API); -} + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API): + } print ''; } @@ -297,7 +297,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); -} + } print ''; } From 0a3e0bc2682592987b24c2f083a000f1f8d64b03 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 22:56:07 +0100 Subject: [PATCH 5/8] Update stripe.php --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 4a3b189a71e..46c12801c51 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -282,7 +282,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code 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, $conf->global->STRIPE_PAYMENT_REQUEST_API): + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); } print ''; } From 0af6426f8c7ec6fb924e35eafafd6612c02b46dc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 19 Feb 2019 23:36:59 +0100 Subject: [PATCH 6/8] Update stripe.php --- htdocs/stripe/admin/stripe.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 46c12801c51..172e1897417 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -193,7 +193,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php?test', 2); $out.= ''; $out.= ajax_autoselect("onlinetestwebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else { print ''.$langs->trans("StripeConnect").''; @@ -228,7 +228,7 @@ if (empty($conf->stripeconnect->enabled)) $url = dol_buildpath('/public/stripe/ipn.php', 2); $out.= ''; $out.= ajax_autoselect("onlinelivewebhookurl", 0); - print '
'.$out; + print '
'.$out; print ''; } else From 0428e026c9a53c8a5ab0e04ecf7d78b2520b60be Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 21 Feb 2019 15:08:19 +0100 Subject: [PATCH 7/8] Update stripe.php --- htdocs/stripe/admin/stripe.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 172e1897417..0c6e195910d 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -187,7 +187,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; - print ''; + print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForTestWebhook").'
'; $url = dol_buildpath('/public/stripe/ipn.php?test', 2); @@ -222,7 +222,7 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; - print ''; + print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForLiveWebhook").'
'; $url = dol_buildpath('/public/stripe/ipn.php', 2); From 6ba5708814627d346a3cf1d8d0a7c7d2e500c368 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 23 Feb 2019 19:26:52 +0100 Subject: [PATCH 8/8] disable online payment warehouse --- htdocs/stripe/admin/stripe.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 0c6e195910d..5e2c27dd392 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -94,9 +94,9 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error ++; // Stock decrement - $result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); - if (! $result > 0) - $error ++; + //$result = dolibarr_set_const($db, "ONLINE_PAYMENT_WAREHOUSE", (GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity); + //if (! $result > 0) + // $error ++; // Payment token for URL $result = dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN", GETPOST('PAYMENT_SECURITY_TOKEN', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -302,13 +302,13 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code } // Warehouse for automatic decrement -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment -{ - print ''; - print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; - print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE, 'ONLINE_PAYMENT_WAREHOUSE', '', 1, $disabled); - print ''; -} +//if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment +//{ +// print ''; +// print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").''; +// print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE, 'ONLINE_PAYMENT_WAREHOUSE', '', 1, $disabled); +// print ''; +//} print ''; print $langs->trans("CSSUrlForPaymentForm").'';