public function Manual::receivePayment in Commerce Core 8.2
Receives the given payment.
Parameters
\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment.
\Drupal\commerce_price\Price $amount: The received amount. If NULL, defaults to the entire payment amount.
Overrides ManualPaymentGatewayInterface::receivePayment
File
- modules/
payment/ src/ Plugin/ Commerce/ PaymentGateway/ Manual.php, line 197
Class
- Manual
- Provides the Manual payment gateway.
Namespace
Drupal\commerce_payment\Plugin\Commerce\PaymentGatewayCode
public function receivePayment(PaymentInterface $payment, Price $amount = NULL) {
$this
->assertPaymentState($payment, [
'pending',
]);
// If not specified, use the entire amount.
$amount = $amount ?: $payment
->getAmount();
$payment->state = 'completed';
$payment
->setAmount($amount);
$payment
->save();
}