How do I get information about the payment method from the order object programmatically? I'm trying to do some different processing after an order is placed depending on which payment method a customer uses.

In my EventSubscriber, I have the following code:

 public static function getSubscribedEvents() {
    $events = [
      'commerce_order.place.post_transition' =&gt; 'onPlaceTransition'
    ];
    return $events;
  }

  public function onPlaceTransition(WorkflowTransitionEvent $event) {
    $order = $event-&gt;getEntity();


Now I want to get the name or id of the payment method that was used from the order, but when I used kint($order) I couldn't find a way to access the payment method.

How do I access the payment method given an $order object?
The Commerce Payment module adds the payment_method base field when it is enabled, see commerce_payment_entity_base_field_info https://github.com/drupalcommerce/commerce/blob/8.x-2.x/modules/payment/commerce_payment.module#L28

You can access the payment method (and gateway) through

$order-&gt;get('payment_method')-&gt;first()-&gt;entity
$order-&gt;get('payment_gateway')-&gt;first()-&gt;entity


Example of when we get the payment method label for the order receipt email.

if (!$order-&gt;get('payment_method')-&gt;isEmpty()) {
  $variables['payment_method'] = [
    '#markup' =&gt; $order-&gt;get('payment_method')-&gt;first()-&gt;entity-&gt;label(),
  ];
}


From https://github.com/drupalcommerce/commerce/blob/77b25bf4889a940eed6652475c3952c36144efc0/modules/payment/commerce_payment.module#L122