Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2019-06-07 14:21:11 +02:00
commit 235a65e7a8
8 changed files with 177 additions and 142 deletions

View File

@ -10,7 +10,7 @@ ToComplete=To complete
YourEMail=Email to receive payment confirmation
Creditor=Creditor
PaymentCode=Payment code
PayBoxDoPayment=Pay with Credit or Debit Card (Paybox)
PayBoxDoPayment=Pay with Paybox
ToPay=Do payment
YouWillBeRedirectedOnPayBox=You will be redirected on secured Paybox page to input you credit card information
Continue=Next

View File

@ -33,3 +33,4 @@ PostActionAfterPayment=Post actions after payments
ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions. You must complete post actions manually if they are necessary.
ValidationOfPaymentFailed=Validation of payment has failed
CardOwner=Card holder
PayPalBalance=Paypal credit

View File

@ -12,7 +12,7 @@ YourEMail=Email to receive payment confirmation
STRIPE_PAYONLINE_SENDEMAIL=Email notification after a payment attempt (success or fail)
Creditor=Creditor
PaymentCode=Payment code
StripeDoPayment=Pay with Credit or Debit Card (Stripe)
StripeDoPayment=Pay with Stripe
YouWillBeRedirectedOnStripe=You will be redirected on secured Stripe page to input you credit card information
Continue=Next
ToOfferALinkForOnlinePayment=URL for %s payment

View File

@ -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&amp;entity='.$conf->entity.'&amp;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&amp;entity='.$conf->entity.'&amp;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 ?>');

View File

@ -106,7 +106,7 @@ catch(\UnexpectedValueException $e) {
$langs->load("main");
// TODO Do we really need a user in setup just to have an name to fill an email topic when it is a technical system notification email
// TODO Do we really need a user in setup just to have a name to fill an email topic when it is a technical system notification email
$user = new User($db);
$user->fetch($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS);
$user->getrights();
@ -297,12 +297,18 @@ elseif ($event->type == 'customer.deleted') {
$db->query($sql);
$db->commit();
}
elseif ($event->type == 'payment_intent.succeeded') {
// TODO: Redirect to paymentok.php
elseif ($event->type == 'payment_intent.succeeded') { // Called when making payment with PaymentIntent method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on).
// TODO: create fees
// TODO: Redirect to paymentok.php
}
elseif ($event->type == 'payment_intent.payment_failed') {
// TODO: Redirect to paymentko.php
}
elseif ($event->type == 'checkout.session.completed') // Called when making payment with new Checkout method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on).
{
// TODO: create fees
// TODO: Redirect to paymentok.php
}
elseif ($event->type == 'charge.succeeded') {
// TODO: create fees
// TODO: Redirect to paymentok.php

View File

@ -242,7 +242,7 @@ class Stripe extends CommonObject
* Warning. If a payment was tried and failed, a payment intent was created.
* But if we change someting on object to pay (amount or other), reusing same payment intent is not allowed.
* Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay),
* that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old that will not be used)
* that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used)
*
* @param double $amount Amount
* @param string $currency_code Currency code
@ -366,6 +366,7 @@ class Stripe extends CommonObject
global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']);
// Note: If all data for payment intent are same than a previous on, even if we use 'create', Stripe will return ID of the old existing payment intent.
if (empty($key)) { // If the Stripe connect account not set, we use common API usage
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description"));
//$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array());
@ -373,7 +374,7 @@ class Stripe extends CommonObject
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("idempotency_key" => "$description", "stripe_account" => $key));
//$paymentintent = \Stripe\PaymentIntent::create($dataforintent, array("stripe_account" => $key));
}
//var_dump($paymentintent);
//var_dump($paymentintent->id);
// Store the payment intent
if (is_object($object))

View File

@ -133,7 +133,7 @@ input.buttongen {
vertical-align: middle;
}
input.buttonpayment, button.buttonpayment, div.buttonpayment {
min-width: 320px;
min-width: 290px;
margin-bottom: 15px;
background-image: none;
line-height: 24px;
@ -147,6 +147,11 @@ input.buttonpayment, button.buttonpayment, div.buttonpayment {
color: #fff;
border-radius: 4px;
}
.buttonpaymentsmall {
font-size: 0.65em;
padding-left: 5px;
padding-right: 5px;
}
div.buttonpayment input {
background-color: unset;
color: #fff;

View File

@ -353,8 +353,11 @@ input.buttongen {
vertical-align: middle;
}
input.buttonpayment, button.buttonpayment, div.buttonpayment {
min-width: 320px;
min-width: 290px;
margin-bottom: 15px;
margin-top: 0;
margin-left: 5px;
margin-right: 5px;
background-image: none;
line-height: 24px;
padding: 8px;