Merge pull request #9681 from ptibogxiv/patch-70
Fix metadata for charge.php
This commit is contained in:
commit
36b75031f5
@ -233,7 +233,9 @@ if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
|
|||||||
if (! $valid)
|
if (! $valid)
|
||||||
{
|
{
|
||||||
print '<div class="error">Bad value for key.</div>';
|
print '<div class="error">Bad value for key.</div>';
|
||||||
//print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid;
|
//prin <input name="savesource" type="checkbox"> '.$langs->trans("SaveSource").'
|
||||||
|
1563
|
||||||
|
t 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,7 +412,10 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
$stripeToken = GETPOST("stripeToken",'alpha');
|
$stripeToken = GETPOST("stripeToken",'alpha');
|
||||||
$email = GETPOST("email",'alpha');
|
$email = GETPOST("email",'alpha');
|
||||||
$thirdparty_id=GETPOST('thirdparty_id', 'int'); // Note that for payment following online registration for members, this is empty because thirdparty is created once payment is confirmed by paymentok.php
|
$thirdparty_id=GETPOST('thirdparty_id', 'int'); // Note that for payment following online registration for members, this is empty because thirdparty is created once payment is confirmed by paymentok.php
|
||||||
$vatnumber = GETPOST('vatnumber','alpha');
|
$dol_type=(GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha'));
|
||||||
|
$dol_id=GETPOST('dol_id', 'int');
|
||||||
|
$vatnumber = GETPOST('vatnumber','alpha');
|
||||||
|
$savesource=GETPOST('savesource', 'int');
|
||||||
|
|
||||||
dol_syslog("stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe');
|
dol_syslog("stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe');
|
||||||
dol_syslog("email = ".$email, LOG_DEBUG, 0, '_stripe');
|
dol_syslog("email = ".$email, LOG_DEBUG, 0, '_stripe');
|
||||||
@ -421,12 +426,12 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$metadata = array(
|
$metadata = array(
|
||||||
'dol_version'=>DOL_VERSION,
|
'dol_version' => DOL_VERSION,
|
||||||
'dol_entity'=>$conf->entity,
|
'dol_entity' => $conf->entity,
|
||||||
|
'dol_company' => $mysoc->name, // Usefull when using multicompany
|
||||||
'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])
|
'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])
|
||||||
);
|
);
|
||||||
if (! empty($dol_id)) $metadata["dol_id"] = $dol_id;
|
|
||||||
if (! empty($dol_type)) $metadata["dol_type"] = $dol_type;
|
|
||||||
if (! empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id;
|
if (! empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id;
|
||||||
|
|
||||||
if ($thirdparty_id > 0)
|
if ($thirdparty_id > 0)
|
||||||
@ -451,7 +456,9 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
$customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
|
$customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
|
||||||
|
|
||||||
// Create Stripe card from Token
|
// Create Stripe card from Token
|
||||||
|
if (! empty($savesource)) {
|
||||||
$card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata));
|
$card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata));
|
||||||
|
} else { $card = $stripeToken; }
|
||||||
|
|
||||||
if (empty($card))
|
if (empty($card))
|
||||||
{
|
{
|
||||||
@ -461,14 +468,18 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG;
|
||||||
|
if (! empty($dol_id)) $metadata["dol_id"] = $dol_id;
|
||||||
|
if (! empty($dol_type)) $metadata["dol_type"] = $dol_type;
|
||||||
|
|
||||||
dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe');
|
dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe');
|
||||||
$charge = \Stripe\Charge::create(array(
|
$charge = \Stripe\Charge::create(array(
|
||||||
'amount' => price2num($amountstripe, 'MU'),
|
'amount' => price2num($amountstripe, 'MU'),
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'capture' => true, // Charge immediatly
|
'capture' => true, // Charge immediatly
|
||||||
'description' => 'Stripe payment: '.$FULLTAG,
|
'description' => 'Stripe payment: '.$FULLTAG,
|
||||||
'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])),
|
'metadata' => $metadata,
|
||||||
'customer' => $customer->id,
|
'customer' => $customer->id,
|
||||||
'source' => $card,
|
'source' => $card,
|
||||||
'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt
|
'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt
|
||||||
@ -494,6 +505,10 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?)
|
'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?)
|
||||||
));
|
));
|
||||||
// Return $customer = array('id'=>'cus_XXXX', ...)
|
// Return $customer = array('id'=>'cus_XXXX', ...)
|
||||||
|
|
||||||
|
if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG;
|
||||||
|
if (! empty($dol_id)) $metadata["dol_id"] = $dol_id;
|
||||||
|
if (! empty($dol_type)) $metadata["dol_type"] = $dol_type;
|
||||||
|
|
||||||
// The customer was just created with a source, so we can make a charge
|
// 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.
|
// with no card defined, the source just used for customer creation will be used.
|
||||||
@ -504,7 +519,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'capture' => true, // Charge immediatly
|
'capture' => true, // Charge immediatly
|
||||||
'description' => 'Stripe payment: '.$FULLTAG,
|
'description' => 'Stripe payment: '.$FULLTAG,
|
||||||
'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])),
|
'metadata' => $metadata,
|
||||||
'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt
|
'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt
|
||||||
));
|
));
|
||||||
// Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...)
|
// Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...)
|
||||||
@ -820,6 +835,7 @@ if ($source == 'order')
|
|||||||
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
||||||
print '<input type="hidden" name="s" value="'.dol_escape_htmltag($source).'">';
|
print '<input type="hidden" name="s" value="'.dol_escape_htmltag($source).'">';
|
||||||
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).'">';
|
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($order->ref).'">';
|
||||||
|
print '<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($order->id).'">';
|
||||||
$directdownloadlink = $order->getLastMainDocLink('commande');
|
$directdownloadlink = $order->getLastMainDocLink('commande');
|
||||||
if ($directdownloadlink)
|
if ($directdownloadlink)
|
||||||
{
|
{
|
||||||
@ -939,6 +955,7 @@ if ($source == 'invoice')
|
|||||||
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
||||||
print '<input type="hidden" name="s" value="'.dol_escape_htmltag($source).'">';
|
print '<input type="hidden" name="s" value="'.dol_escape_htmltag($source).'">';
|
||||||
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).'">';
|
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->ref).'">';
|
||||||
|
print '<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($invoice->id).'">';
|
||||||
$directdownloadlink = $invoice->getLastMainDocLink('facture');
|
$directdownloadlink = $invoice->getLastMainDocLink('facture');
|
||||||
if ($directdownloadlink)
|
if ($directdownloadlink)
|
||||||
{
|
{
|
||||||
@ -1137,6 +1154,7 @@ if ($source == 'contractline')
|
|||||||
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
|
||||||
print '<input type="hidden" name="source" value="'.dol_escape_htmltag($source).'">';
|
print '<input type="hidden" name="source" value="'.dol_escape_htmltag($source).'">';
|
||||||
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).'">';
|
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($contractline->ref).'">';
|
||||||
|
print '<input type="hidden" name="dol_id" value="'.dol_escape_htmltag($contractline->id).'">';
|
||||||
$directdownloadlink = $contract->getLastMainDocLink('contract');
|
$directdownloadlink = $contract->getLastMainDocLink('contract');
|
||||||
if ($directdownloadlink)
|
if ($directdownloadlink)
|
||||||
{
|
{
|
||||||
@ -1543,7 +1561,6 @@ if (preg_match('/^dopayment/',$action))
|
|||||||
<div id="card-element">
|
<div id="card-element">
|
||||||
<!-- a Stripe Element will be inserted here. -->
|
<!-- a Stripe Element will be inserted here. -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Used to display form errors -->
|
<!-- Used to display form errors -->
|
||||||
<div id="card-errors" role="alert"></div>
|
<div id="card-errors" role="alert"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -1554,8 +1571,6 @@ if (preg_match('/^dopayment/',$action))
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://js.stripe.com/v2/"></script>
|
|
||||||
<script src="https://js.stripe.com/v3/"></script>
|
<script src="https://js.stripe.com/v3/"></script>
|
||||||
|
|
||||||
<script type="text/javascript" language="javascript">';
|
<script type="text/javascript" language="javascript">';
|
||||||
@ -1691,4 +1706,3 @@ htmlPrintOnlinePaymentFooter($mysoc,$langs,1,$suffix,$object);
|
|||||||
llxFooter('', 'public');
|
llxFooter('', 'public');
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user