/** * Test saveAction controller action - change payment mean * * Get a random customer. Change payment method to debit */ public function testChangeCustomerPaymentMean() { $dummyData = new \Shopware\Models\Customer\Customer(); $dummyData->setEmail('*****@*****.**'); $this->manager->persist($dummyData); $this->manager->flush(); $this->assertEquals(0, $dummyData->getPaymentId()); $debit = $this->manager->getRepository('Shopware\\Models\\Payment\\Payment')->findOneBy(array('name' => 'debit')); $params = array('id' => $dummyData->getId(), 'paymentId' => $debit->getId()); $this->Request()->setMethod('POST')->setPost($params); $this->dispatch('/backend/Customer/save'); $jsonBody = $this->View()->getAssign(); $this->assertTrue($this->View()->success); $this->assertEquals($debit->getId(), $jsonBody['data']['paymentId']); $this->manager->refresh($dummyData); $this->assertEquals($debit->getId(), $dummyData->getPaymentId()); $this->manager->remove($dummyData); $this->manager->flush(); }
/** * Checks if payment methods are hidden by session. Methods will be hide just in live/production mode * * @return bool */ public function isRatepayHidden() { $config = Shopware()->Plugins()->Frontend()->RpayRatePay()->Config(); $country = Shopware()->Models()->find('Shopware\\Models\\Country\\Country', $this->_user->getBilling()->getCountryId())->getIso(); if ('DE' === $country || 'AT' === $country || 'CH' === $country) { $sandbox = $config->get('RatePaySandbox' . $country); } if (true === Shopware()->Session()->RatePAY['hidePayment'] && false === $sandbox) { return true; } else { return false; } }
/** * @param array $customerData * @return Shopware\Models\Customer\Customer */ protected function saveCustomer($customerData) { $customerData = $this->toUtf8($customerData); $customerRepository = $this->getCustomerRepository(); /** @var \Shopware\Components\Api\Resource\Customer $customerResource */ $customerResource = \Shopware\Components\Api\Manager::getResource('customer'); $customerModel = null; if (empty($customerData['email'])) { return false; } // userId and custumernumber will be ignored as there is not distinction between accountmode 0 and 1 in // old export files if (!empty($customerData['email']) && !empty($customerData['subshopID'])) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = $customerRepository->findOneBy(array('email' => $customerData['email'], 'shopId' => $customerData['subshopID'])); } elseif (!empty($customerData['email'])) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = $customerRepository->findOneBy(array('email' => $customerData['email'])); } // if no user was found by email, its save to find one via customernumber if (!$customerModel && !empty($customerData['customernumber'])) { /** \Shopware\Models\Customer\Billing $billingModel */ $billingModel = Shopware()->Models()->getRepository('\\Shopware\\Models\\Customer\\Billing')->findOneBy(array('number' => $customerData['customernumber'])); if ($billingModel) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = $billingModel->getCustomer(); } } if (!$customerModel) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = new \Shopware\Models\Customer\Customer(); } $customerData = $this->prepareCustomerData($customerData); if ($customerModel->getId() > 0) { $result = $customerResource->update($customerModel->getId(), $customerData); } else { $result = $customerResource->create($customerData); } return $result; }
/** * @param array $customerData * @return Shopware\Models\Customer\Customer */ protected function saveCustomer($customerData) { $customerData = $this->toUtf8($customerData); $customerRepository = $this->getCustomerRepository(); /** @var \Shopware\Components\Api\Resource\Customer $customerResource */ $customerResource = \Shopware\Components\Api\Manager::getResource('customer'); if (empty($customerData['userID']) && empty($customerData['email'])) { return false; } if (!empty($customerData['userID'])) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = $customerRepository->find($customerData['userID']); if (!$customerModel) { return false; } } elseif (!empty($customerData['email']) && empty($customerData['subshopID'])) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = $customerRepository->findOneBy(array('email' => $customerData['email'], 'shopId' => $customerData['subshopID'])); } elseif (!empty($customerData['email'])) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = $customerRepository->findOneBy(array('email' => $customerData['email'])); } if (!$customerModel) { /** \Shopware\Models\Customer\Customer $customerModel */ $customerModel = new \Shopware\Models\Customer\Customer(); } $customerData = $this->prepareCustomerData($customerData); if ($customerModel->getId() > 0) { $result = $customerResource->update($customerModel->getId(), $customerData); } else { $result = $customerResource->create($customerData); } return $result; }