Merge pull request #9770 from Dolibarr/revert-9764-patch-71
Revert "FIX and dolibarize"
This commit is contained in:
commit
23ffac3bf2
@ -346,10 +346,10 @@ class Stripe extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Create charge with public/payment/newpayment.php, stripe/card.php, cronjobs or REST API
|
* Create charge with public/payment/newpayment.php, stripe/card.php, cronjobs or REST API
|
||||||
*
|
*
|
||||||
* @param int $stripeamount Amount to pay
|
* @param int $amount Amount to pay
|
||||||
* @param string $currency EUR, GPB...
|
* @param string $currency EUR, GPB...
|
||||||
* @param string $dol_type Object type to pay (order, invoice, contract...)
|
* @param string $origin Object type to pay (order, invoice, contract...)
|
||||||
* @param int $dol_id Object id to pay
|
* @param int $item Object id to pay
|
||||||
* @param string $source src_xxxxx or card_xxxxx
|
* @param string $source src_xxxxx or card_xxxxx
|
||||||
* @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe()
|
* @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe()
|
||||||
* @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount()
|
* @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount()
|
||||||
@ -358,7 +358,7 @@ class Stripe extends CommonObject
|
|||||||
* @param boolean $capture Set capture flag to true (take payment) or false (wait)
|
* @param boolean $capture Set capture flag to true (take payment) or false (wait)
|
||||||
* @return Stripe
|
* @return Stripe
|
||||||
*/
|
*/
|
||||||
public function createPaymentStripe($stripeamount, $currency, $dol_type, $dol_id, $source, $customer, $account, $status=0, $usethirdpartyemailforreceiptemail=0, $capture=true)
|
public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account, $status=0, $usethirdpartyemailforreceiptemail=0, $capture=true)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -387,28 +387,29 @@ class Stripe extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
|
$arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
|
||||||
if (! in_array($currency, $arrayzerounitcurrency)) $stripeamount=$stripeamount * 100;
|
if (! in_array($currency, $arrayzerounitcurrency)) $stripeamount=$amount * 100;
|
||||||
|
else $stripeamount = $amount;
|
||||||
|
|
||||||
$societe = new Societe($this->db);
|
$societe = new Societe($this->db);
|
||||||
if ($key > 0) $societe->fetch($key);
|
if ($key > 0) $societe->fetch($key);
|
||||||
|
|
||||||
$description = "";
|
$description = "";
|
||||||
$ref = "";
|
$ref = "";
|
||||||
if ($dol_type == order) {
|
if ($origin == order) {
|
||||||
$order = new Commande($this->db);
|
$order = new Commande($this->db);
|
||||||
$order->fetch($dol_id);
|
$order->fetch($item);
|
||||||
$ref = $order->ref;
|
$ref = $order->ref;
|
||||||
$description = "ORD=" . $ref . ".CUS=" . $societe->id.".PM=stripe";
|
$description = "ORD=" . $ref . ".CUS=" . $societe->id.".PM=stripe";
|
||||||
} elseif ($dol_type == invoice) {
|
} elseif ($origin == invoice) {
|
||||||
$invoice = new Facture($this->db);
|
$invoice = new Facture($this->db);
|
||||||
$invoice->fetch($dol_id);
|
$invoice->fetch($item);
|
||||||
$ref = $invoice->ref;
|
$ref = $invoice->ref;
|
||||||
$description = "INV=" . $ref . ".CUS=" . $societe->id.".PM=stripe";
|
$description = "INV=" . $ref . ".CUS=" . $societe->id.".PM=stripe";
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata = array(
|
$metadata = array(
|
||||||
"dol_id" => "" . $dol_id . "",
|
"dol_id" => "" . $item . "",
|
||||||
"dol_type" => "" . $dol_type . "",
|
"dol_type" => "" . $origin . "",
|
||||||
"dol_thirdparty_id" => "" . $societe->id . "",
|
"dol_thirdparty_id" => "" . $societe->id . "",
|
||||||
'dol_thirdparty_name' => $societe->name,
|
'dol_thirdparty_name' => $societe->name,
|
||||||
'dol_version'=>DOL_VERSION,
|
'dol_version'=>DOL_VERSION,
|
||||||
@ -426,7 +427,7 @@ class Stripe extends CommonObject
|
|||||||
if (preg_match('/acct_/i', $source))
|
if (preg_match('/acct_/i', $source))
|
||||||
{
|
{
|
||||||
$charge = \Stripe\Charge::create(array(
|
$charge = \Stripe\Charge::create(array(
|
||||||
"amount" => price2num($stripeamount, 'MU'),
|
"amount" => "$stripeamount",
|
||||||
"currency" => "$currency",
|
"currency" => "$currency",
|
||||||
"statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt
|
"statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt
|
||||||
"description" => "Stripe payment: ".$description,
|
"description" => "Stripe payment: ".$description,
|
||||||
@ -436,7 +437,7 @@ class Stripe extends CommonObject
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$paymentarray = array(
|
$paymentarray = array(
|
||||||
"amount" => price2num($stripeamount, 'MU'),
|
"amount" => "$stripeamount",
|
||||||
"currency" => "$currency",
|
"currency" => "$currency",
|
||||||
"statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt
|
"statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt
|
||||||
"description" => "Stripe payment: ".$description,
|
"description" => "Stripe payment: ".$description,
|
||||||
@ -455,13 +456,13 @@ class Stripe extends CommonObject
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$fee = round(($stripeamount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE) * 100);
|
$fee = round(($amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE) * 100);
|
||||||
if ($fee < ($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100)) {
|
if ($fee < ($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100)) {
|
||||||
$fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100);
|
$fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
$paymentarray = array(
|
$paymentarray = array(
|
||||||
"amount" => price2num($stripeamount, 'MU'),
|
"amount" => "$stripeamount",
|
||||||
"currency" => "$currency",
|
"currency" => "$currency",
|
||||||
"statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt
|
"statement_descriptor" => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 8, 'right', 'UTF-8', 1).' '.$description, 22, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt
|
||||||
"description" => "Stripe payment: ".$description,
|
"description" => "Stripe payment: ".$description,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user