protected function PaymentGatewayBase::getRemoteCustomerId in Commerce Core 8.2
Gets the remote customer ID for the given user.
The remote customer ID is specific to a payment gateway instance in the configured mode. This allows the gateway to skip test customers after the gateway has been switched to live mode.
Parameters
\Drupal\user\UserInterface $account: The user account.
Return value
string The remote customer ID, or NULL if none found.
1 call to PaymentGatewayBase::getRemoteCustomerId()
- Onsite::createPaymentMethod in modules/
payment_example/ src/ Plugin/ Commerce/ PaymentGateway/ Onsite.php - Creates a payment method with the given payment details.
File
- modules/
payment/ src/ Plugin/ Commerce/ PaymentGateway/ PaymentGatewayBase.php, line 487
Class
- PaymentGatewayBase
- Provides the base class for payment gateways.
Namespace
Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCode
protected function getRemoteCustomerId(UserInterface $account) {
$remote_id = NULL;
if ($account
->isAuthenticated()) {
$provider = $this->parentEntity
->id() . '|' . $this
->getMode();
/** @var \Drupal\commerce\Plugin\Field\FieldType\RemoteIdFieldItemListInterface $remote_ids */
$remote_ids = $account
->get('commerce_remote_id');
$remote_id = $remote_ids
->getByProvider($provider);
// Gateways used to key customer IDs by module name, migrate that data.
if (!$remote_id) {
$remote_id = $remote_ids
->getByProvider($this->pluginDefinition['provider']);
if ($remote_id) {
$remote_ids
->setByProvider($this->pluginDefinition['provider'], NULL);
$remote_ids
->setByProvider($provider, $remote_id);
$account
->save();
}
}
}
return $remote_id;
}