public function PurchaseOrderGateway::createPayment in Commerce Purchase Order 8
Creates a payment.
Parameters
\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment.
bool $capture: Whether the created payment should be captured (VS authorized only). Allowed to be FALSE only if the plugin supports authorizations.
Throws
\InvalidArgumentException If $capture is FALSE but the plugin does not support authorizations.
\Drupal\commerce_payment\Exception\PaymentGatewayException Thrown when the transaction fails for any reason.
Overrides SupportsStoredPaymentMethodsInterface::createPayment
File
- src/
Plugin/ Commerce/ PaymentGateway/ PurchaseOrderGateway.php, line 151
Class
- PurchaseOrderGateway
- Provides the On-site payment gateway.
Namespace
Drupal\commerce_purchase_order\Plugin\Commerce\PaymentGatewayCode
public function createPayment(PaymentInterface $payment, $capture = TRUE) {
$this
->assertPaymentState($payment, [
'new',
]);
$this
->authorizePayment($payment);
$this
->assertAuthorized($payment);
$payment_method = $payment
->getPaymentMethod();
$this
->assertPaymentMethod($payment_method);
$payment
->setState('completed');
$payment
->save();
}