src/migrations/Install.php
private function _convertGateways()
    {
        $gateways = (new Query())
            ->select(['id', 'settings'])
            ->where(['type' => 'craft\\commerce\\gateways\\Stripe'])
            ->from(['{{%commerce_gateways}}'])
            ->all();

        $dbConnection = Craft::$app->getDb();

        foreach ($gateways as $gateway) {

            $settings = Json::decodeIfJson($gateway['settings']);

            if ($settings && isset($settings['includeReceiptEmailInRequests'])) {
                $settings['sendReceiptEmail'] = $settings['includeReceiptEmailInRequests'];
                unset($settings['includeReceiptEmailInRequests']);
            } else {
                $settings = [];
            }

            $settings = Json::encode($settings);

            $values = [
                'type' => Gateway::class,
                'settings' => $settings
            ];

            $dbConnection->createCommand()
                ->update('{{%commerce_gateways}}', $values, ['id' => $gateway['id']])
                ->execute();
        }
    }
private function _convertGateways()
    {
        $gateways = (new Query())
            ->select(['id', 'settings'])
            ->where(['type' => 'craft\\commerce\\gateways\\Stripe'])
            ->from(['{{%commerce_gateways}}'])
            ->all();

        $dbConnection = Craft::$app->getDb();

        foreach ($gateways as $gateway) {

            $settings = Json::decodeIfJson($gateway['settings']);

            if ($settings && isset($settings['includeReceiptEmailInRequests'])) {
                $settings['sendReceiptEmail'] = $settings['includeReceiptEmailInRequests'];
                unset($settings['includeReceiptEmailInRequests']);
            } else {
                $settings = [];
            }

            $settings = Json::encode($settings);

            $values = [
                'type' => Gateway::class,
                'settings' => $settings
            ];

            $dbConnection->createCommand()
                ->update('{{%commerce_gateways}}', $values, ['id' => $gateway['id']])
                ->execute();
        }
    }
private function _convertGateways ( ) { $ gateways = ( new Query ( ) ) -> select ( [ 'id' , 'settings' ] ) -> where ( [ 'type' => 'craft\\commerce\\gateways\\Stripe' ] ) -> from ( [ '{{%commerce_gateways}}' ] ) -> all ( ) ; $ dbConnection = Craft :: $ app -> getDb ( ) ; foreach ( $ gateways as $ gateway ) { $ settings = Json :: decodeIfJson ( $ gateway [ 'settings' ] ) ; if ( $ settings && isset ( $ settings [ 'includeReceiptEmailInRequests' ] ) ) { $ settings [ 'sendReceiptEmail' ] = $ settings [ 'includeReceiptEmailInRequests' ] ; unset ( $ settings [ 'includeReceiptEmailInRequests' ] ) ; } else { $ settings = [ ] ; } $ settings = Json :: encode ( $ settings ) ; $ values = [ 'type' => Gateway :: class , 'settings' => $ settings ] ; $ dbConnection -> createCommand ( ) -> update ( '{{%commerce_gateways}}' , $ values , [ 'id' => $ gateway [ 'id' ] ] ) -> execute ( ) ; } }
Converts any old school Stripe gateways to this one
Converts any old school Stripe gateways to this one