Right now i have a payment method called "Transferência Bancária" and I need it to change to the workflow state "Awaiting Transferencia" automatically when that payment method is selected.
Is it possible to do programmatically?
I'm stuck at:
$order = $event->getEntity(); if(($order->getPaymentGateway()) == ('transferencia')) { $order->set('state', 'aguardando_transferencia'); }
on my /modules/workflowtkn/src/EventSubscriber/WorkflowTknProcessSubscriber.php
Error: Call to undefined method Drupal\commerce_order\Entity\Order::getPaymentGateway()
EDIT: I'm having troubles calling the function "getPaymentGateway()" because is in another module, can somebody help, please :) It has to be corresponded to the order.
I've tried $gateway = \Drupal::service('plugin.manager.commerce_payment_method_type');
but it says can't convert to string...
This:
$payment = $order->get('payment_gateway')->first()->entity
Gives me:
Warning: htmlspecialchars() expects parameter 1 to be string, object given in Drupal\Component\Utility\Html::escape() .
I've looked at How do I get information about the payment method from the order object programmatically?
but can't figure it out.
I guess i'm failing to convert to string?
EDIT: When I use json_encode: json_encode($order->get('payment_gateway')->first()->entity)
it only returns "{}"