|
|
|
|
@ -313,8 +313,6 @@ if ($action == 'dopayment')
|
|
|
|
|
|
|
|
|
|
// Other
|
|
|
|
|
$PAYPAL_API_DEVISE="USD";
|
|
|
|
|
//if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR";
|
|
|
|
|
//if ($currency == 'USD') $PAYPAL_API_DEVISE="USD";
|
|
|
|
|
if (! empty($currency)) $PAYPAL_API_DEVISE=$currency;
|
|
|
|
|
|
|
|
|
|
// Show var initialized by include fo paypal lib at begin of this file
|
|
|
|
|
@ -340,9 +338,6 @@ if ($action == 'dopayment')
|
|
|
|
|
dol_syslog("desc: $desc", LOG_DEBUG);
|
|
|
|
|
|
|
|
|
|
dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO
|
|
|
|
|
//$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE;
|
|
|
|
|
//$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE;
|
|
|
|
|
//$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE;
|
|
|
|
|
|
|
|
|
|
// A redirect is added if API call successfull
|
|
|
|
|
$mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
|
|
|
|
|
@ -662,7 +657,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method
|
|
|
|
|
// Note that with other Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here.
|
|
|
|
|
// Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here.
|
|
|
|
|
//dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -777,16 +772,20 @@ elseif (! empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall=$conf->global->O
|
|
|
|
|
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
|
|
|
|
|
// Define urllogo
|
|
|
|
|
$urllogo='';
|
|
|
|
|
$urllogofull='';
|
|
|
|
|
if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
|
|
|
|
|
{
|
|
|
|
|
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
|
|
|
|
$urllogofull=$dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
|
|
|
|
$width=150;
|
|
|
|
|
}
|
|
|
|
|
elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
|
|
|
|
|
{
|
|
|
|
|
$urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
|
|
|
|
$urllogofull=$dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
|
|
|
|
$width=150;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Output html code for logo
|
|
|
|
|
if ($urllogo)
|
|
|
|
|
{
|
|
|
|
|
@ -864,25 +863,6 @@ if (! $source)
|
|
|
|
|
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
|
|
|
|
|
print '</td></tr>'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = null;
|
|
|
|
|
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag, $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
// We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
|
|
|
|
|
// as they don't exists (buyer is unknown, tag is free).
|
|
|
|
|
}
|
|
|
|
|
@ -974,26 +954,6 @@ if ($source == 'order')
|
|
|
|
|
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
|
|
|
|
|
print '</td></tr>'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && empty($order->billed) && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = $stripe->customerStripe($order->thirdparty, $stripeacc, $servicestatus, 1);
|
|
|
|
|
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.' ref='.$object->ref, $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shipping address
|
|
|
|
|
$shipToName=$order->thirdparty->name;
|
|
|
|
|
$shipToStreet=$order->thirdparty->address;
|
|
|
|
|
@ -1121,25 +1081,6 @@ if ($source == 'invoice')
|
|
|
|
|
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
|
|
|
|
|
print '</td></tr>'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->stripe->enabled) && ($paymentmethod == 'stripe') && empty($object->paye) && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = $stripe->customerStripe($invoice->thirdparty, $stripeacc, $servicestatus, 1);
|
|
|
|
|
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.' ref='.$object->ref, $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shipping address
|
|
|
|
|
$shipToName=$invoice->thirdparty->name;
|
|
|
|
|
$shipToStreet=$invoice->thirdparty->address;
|
|
|
|
|
@ -1350,26 +1291,6 @@ if ($source == 'contractline')
|
|
|
|
|
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
|
|
|
|
|
print '</td></tr>'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = null;
|
|
|
|
|
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag." ref=".$object->ref, $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shipping address
|
|
|
|
|
$shipToName=$contract->thirdparty->name;
|
|
|
|
|
$shipToStreet=$contract->thirdparty->address;
|
|
|
|
|
@ -1536,26 +1457,6 @@ if ($source == 'membersubscription')
|
|
|
|
|
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
|
|
|
|
|
print '</td></tr>'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->stripe->enabled) && $paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = null;
|
|
|
|
|
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag." ref=".$object->ref, $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shipping address
|
|
|
|
|
$shipToName=$member->getFullName($langs);
|
|
|
|
|
$shipToStreet=$member->address;
|
|
|
|
|
@ -1697,26 +1598,6 @@ if ($source == 'donation')
|
|
|
|
|
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
|
|
|
|
|
print '</td></tr>'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->stripe->enabled) && ($paymentmethod == 'stripe') && empty($object->paid) && ! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = $stripe->customerStripe($don->thirdparty, $stripeacc, $servicestatus, 1);
|
|
|
|
|
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag." ref=".$object->ref, $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Shipping address
|
|
|
|
|
$shipToName=$don->getFullName($langs);
|
|
|
|
|
$shipToStreet=$don->address;
|
|
|
|
|
@ -1758,6 +1639,7 @@ print '</table>'."\n";
|
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Show all payment mode buttons (Stripe, Paypal, ...)
|
|
|
|
|
if ($action != 'dopayment')
|
|
|
|
|
{
|
|
|
|
|
if ($found && ! $error) // We are in a management option and no error
|
|
|
|
|
@ -1788,27 +1670,37 @@ if ($action != 'dopayment')
|
|
|
|
|
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled))
|
|
|
|
|
{
|
|
|
|
|
// If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of paybox
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-credit-card"></span> <input class="" type="submit" name="dopayment_paybox" value="'.$langs->trans("PayBoxDoPayment").'"></div>';
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-credit-card"></span> <input class="" type="submit" name="dopayment_paybox" value="'.$langs->trans("PayBoxDoPayment").'">';
|
|
|
|
|
print '<br>';
|
|
|
|
|
print '<span class="buttonpaymentsmall">'.$langs->trans("CreditOrDebitCard").'</span>';
|
|
|
|
|
print '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled))
|
|
|
|
|
{
|
|
|
|
|
// If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-credit-card"></span> <input class="" type="submit" name="dopayment_stripe" value="'.$langs->trans("StripeDoPayment").'"></div>';
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-credit-card"></span> <input class="" type="submit" name="dopayment_stripe" value="'.$langs->trans("StripeDoPayment").'">';
|
|
|
|
|
print '<br>';
|
|
|
|
|
print '<span class="buttonpaymentsmall">'.$langs->trans("CreditOrDebitCard").'</span>';
|
|
|
|
|
print '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled))
|
|
|
|
|
{
|
|
|
|
|
if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral';
|
|
|
|
|
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-paypal"></span> <input class="" type="submit" name="dopayment_paypal" value="'.$langs->trans("PaypalDoPayment").'">';
|
|
|
|
|
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral')
|
|
|
|
|
{
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-paypal"></span> <input class="" type="submit" name="dopayment_paypal" value="'.$langs->trans("PaypalOrCBDoPayment").'"></div>';
|
|
|
|
|
print '<br>';
|
|
|
|
|
print '<span class="buttonpaymentsmall">'.$langs->trans("CreditOrDebitCard").'</span><span class="buttonpaymentsmall"> - </span>';
|
|
|
|
|
print '<span class="buttonpaymentsmall">'.$langs->trans("PayPalBalance").'</span>';
|
|
|
|
|
}
|
|
|
|
|
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly')
|
|
|
|
|
{
|
|
|
|
|
print '<br><div class="button buttonpayment"><span class="fa fa-paypal"></span> <input class="" type="submit" name="dopayment_paypal" value="'.$langs->trans("PaypalDoPayment").'"></div>';
|
|
|
|
|
//print '<br><span class="buttonpaymentsmall">'.$langs->trans("PaypalAccount").'"></span>';
|
|
|
|
|
}
|
|
|
|
|
print '</div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1833,7 +1725,7 @@ print '<br>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add more content on page for some services
|
|
|
|
|
if (preg_match('/^dopayment/', $action))
|
|
|
|
|
if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment mode
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Stripe
|
|
|
|
|
@ -1888,6 +1780,30 @@ if (preg_match('/^dopayment/', $action))
|
|
|
|
|
print '<input type="hidden" name="email" value="'.GETPOST('email', 'alpha').'" />';
|
|
|
|
|
print '<input type="hidden" name="thirdparty_id" value="'.GETPOST('thirdparty_id', 'int').'" />';
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($conf->global->STRIPE_USE_NEW_CHECKOUT))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
|
|
|
|
|
|
|
|
|
$service = 'StripeLive';
|
|
|
|
|
$servicestatus = 1;
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))
|
|
|
|
|
{
|
|
|
|
|
$service = 'StripeTest';
|
|
|
|
|
$servicestatus = 0;
|
|
|
|
|
}
|
|
|
|
|
$stripe = new Stripe($db);
|
|
|
|
|
$stripeacc = $stripe->getStripeAccount($service);
|
|
|
|
|
$stripecu = null;
|
|
|
|
|
if (is_object($object) && is_object($object->thirdparty)) $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1);
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
$paymentintent=$stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $stripecu, $stripeacc, $servicestatus);
|
|
|
|
|
if ($stripe->error) setEventMessages($stripe->error, null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent))
|
|
|
|
|
{
|
|
|
|
|
print '
|
|
|
|
|
@ -1943,18 +1859,122 @@ if (preg_match('/^dopayment/', $action))
|
|
|
|
|
|
|
|
|
|
print '</form>'."\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// JS Code for Stripe
|
|
|
|
|
if (empty($stripearrayofkeys['publishable_key']))
|
|
|
|
|
{
|
|
|
|
|
print info_admin($langs->trans("ErrorModuleSetupNotComplete", "stripe"), 0, 0, 'error');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<!-- JS Code for Stripe components -->';
|
|
|
|
|
print '<script src="https://js.stripe.com/v3/"></script>'."\n";
|
|
|
|
|
|
|
|
|
|
// Code to ask the credit card. This use the default "API version". No way to force API version when using JS code.
|
|
|
|
|
print '<script type="text/javascript" language="javascript">'."\n";
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
if (! empty($conf->global->STRIPE_USE_NEW_CHECKOUT))
|
|
|
|
|
{
|
|
|
|
|
$amountstripe = $amount;
|
|
|
|
|
|
|
|
|
|
// Correct the amount according to unit of currency
|
|
|
|
|
// See https://support.stripe.com/questions/which-zero-decimal-currencies-does-stripe-support
|
|
|
|
|
$arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
|
|
|
|
|
if (! in_array($currency, $arrayzerounitcurrency)) $amountstripe=$amountstripe * 100;
|
|
|
|
|
|
|
|
|
|
$ipaddress=getUserRemoteIP();
|
|
|
|
|
$metadata = array('dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>$ipaddress);
|
|
|
|
|
if (is_object($object))
|
|
|
|
|
{
|
|
|
|
|
$metadata['dol_type'] = $object->element;
|
|
|
|
|
$metadata['dol_id'] = $object->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$arrayforpaymentintent = array(
|
|
|
|
|
'description'=>'Stripe payment: '.$FULLTAG.(is_object($object)?' ref='.$object->ref:''),
|
|
|
|
|
"metadata" => $metadata
|
|
|
|
|
);
|
|
|
|
|
if ($TAG) $arrayforpaymentintent["statement_descriptor"] = dol_trunc($TAG, 10, 'right', 'UTF-8', 1); // 22 chars that appears on bank receipt (company + description)
|
|
|
|
|
|
|
|
|
|
$arrayforcheckout = array(
|
|
|
|
|
'payment_method_types' => array('card'),
|
|
|
|
|
'line_items' => array(array(
|
|
|
|
|
'name' => $langs->transnoentitiesnoconv("Payment").' '.$FULLTAG.' ref='.$ref,
|
|
|
|
|
'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref,
|
|
|
|
|
'amount' => $amountstripe,
|
|
|
|
|
'currency' => $currency,
|
|
|
|
|
'images' => array($urllogofull),
|
|
|
|
|
'quantity' => 1,
|
|
|
|
|
)),
|
|
|
|
|
'client_reference_id' => $FULLTAG,
|
|
|
|
|
'success_url' => $urlok,
|
|
|
|
|
'cancel_url' => $urlko,
|
|
|
|
|
'payment_intent_data' => $arrayforpaymentintent
|
|
|
|
|
);
|
|
|
|
|
if ($stripecu) $arrayforcheckout['customer'] = $stripecu;
|
|
|
|
|
elseif (GETPOST('email', 'alpha') && isValidEmail(GETPOST('email', 'alpha'))) $arrayforcheckout['customer_email'] = GETPOST('email', 'alpha');
|
|
|
|
|
$sessionstripe = \Stripe\Checkout\Session::create($arrayforcheckout);
|
|
|
|
|
|
|
|
|
|
$remoteip = getUserRemoteIP();
|
|
|
|
|
|
|
|
|
|
// Save some data for the paymentok
|
|
|
|
|
$_SESSION["currencyCodeType"] = $currency;
|
|
|
|
|
$_SESSION["paymentType"] = '';
|
|
|
|
|
$_SESSION["FinalPaymentAmt"] = $amount;
|
|
|
|
|
$_SESSION['ipaddress'] = ($remoteip?$remoteip:'unknown'); // Payer ip
|
|
|
|
|
$_SESSION['payerID'] = is_object($stripecu)?$stripecu->id:'';
|
|
|
|
|
$_SESSION['TRANSACTIONID'] = $sessionstripe->id;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception $e)
|
|
|
|
|
{
|
|
|
|
|
print $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
// Code for payment with option STRIPE_USE_NEW_CHECKOUT set
|
|
|
|
|
|
|
|
|
|
// Create a Stripe client.
|
|
|
|
|
var stripe = Stripe('<?php echo $stripearrayofkeys['publishable_key']; // Defined into config.php ?>');
|
|
|
|
|
|
|
|
|
|
// Create an instance of Elements
|
|
|
|
|
var elements = stripe.elements();
|
|
|
|
|
|
|
|
|
|
// Custom styling can be passed to options when creating an Element.
|
|
|
|
|
// (Note that this demo uses a wider set of styles than the guide below.)
|
|
|
|
|
var style = {
|
|
|
|
|
base: {
|
|
|
|
|
color: '#32325d',
|
|
|
|
|
lineHeight: '24px',
|
|
|
|
|
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
|
|
|
|
|
fontSmoothing: 'antialiased',
|
|
|
|
|
fontSize: '16px',
|
|
|
|
|
'::placeholder': {
|
|
|
|
|
color: '#aab7c4'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
invalid: {
|
|
|
|
|
color: '#fa755a',
|
|
|
|
|
iconColor: '#fa755a'
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var cardElement = elements.create('card', {style: style});
|
|
|
|
|
|
|
|
|
|
stripe.redirectToCheckout({
|
|
|
|
|
// Make the id field from the Checkout Session creation API response
|
|
|
|
|
// available to this file, so you can provide it as parameter here
|
|
|
|
|
// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
|
|
|
|
|
sessionId: '<?php print $sessionstripe->id; ?>'
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
// If `redirectToCheckout` fails due to a browser or network
|
|
|
|
|
// error, display the localized error message to your customer
|
|
|
|
|
// using `result.error.message`.
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
elseif (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
|
|
|
|
|
{
|
|
|
|
|
?>
|
|
|
|
|
// Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set
|
|
|
|
|
@ -2032,7 +2052,7 @@ if (preg_match('/^dopayment/', $action))
|
|
|
|
|
postal_code: '<?php echo $object->thirdparty->zip; ?>'}<?php } ?>
|
|
|
|
|
} /* TODO Add all other known data like emails, ... to be SCA compliant */
|
|
|
|
|
},
|
|
|
|
|
save_payment_method: true /* the card will be saved */
|
|
|
|
|
save_payment_method: <?php if ($stripecu) { print 'true'; } else { print 'false'; } ?> /* true when a customer was provided when creating payment intent. true ask to save the card */
|
|
|
|
|
}
|
|
|
|
|
).then(function(result) {
|
|
|
|
|
console.log(result);
|
|
|
|
|
@ -2056,13 +2076,12 @@ if (preg_match('/^dopayment/', $action))
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
?>
|
|
|
|
|
// Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off
|
|
|
|
|
// Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off and STRIPE_USE_NEW_CHECKOUT off
|
|
|
|
|
|
|
|
|
|
// Create a Stripe client.
|
|
|
|
|
var stripe = Stripe('<?php echo $stripearrayofkeys['publishable_key']; // Defined into config.php ?>');
|
|
|
|
|
|