public function HostedFields::deletePaymentMethod in Commerce Braintree 8
Deletes the given payment method.
Both the entity and the remote record are deleted.
Parameters
\Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method: The payment method.
Throws
\Drupal\commerce_payment\Exception\PaymentGatewayException Thrown when the transaction fails for any reason.
Overrides SupportsStoredPaymentMethodsInterface::deletePaymentMethod
File
- src/
Plugin/ Commerce/ PaymentGateway/ HostedFields.php, line 502
Class
- HostedFields
- Provides the HostedFields payment gateway.
Namespace
Drupal\commerce_braintree\Plugin\Commerce\PaymentGatewayCode
public function deletePaymentMethod(PaymentMethodInterface $payment_method) {
// Delete the remote record.
try {
$result = $this->api
->paymentMethod()
->delete($payment_method
->getRemoteId());
ErrorHelper::handleErrors($result);
} catch (BraintreeException $e) {
ErrorHelper::handleException($e);
}
// Delete the local entity.
$payment_method
->delete();
}