Started messing with this.
There are a few things that would need to be done to make it work.- The
card_type
on 7 is not the actual card type like visa or mastercard. - Would need to get the billing profiles, as there are no billing profiles associated in Drupal 7 payment methods.
- The remote ids are formatted differently. on 7 they are 9999999|99999999 with a pipe in the middle.
Here is the source plugin:
<?php namespace Drupal\MY_MODULE\Plugin\migrate\source; use Drupal\migrate\Plugin\migrate\source\SqlBase; use Drupal\migrate\Row; /** * Migrate Source plugin. * * @MigrateSource( * id = "stored_payment_method" * ) */ class PaymentMethod extends SqlBase { /** * {@inheritdoc} */ public function query() { $query = $this->select('commerce_cardonfile', 'c') ->fields('c', [ 'card_id', 'uid', 'payment_method', 'instance_id', 'remote_id', 'card_type', 'card_name', 'card_number', 'card_exp_month', 'card_exp_year', 'instance_default', 'status', 'created', 'changed', ]); return $query; } /** * {@inheritdoc} */ public function fields() { $fields = [ 'card_id' => $this->t('Card ID'), 'uid' => $this->t('User ID'), 'payment_method' => $this->t('Payment method'), 'instance_id' => $this->t('Instance ID'), 'remote_id' => $this->t('Remote ID'), 'card_type' => $this->t('Card type'), 'card_name' => $this->t('Card name'), 'card_number' => $this->t('Card number'), 'card_exp_month' => $this->t('Card expiration month'), 'card_exp_year' => $this->t('Card expiration year'), 'instance_default' => $this->t('Whether the card is default'), 'status' => $this->t('Status'), 'created' => $this->t('Created time'), 'changed' => $this->t('Changed time'), ]; return $fields; } /** * {@inheritdoc} */ public function getIds() { return [ 'card_id' => [ 'type' => 'integer', 'alias' => 'c', ], ]; } /** * {@inheritdoc} */ public function prepareRow(Row $row) { // // Get Field API field values. // foreach (array_keys($this->getFields('flagging', $row->getSourceProperty('name'))) as $field) { // $flagging_id = $row->getSourceProperty('flagging_id'); // $row->setSourceProperty($field, $this->getFieldValues('flagging', $field, $flagging_id)); // } return parent::prepareRow($row); } }
langcode: en status: true dependencies: { } id: commerce1_payment_method class: null field_plugin_method: null cck_plugin_method: null migration_tags: { } migration_group: migrate_drupal_7 label: 'Payment Method' source: plugin: stored_payment_method process: type: plugin: default_value default_value: credit_card uid: - plugin: get source: uid payment_gateway: - plugin: static_map source: payment_method map: authnet_acceptjs: authorize_net_accept_js - plugin: skip_on_empty method: row payment_gateway_mode: - plugin: default_value default_value: test remote_id: - plugin: get source: remote_id reusable: - plugin: default_value default_value: 1 is_default: - plugin: get source: instance_default created: created changed: changed card_exp_month: - plugin: get source: card_exp_month card_exp_year: - plugin: get source: card_exp_year card_number: - plugin: get source: card_number card_type: - plugin: default_value default_value: visa destination: plugin: 'entity:commerce_payment_method' destination_module: commerce_payment migration_dependencies: required: { }
- The