Skip to main content
edited title
Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91

How to change payment state programmiticallyprogrammatically?

Coding standards, title
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

How to change payment state in drupal 8 programmitically?

I had created a custom module to update order state and payment state. In my controller iI used the following code to change the order state of order.

 $order = \Drupal\commerce_order\Entity\Order::load($order_id);
      
 if ($payment_status === 'payment.captured' ){
        $order->set('state', 'completed' );
        $order->save();
      }
      else {
        $order->set('state', 'pending' );
        $order->save();
      }
      
     }

Similarly how can i changeHow can I now change the payment state of a payment which comes inside that order?

This is the payment statescreenshot of amy payment which comes inside that order. Now the payment state is pending. I want to change it to something else by using code, for example completed.

This is the screenshot of my payment. Now the payment state is pending , I want to change it to something else by using code,for example completed

How to change payment state in drupal 8 programmitically?

I had created a custom module to update order state and payment state. In my controller i used the following code to change the order state of order.

 $order = \Drupal\commerce_order\Entity\Order::load($order_id);
      if($payment_status === 'payment.captured' ){
        $order->set('state', 'completed' );
        $order->save();
      }
      else{
        $order->set('state', 'pending' );
        $order->save();
      }
      
     }

Similarly how can i change the payment state of a payment which comes inside that order.

This is the screenshot of my payment. Now the payment state is pending , I want to change it to something else by using code,for example completed

How to change payment state programmitically?

I had created a custom module to update order state and payment state. In my controller I used the following code to change the order state of order.

 $order = \Drupal\commerce_order\Entity\Order::load($order_id);
  
 if ($payment_status === 'payment.captured'){
   $order->set('state', 'completed');
   $order->save();
 }
 else {
   $order->set('state', 'pending');
   $order->save();
 }
      

How can I now change the payment state of a payment which comes inside that order?

This is the screenshot of my payment. Now the payment state is pending. I want to change it to something else by using code, for example completed.

This is the screenshot of my payment. Now the payment state is pending , I want to change it to something else by using code,for example completed

Source Link
Rifas Ali
  • 510
  • 3
  • 8
  • 19

How to change payment state in drupal 8 programmitically?

I had created a custom module to update order state and payment state. In my controller i used the following code to change the order state of order.

 $order = \Drupal\commerce_order\Entity\Order::load($order_id);
      if($payment_status === 'payment.captured' ){
        $order->set('state', 'completed' );
        $order->save();
      }
      else{
        $order->set('state', 'pending' );
        $order->save();
      }
      
    }

Similarly how can i change the payment state of a payment which comes inside that order.

This is the screenshot of my payment. Now the payment state is pending , I want to change it to something else by using code,for example completed