Fany_VanDaal

Vložení Stripe platební metody do Superfaktury

Apr 9th, 2020
117
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Pridanie Stripe do zoznamu SF platobnych metod
  3.  *
  4.  * @param array $gateway_mappings
  5.  * @return array
  6.  */
  7. function pmo_modify_sf_mappings($gateway_mappings) {
  8.     $new = array(
  9.                 'stripe' => __('Stripe', 'woocommerce')
  10.             );
  11.  
  12.     return array_merge($gateway_mappings, $new);
  13. }
  14. add_filter('sf_gateway_mapping', 'pmo_modify_sf_mappings', 10, 1);
  15.  
  16. /**
  17.  * Superfaktura - automaticke oznacenie zrealizovanej platby
  18.  *
  19.  * @param boolean $is_paid
  20.  * @param WC_Order $order
  21.  * @return boolean
  22.  */
  23. function pmo_set_paid_invoice($is_paid, $order) {
  24.     $payment_method = $order->get_payment_method();
  25.     $set_as_paid = array('paypal', 'stripe');
  26.  
  27.     if ( $order->get_status() == 'processing' && in_array($payment_method, $set_as_paid) !== false ) {
  28.         return true;
  29.     }
  30.  
  31.     return $is_paid;
  32. }
  33. add_filter( 'woocommerce_sf_order_is_paid', 'pmo_set_paid_invoice', 10, 2 );
RAW Paste Data Copied