diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 7fe3c835f18..b9e79d78a6a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -233,7 +233,9 @@ if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) if (! $valid) { print '
Bad value for key.
'; - //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; + //prin '.$langs->trans("SaveSource").' +1563 +t 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; exit; } } @@ -410,7 +412,10 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) $stripeToken = GETPOST("stripeToken",'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 - $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("email = ".$email, LOG_DEBUG, 0, '_stripe'); @@ -421,12 +426,12 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) try { $metadata = array( - 'dol_version'=>DOL_VERSION, - 'dol_entity'=>$conf->entity, + 'dol_version' => DOL_VERSION, + 'dol_entity' => $conf->entity, + 'dol_company' => $mysoc->name, // Usefull when using multicompany '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 ($thirdparty_id > 0) @@ -451,7 +456,9 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); // Create Stripe card from Token + if (! empty($savesource)) { $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + } else { $card = $stripeToken; } if (empty($card)) { @@ -461,14 +468,18 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled)) $action=''; } 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'); $charge = \Stripe\Charge::create(array( 'amount' => price2num($amountstripe, 'MU'), 'currency' => $currency, 'capture' => true, // Charge immediatly '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, '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 @@ -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 ?) )); // 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 // 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, 'capture' => true, // Charge immediatly '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 )); // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) @@ -820,6 +835,7 @@ if ($source == 'order') print ''.$text; print ''; print ''; + print ''; $directdownloadlink = $order->getLastMainDocLink('commande'); if ($directdownloadlink) { @@ -939,6 +955,7 @@ if ($source == 'invoice') print ''.$text; print ''; print ''; + print ''; $directdownloadlink = $invoice->getLastMainDocLink('facture'); if ($directdownloadlink) { @@ -1137,6 +1154,7 @@ if ($source == 'contractline') print ''.$text; print ''; print ''; + print ''; $directdownloadlink = $contract->getLastMainDocLink('contract'); if ($directdownloadlink) { @@ -1543,7 +1561,6 @@ if (preg_match('/^dopayment/',$action))
- @@ -1554,8 +1571,6 @@ if (preg_match('/^dopayment/',$action)) - -