diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index a17725225b08..5af1cbf05ab2 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -61,7 +61,7 @@ class ACH try { $source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], $this->stripe->stripe_connect_auth); - // $source = $this->stripe->stripe->customers->createSource($customer->id, ['source' => $stripe_response->token->id]); + } catch (InvalidRequestException $e) { throw new PaymentFailed($e->getMessage(), $e->getCode()); } diff --git a/app/PaymentDrivers/Stripe/ImportCustomers.php b/app/PaymentDrivers/Stripe/ImportCustomers.php index 1fae465da08d..2baf26d5bbd5 100644 --- a/app/PaymentDrivers/Stripe/ImportCustomers.php +++ b/app/PaymentDrivers/Stripe/ImportCustomers.php @@ -142,6 +142,32 @@ class ImportCustomers $this->update_payment_methods->updateMethods($customer, $client); } + public function importCustomer($customer_id) + { + + $this->stripe->init(); + + $this->update_payment_methods = new UpdatePaymentMethods($this->stripe); + + if(strlen($this->stripe->company_gateway->getConfigField('account_id')) < 1) + throw new StripeConnectFailure('Stripe Connect has not been configured'); + + $customer = Customer::retrieve($customer_id, $this->stripe_connect_auth); + + if(!$customer) + return; + + foreach($this->stripe->company_gateway->company->clients as $client) + { + if($client->present()->email() == $customer->email) { + + $this->update_payment_methods->updateMethods($customer, $client); + + } + } + + } + public function match() { $this->stripe->init(); diff --git a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php index 596356a83148..74d09d4abe26 100644 --- a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php +++ b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php @@ -93,6 +93,12 @@ class UpdatePaymentMethods $this->addOrUpdateCard($method, $customer->id, $client, GatewayType::SOFORT); } + //$this->importBankAccounts($customer, $client); + } + + private function importBankAccounts($customer, $client) + { + } // private function addOrUpdateBankAccount($bank_account, $customer_reference, Client $client) diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 0dce16d84d16..7231cebbffc4 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -550,6 +550,11 @@ class StripePaymentDriver extends BaseDriver return (new ImportCustomers($this))->match(); } + public function importCustomer($customer_id) + { + return (new ImportCustomers($this))->importCustomer($customer_id); + } + public function verifyConnect() { return (new Verify($this))->run();