Currently the payment storage does not allow creating a payment with a payment gateway object:

    $payment_gateway = $this->order->payment_gateway->entity;
    $payment_storage = $this->entityTypeManager->getStorage('commerce_payment');
    $payment = $payment_storage->create([
      'state' => 'new',
      'amount' => $this->order->getTotalPrice(),
      'payment_gateway' => $payment_gateway, // Not allowed
      'order_id' => $this->order->id(),
    ]);
CommentFileSizeAuthor
#2 2908419-2.patch797 bytesedaa
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

edwardaa created an issue. See original summary.

edaa’s picture

Status: Active » Needs review
FileSize
797 bytes
bojanz’s picture

You are right, this should be supported.

Let's replace !is_object with an is_string, I find positive checks to be more readable. We can also replace the isset() check on top of the method with an empty check to better handle empty strings or zeroes that might be accidentally passed.

Making the change now and pushing to Travis.

  • bojanz committed 2d5cd0a on 8.x-2.x authored by edwardaa
    Issue #2908419 by edwardaa: Allow for a payment gateway object when...
bojanz’s picture

Status: Needs review » Fixed

Travis build passed. Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.