From 13eef54392e8a5f415c4c2eef0bdb8e3b0350ca4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 3 Aug 2019 12:31:13 +0200 Subject: [PATCH 1/5] Fix round for application fee in stripe --- htdocs/stripe/class/stripe.class.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index c731637fce6..28ba74fa91b 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -319,14 +319,14 @@ class Stripe extends CommonObject if (! in_array($currency_code, $arrayzerounitcurrency)) $stripeamount = $amount * 100; else $stripeamount = $amount; - $fee = round($amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE); + $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = round($conf->global->STRIPE_APPLICATION_FEE_MAXIMAL); + $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL); + $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } - if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = $fee * 100; - else $stripefee = $fee; + if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); + else $stripefee = round($fee); $paymentintent = null; @@ -708,15 +708,14 @@ class Stripe extends CommonObject $charge = \Stripe\Charge::create($paymentarray, array("idempotency_key" => "$description")); } } else { - $fee = round($amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE); - if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = round($conf->global->STRIPE_APPLICATION_FEE_MAXIMAL); - } - elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { - $fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL); - } - if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = $fee * 100; - else $stripefee = $fee; + $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE; + if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { + $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL; + } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { + $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; + } + if (! in_array($currency, $arrayzerounitcurrency)) $stripefee = round($fee * 100); + else $stripefee = round($fee); $paymentarray = array( "amount" => "$stripeamount", From 07cc21a113187c85887bdfe9844be9d370697067 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 3 Aug 2019 20:35:53 +0200 Subject: [PATCH 2/5] Fix display payment intent in stripe's charge list --- htdocs/stripe/charge.php | 47 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index e8823119e30..80c633b0254 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -121,6 +121,31 @@ if (!$rowid) //print $list; foreach ($list->data as $charge) { + if ($charge->refunded=='1'){ + $status = img_picto($langs->trans("refunded"), 'statut6'); + } elseif ($charge->paid=='1'){ + $status = img_picto($langs->trans("".$charge->status.""), 'statut4'); + } else { + $label="Message: ".$charge->failure_message."
"; + $label.="Réseau: ".$charge->outcome->network_status."
"; + $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); + $status = $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1); + } + + if ($charge->payment_method_details->type=='card') + { + $type = $langs->trans("card"); + } + elseif ($charge->source->type=='card'){ + $type = $langs->trans("card"); + } elseif ($charge->payment_method_details->type=='three_d_secure'){ + $type = $langs->trans("card3DS"); + } + + if (! empty($charge->payment_intent)) { + $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent); + } + // The metadata FULLTAG is defined by the online payment page $FULLTAG=$charge->metadata->FULLTAG; @@ -205,31 +230,13 @@ if (!$rowid) print ''.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."\n"; // Type print ''; - if ($charge->source->object=='card') - { - print $langs->trans("card"); - } - elseif ($charge->source->type=='card'){ - print $langs->trans("card"); - } elseif ($charge->source->type=='three_d_secure'){ - print $langs->trans("card3DS"); - } + print $type; print ''; // Amount print ''.price(($charge->amount-$charge->amount_refunded)/100, 0, '', 1, - 1, - 1, strtoupper($charge->currency)).""; // Status print ''; - if ($charge->refunded=='1'){ - print img_picto($langs->trans("refunded"), 'statut6'); - } elseif ($charge->paid=='1'){ - - print img_picto($langs->trans("".$charge->status.""), 'statut4'); - } else { - $label="Message: ".$charge->failure_message."
"; - $label.="Réseau: ".$charge->outcome->network_status."
"; - $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); - print $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1); - } + print $status; print "\n"; print "\n"; From 4ed1ff5b9bc9231ef2945494974da3ee3f8367df Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 3 Aug 2019 21:17:12 +0200 Subject: [PATCH 3/5] Fix display only stripe sources for customer --- htdocs/societe/paymentmodes.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index fdd4f54b6c8..4a34a2b360f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -822,7 +822,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
'; // List of Stripe payment modes - if (! (empty($conf->stripe->enabled))) + if (! (empty($conf->stripe->enabled)) && $object->client) { $morehtmlright=''; if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) @@ -1184,11 +1184,10 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } print ""; print ""; + print '
'; } - // List of bank accounts - print '
'; $morehtmlright= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create'); From 4633af3f5d84f175dd528d8c452138631172971d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 3 Aug 2019 21:19:47 +0200 Subject: [PATCH 4/5] Update charge.php --- htdocs/stripe/charge.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 80c633b0254..a524a62f6a3 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -130,16 +130,15 @@ if (!$rowid) $label.="Réseau: ".$charge->outcome->network_status."
"; $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); $status = $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1); - } + } if ($charge->payment_method_details->type=='card') { $type = $langs->trans("card"); - } - elseif ($charge->source->type=='card'){ - $type = $langs->trans("card"); + } elseif ($charge->source->type=='card'){ + $type = $langs->trans("card"); } elseif ($charge->payment_method_details->type=='three_d_secure'){ - $type = $langs->trans("card3DS"); + $type = $langs->trans("card3DS"); } if (! empty($charge->payment_intent)) { From 05ac4eec52c8fe5c585dbc8171ee891e45742e9e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 6 Aug 2019 00:16:18 +0200 Subject: [PATCH 5/5] Update charge.php --- htdocs/stripe/charge.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index a524a62f6a3..9d4bf71c040 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -133,13 +133,13 @@ if (!$rowid) } if ($charge->payment_method_details->type=='card') - { + { $type = $langs->trans("card"); - } elseif ($charge->source->type=='card'){ + } elseif ($charge->source->type=='card'){ $type = $langs->trans("card"); - } elseif ($charge->payment_method_details->type=='three_d_secure'){ + } elseif ($charge->payment_method_details->type=='three_d_secure'){ $type = $langs->trans("card3DS"); - } + } if (! empty($charge->payment_intent)) { $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);