Esempio n. 1
0
 * @license   http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
 * @link      http://www.x-cart.com/
 */
return function () {
    $method = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Method')->findOneBy(array('service_name' => 'Stripe'));
    if ($method) {
        $isInTestMode = \XLite\View\FormField\Select\TestLiveMode::TEST === $method->getSetting('mode');
        $accessToken = $method->getSetting('accessToken');
        $publishKey = $method->getSetting('publishKey');
        $setting = new \XLite\Model\Payment\MethodSetting();
        $setting->setName('accessTokenTest');
        $setting->setValue($isInTestMode ? $accessToken : '');
        $setting->setPaymentMethod($method);
        $setting->persist();
        $method->addSettings($setting);
        $setting = new \XLite\Model\Payment\MethodSetting();
        $setting->setName('publishKeyTest');
        $setting->setValue($isInTestMode ? $publishKey : '');
        $setting->setPaymentMethod($method);
        $setting->persist();
        $method->addSettings($setting);
        if ($isInTestMode) {
            foreach ($method->getSettings() as $setting) {
                if (in_array($setting->getName(), array('accessToken', 'publishKey'))) {
                    $setting->setValue('');
                }
            }
        }
        \XLite\Core\Database::getEM()->flush();
    }
};