diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 70f3e87eaf979..b73d59c6cfdc2 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -142,23 +142,32 @@ function showOnlinePaymentUrl($type, $ref) /** * Return string with full Url * - * @param int $mode 0=True url, 1=Url formated with colors - * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) - * @param string $ref Ref of object - * @param int $amount Amount (required for $type='free' only) - * @param string $freetag Free tag - * @return string Url string + * @param int $mode 0=True url, 1=Url formated with colors + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param int $amount Amount (required for $type='free' only) + * @param string $freetag Free tag + * @param string $localorexternal 0=Url for browser, 1=Url for external access + * @return string Url string */ -function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag') +function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag', $localorexternal=0) { - global $conf; + global $conf, $dolibarr_main_url_root; $ref=str_replace(' ', '', $ref); $out=''; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urltouse = DOL_MAIN_URL_ROOT; + if ($localorexternal) $urltouse = $urlwithroot; + if ($type == 'free') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?amount='.($mode?'':'').$amount.($mode?'':'').'&tag='.($mode?'':'').$freetag.($mode?'':''); if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; @@ -167,7 +176,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'order') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode?'':''); if ($mode == 1) $out.='order_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -185,7 +194,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'invoice') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'':''); if ($mode == 1) $out.='invoice_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -203,7 +212,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'contractline') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'':''); if ($mode == 1) $out.='contractline_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -221,7 +230,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } elseif ($type == 'member' || $type == 'membersubscription') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'':''); if ($mode == 1) $out.='member_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); @@ -239,7 +248,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } if ($type == 'donation') { - $out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); + $out=$urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode?'':''); if ($mode == 1) $out.='donation_ref'; if ($mode == 0) $out.=urlencode($ref); $out.=($mode?'':''); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 050722b0b8e87..ff6a0abb72b2c 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -112,7 +112,7 @@ class pdf_standard extends ModeleExpenseReport /** * Issuer - * @var Company object that emits + * @var Societe */ public $emetteur; @@ -1053,18 +1053,18 @@ private function tablePayments(&$pdf, $object, $posy, $outputlangs) $pdf->SetXY($tab3_posx+17, $tab3_top+$y); $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); $pdf->SetXY($tab3_posx+35, $tab3_top+$y); - $pdf->MultiCell(30, 4, $outputlangs->trans("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AlreadyPaid"), 0, 'L', 0); $y+=$tab3_height-2; $pdf->SetXY($tab3_posx+17, $tab3_top+$y); $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); $pdf->SetXY($tab3_posx+35, $tab3_top+$y); - $pdf->MultiCell(30, 4, $outputlangs->trans("AmountExpected"), 0, 'L', 0); + $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AmountExpected"), 0, 'L', 0); $y+=$tab3_height-2; $remaintopay = $object->total_ttc - $totalpaid; $pdf->SetXY($tab3_posx+17, $tab3_top+$y); $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); $pdf->SetXY($tab3_posx+35, $tab3_top+$y); - $pdf->MultiCell(30, 4, $outputlangs->trans("RemainderToPay"), 0, 'L', 0); + $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("RemainderToPay"), 0, 'L', 0); } } else diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index b32fcf3658abc..990368d87381c 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -29,21 +29,22 @@ // Url list print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':

'; print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount", $servicename).':
'; -print ''.getOnlinePaymentUrl(1, 'free')."

\n"; +print ''.getOnlinePaymentUrl(1, 'free')."

\n"; if (! empty($conf->commande->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'order')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'order')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("orders"); - print '
'; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Order")).': '; print ''; print ''; if (GETPOST('generate_order_ref', 'alpha')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'order', GETPOST('generate_order_ref', 'alpha')); print $url; print "
\n"; @@ -54,18 +55,19 @@ } if (! empty($conf->facture->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'invoice')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'invoice')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("bills"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Invoice")).': '; print ''; print ''; if (GETPOST('generate_invoice_ref', 'alpha')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'invoice', GETPOST('generate_invoice_ref', 'alpha')); print $url; print "
\n"; @@ -76,18 +78,19 @@ } if (! empty($conf->contrat->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'contractline')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'contractline')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("contracts"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("ContractLine")).': '; print ''; print ''; if (GETPOST('generate_contract_ref')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'contractline', GETPOST('generate_contract_ref', 'alpha')); print $url; print "
\n"; @@ -98,18 +101,19 @@ } if (! empty($conf->adherent->enabled)) { - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'membersubscription')."
\n"; + print '
'; + print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
'; + print ''.getOnlinePaymentUrl(1, 'membersubscription')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Member")).': '; print ''; print ''; if (GETPOST('generate_member_ref')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'membersubscription', GETPOST('generate_member_ref', 'alpha')); print $url; print "
\n"; @@ -120,18 +124,19 @@ } if (! empty($conf->don->enabled)) { + print '
'; print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnDonation", $servicename).':
'; - print ''.getOnlinePaymentUrl(1, 'donation')."
\n"; + print ''.getOnlinePaymentUrl(1, 'donation')."
\n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $langs->load("members"); - print ''; + print ''; print $langs->trans("EnterRefToBuildUrl", $langs->transnoentitiesnoconv("Don")).': '; print ''; print ''; if (GETPOST('generate_donation_ref')) { - print '
-> '; + print '
-> '; $url=getOnlinePaymentUrl(0, 'donation', GETPOST('generate_donation_ref', 'alpha')); print $url; print "
\n"; diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index 46de5f4485b19..64ce7b15aff58 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -62,4 +62,6 @@ CreateCustomerOnStripe=Create customer on Stripe CreateCardOnStripe=Create card on Stripe ShowInStripe=Show in Stripe StripeUserAccountForActions=User account to use for email notification of some Stripe events (Stripe payouts) -StripePayoutList=List of Stripe payouts \ No newline at end of file +StripePayoutList=List of Stripe payouts +ToOfferALinkForTestWebhook=Link to setup Stripe WebHook to call the IPN (test mode) +ToOfferALinkForLiveWebhook=Link to setup Stripe WebHook to call the IPN (live mode) \ No newline at end of file diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1d3f14c3a3797..2d5793292741e 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -263,7 +263,7 @@ * Actions */ -// Action dopayment is called after choosing the payment mode +// Action dopayment is called after clicking/choosing the payment mode if ($action == 'dopayment') { if ($paymentmethod == 'paypal') @@ -395,7 +395,7 @@ } -// Called when choosing Stripe mode, after the 'dopayment' +// Called when choosing Stripe mode, after clicking the 'dopayment' if ($action == 'charge' && ! empty($conf->stripe->enabled)) { $amountstripe = $amount; @@ -509,7 +509,7 @@ if (empty($vatcleaned)) $taxinfo=null; dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); -$customer = \Stripe\Customer::create(array( + $customer = \Stripe\Customer::create(array( 'email' => $email, 'description' => ($email?'Anonymous customer for '.$email:'Anonymous customer'), 'metadata' => $metadata, @@ -525,7 +525,7 @@ // The customer was just created with a source, so we can make a charge // with no card defined, the source just used for customer creation will be used. dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); -$charge = \Stripe\Charge::create(array( + $charge = \Stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => price2num($amountstripe, 'MU'), 'currency' => $currency, @@ -1658,7 +1658,7 @@ if (preg_match('/^dopayment/', $action)) { - // Strip + // Stripe if (GETPOST('dopayment_stripe', 'alpha')) { // Simple checkout @@ -1727,26 +1727,28 @@ class="stripe-button"
- + +
+ +
+
- - - + '."\n"; - '."\n"; + // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. + print '