diff --git a/src/Service/CustomerService.php b/src/Service/CustomerService.php index 938c10723..854d8455b 100644 --- a/src/Service/CustomerService.php +++ b/src/Service/CustomerService.php @@ -584,7 +584,7 @@ public function createMollieCustomer(string $customerId, string $salesChannelId, throw new CustomerCouldNotBeFoundException($customerId); } - $mollieCustomer = $this->customerApiService->createCustomerAtMollie($customer); + $mollieCustomer = $this->customerApiService->createCustomerAtMollie($customer, $salesChannelId); $this->setMollieCustomerId( $customerId, diff --git a/src/Service/MollieApi/Customer.php b/src/Service/MollieApi/Customer.php index 5a4444298..38a21a84b 100644 --- a/src/Service/MollieApi/Customer.php +++ b/src/Service/MollieApi/Customer.php @@ -43,10 +43,10 @@ public function getMollieCustomerById(string $customerId, string $salesChannelId * @throws CouldNotCreateMollieCustomerException * @return MollieCustomer */ - public function createCustomerAtMollie(CustomerEntity $customer): MollieCustomer + public function createCustomerAtMollie(CustomerEntity $customer, string $salesChannelId): MollieCustomer { try { - $apiClient = $this->clientFactory->getClient($customer->getSalesChannelId()); + $apiClient = $this->clientFactory->getClient($salesChannelId); return $apiClient->customers->create([ 'name' => $customer->getFirstName() . ' ' . $customer->getLastName(), diff --git a/tests/PHPUnit/Service/MollieApi/CustomerTest.php b/tests/PHPUnit/Service/MollieApi/CustomerTest.php index 7f5f6a496..fa0ed423d 100644 --- a/tests/PHPUnit/Service/MollieApi/CustomerTest.php +++ b/tests/PHPUnit/Service/MollieApi/CustomerTest.php @@ -74,7 +74,7 @@ public function testCreatingNewCustomerAtMollie() 'getSalesChannelId' => 'buzz', ]); - $actualInstance = $this->customerApiService->createCustomerAtMollie($customerMock); + $actualInstance = $this->customerApiService->createCustomerAtMollie($customerMock,'buzz'); $this->assertInstanceOf(Customer::class, $actualInstance); } @@ -91,7 +91,7 @@ public function testCreatingNewCustomerAtMollieWithExistingEmailAddress() 'getSalesChannelId' => 'buzz', ]); - $this->customerApiService->createCustomerAtMollie($customerMock); + $this->customerApiService->createCustomerAtMollie($customerMock,'buzz'); } /**