From 3c15da9dde802c1c87c7dd9156c47595717f34ca Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 4 Aug 2018 14:30:52 +0200 Subject: [PATCH] Fix payment in connect mode I know that it's not an optimal fix but it's functionnal for dolibarr 8.0.0 release --- htdocs/stripe/class/stripe.class.php | 32 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index b8472d0b821..bab3fc5f18c 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -425,19 +425,25 @@ class Stripe extends CommonObject $fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100); } - $charge = \Stripe\Charge::create(array( - "amount" => "$stripeamount", - "currency" => "$currency", - // "statement_descriptor" => " ", - "description" => "$description", - "metadata" => $metadata, - "source" => "$source", - "customer" => "$customer", - "application_fee" => "$fee" - ), array( - "idempotency_key" => "$ref", - "stripe_account" => "$account" - )); + $paymentarray = array( + "amount" => "$stripeamount", + "currency" => "$currency", + // "statement_descriptor" => " ", + "description" => "$description", + "metadata" => $metadata, + "source" => "$source", + "customer" => "$customer" + ); + if ($conf->entity>1 && $fee>0) + { + $paymentarray["application_fee"] = $fee; + } + if ($societe->email && $usethirdpartyemailforreceiptemail) + { + $paymentarray["receipt_email"] = $societe->email; + } + + $charge = \Stripe\Charge::create($paymentarray, array("idempotency_key" => "$ref","stripe_account" => "$account")); } if (isset($charge->id)) {}