Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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(),
]);
Comment | File | Size | Author |
---|---|---|---|
#2 | 2908419-2.patch | 797 bytes | edaa |
Comments
Comment #2
edaa CreditAttribution: edaa commentedPR https://github.com/drupalcommerce/commerce/pull/793
Comment #3
bojanz CreditAttribution: bojanz at Centarro commentedYou 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.
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedTravis build passed. Committed. Thanks!