From ef4659c518dfd03b22b5bdd4bd685bdddb64a812 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 11 Sep 2018 10:59:25 +0200 Subject: [PATCH] add capture option in payment function Conflicts: htdocs/stripe/class/stripe.class.php --- htdocs/stripe/class/stripe.class.php | 31 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 895ade49d09..901997cef3b 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -335,18 +335,19 @@ class Stripe extends CommonObject /** * Create charge with public/payment/newpayment.php, stripe/card.php, cronjobs or REST API * - * @param int $amount Amount to pay - * @param string $currency EUR, GPB... - * @param string $origin Object type to pay (order, invoice, contract...) - * @param int $item Object id to pay - * @param string $source src_xxxxx or card_xxxxx - * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() - * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() + * @param int $amount Amount to pay + * @param string $currency EUR, GPB... + * @param string $origin Object type to pay (order, invoice, contract...) + * @param int $item Object id to pay + * @param string $source src_xxxxx or card_xxxxx + * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param string $account Stripe account ref 'acc_xxxxxxxxxxxxx' via getStripeAccount() * @param int $status Status (0=test, 1=live) * @param int $usethirdpartyemailforreceiptemail Use thirdparty email as receipt email + * @param boolean $capture Set capture flag to true (take payment) or false (wait) * @return Stripe */ - public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account, $status=0, $usethirdpartyemailforreceiptemail=0) + public function createPaymentStripe($amount, $currency, $origin, $item, $source, $customer, $account, $status=0, $usethirdpartyemailforreceiptemail=0, $capture=true) { global $conf; @@ -417,9 +418,9 @@ class Stripe extends CommonObject $charge = \Stripe\Charge::create(array( "amount" => "$stripeamount", "currency" => "$currency", - "capture" => true, "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, + "capture" => $capture, "metadata" => $metadata, "source" => "$source" )); @@ -427,9 +428,9 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "capture" => true, - "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, + "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, + "capture" => $capture, "metadata" => $metadata, "source" => "$source", "customer" => "$customer" @@ -452,9 +453,9 @@ class Stripe extends CommonObject $paymentarray = array( "amount" => "$stripeamount", "currency" => "$currency", - "capture" => true, "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, + "capture" => $capture, "metadata" => $metadata, "source" => "$source", "customer" => "$customer"