public function Echeck::createPaymentMethod in Commerce Authorize.Net 8
@todo Needs kernel test
Overrides SupportsCreatingPaymentMethodsInterface::createPaymentMethod
File
- src/
Plugin/ Commerce/ PaymentGateway/ Echeck.php, line 169
Class
- Echeck
- Provides the Authorize.net echeck payment gateway.
Namespace
Drupal\commerce_authnet\Plugin\Commerce\PaymentGatewayCode
public function createPaymentMethod(PaymentMethodInterface $payment_method, array $payment_details) {
$required_keys = [
'data_descriptor',
'data_value',
];
foreach ($required_keys as $required_key) {
if (empty($payment_details[$required_key])) {
throw new \InvalidArgumentException(sprintf('$payment_details must contain the %s key.', $required_key));
}
}
// Reusing echecks is not supported at the moment.
// @see https://community.developer.authorize.net/t5/Integration-and-Testing/Accept-JS-and-ACH/td-p/55874
$payment_method
->setReusable(FALSE);
$payment_method
->setRemoteId($payment_details['data_descriptor'] . '|' . $payment_details['data_value']);
// OpaqueData expire after 15min. We reduce that time by 5s to account for
// the time it took to do the server request after the JS tokenization.
$expires = $this->time
->getRequestTime() + 15 * 60 - 5;
$payment_method
->setExpiresTime($expires);
$payment_method
->save();
}