From d1c49c70210c0825208fd0c21f796d41d7523433 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Nov 2019 10:24:03 +0100 Subject: [PATCH] Fix trans --- htdocs/core/lib/payments.lib.php | 9 ++++++- htdocs/langs/en_US/paybox.lang | 1 - htdocs/langs/en_US/stripe.lang | 2 +- htdocs/public/payment/newpayment.php | 36 +++++++--------------------- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 75e2ee08b8f..568da82368f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -97,22 +97,28 @@ function payment_supplier_prepare_head(Paiement $object) */ function getValidOnlinePaymentMethods($paymentmethod = '') { - global $conf; + global $conf, $langs; $validpaymentmethod=array(); if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) { + $langs->load("paypal"); $validpaymentmethod['paypal']='valid'; } if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) { + $langs->load("paybox"); $validpaymentmethod['paybox']='valid'; } if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { + $langs->load("stripe"); $validpaymentmethod['stripe']='valid'; } + // TODO Add trigger + + return $validpaymentmethod; } @@ -173,6 +179,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } + //if ($mode) $out.='&noidempotency=1'; } elseif ($type == 'order') { diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index 35216661140..ec722c990a4 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -20,7 +20,6 @@ ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription ToOfferALinkForOnlinePaymentOnDonation=URL to offer a %s online payment, user interface for payment of donation -YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. SetupPayBoxToHavePaymentCreatedAutomatically=Setup your Paybox with url %s to have payment created automatically when validated by Paybox. YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you. YourPaymentHasNotBeenRecorded=Your payment has NOT been recorded and the transaction has been canceled. Thank you. diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 6905bd41b20..583ef309727 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -21,7 +21,7 @@ ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment user inte ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user interface for a contract line ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription -YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. +YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (mandatory only for free payment) to add your own payment comment tag.
For free payment, you may also add the parameter &noidempotency=1 so the same link with same tag can be used several times (some payment mode may limit the payment to 1 for each different link without this parameter) SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url %s to have payment created automatically when validated by Stripe. AccountParameter=Account parameters UsageParameter=Usage parameters diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 4a3d08f6602..d292809eda8 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -63,10 +63,10 @@ $action=GETPOST('action', 'aZ09'); // tag (a free text, required if type is empty) // currency (iso code) -$suffix=GETPOST("suffix", 'aZ09'); -$amount=price2num(GETPOST("amount", 'alpha')); -if (! GETPOST("currency", 'alpha')) $currency=$conf->currency; -else $currency=GETPOST("currency", 'alpha'); +$suffix = GETPOST("suffix", 'aZ09'); +$amount = price2num(GETPOST("amount", 'alpha')); +if (! GETPOST("currency", 'alpha')) $currency = $conf->currency; +else $currency = GETPOST("currency", 'alpha'); $source = GETPOST("s", 'alpha')?GETPOST("s", 'alpha'):GETPOST("source", 'alpha'); $download = GETPOST('d', 'int')?GETPOST('d', 'int'):GETPOST('download', 'int'); @@ -159,7 +159,7 @@ $urlko=preg_replace('/&$/', '', $urlko); // Remove last & -// Find valid payment methods +// Make special controls if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled)) { @@ -186,36 +186,18 @@ if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->payp dol_print_error('', "Paypal setup param PAYPAL_API_SIGNATURE not defined"); return -1; } - - $validpaymentmethod['paypal']='valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled)) { - $langs->load("paybox"); - - // TODO Chek setup is complete - - $validpaymentmethod['paybox']='valid'; + // No specific test for the moment } - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled)) { - $langs->load("stripe"); - - require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; - /* already included into /stripe/config.php - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; - */ - - $validpaymentmethod['stripe']='valid'; + require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This include also /stripe/lib/stripe.lib.php, /includes/stripe/init.php, ... } -// TODO Replace previous set of $validpaymentmethod with this line: -//$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); +// Initialize $validpaymentmethod +$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); // Check security token