NF_Actions_CollectPayment

Class NF_Action_CollectPayment.

Defined (1)

The class is defined in the following location(s).

/includes/Actions/CollectPayment.php  
  1. final class NF_Actions_CollectPayment extends NF_Abstracts_Action 
  2. /** 
  3. * @var string 
  4. */ 
  5. protected $_name = 'collectpayment'; 
  6.  
  7. /** 
  8. * @var array 
  9. */ 
  10. protected $_tags = array(); 
  11.  
  12. /** 
  13. * @var string 
  14. */ 
  15. protected $_timing = 'late'; 
  16.  
  17. /** 
  18. * @var int 
  19. */ 
  20. protected $_priority = 0; 
  21.  
  22. /** 
  23. * @var array 
  24. */ 
  25. protected $payment_gateways = array(); 
  26.  
  27. /** 
  28. * Constructor 
  29. */ 
  30. public function __construct() 
  31. parent::__construct(); 
  32.  
  33. $this->_nicename = __( 'Collect Payment', 'ninja-forms' ); 
  34.  
  35. $settings = Ninja_Forms::config( 'ActionCollectPaymentSettings' ); 
  36.  
  37. $this->_settings = array_merge( $this->_settings, $settings ); 
  38.  
  39. add_action( 'ninja_forms_loaded', array( $this, 'register_payment_gateways' ), -1 ); 
  40.  
  41. add_filter( 'ninja_forms_action_type_settings', array( $this, 'maybe_remove_action' ) ); 
  42.  
  43. public function save( $action_settings ) 
  44.  
  45.  
  46. public function process( $action_settings, $form_id, $data ) 
  47. $payment_gateway = $action_settings[ 'payment_gateways' ]; 
  48.  
  49. $payment_gateway_class = $this->payment_gateways[ $payment_gateway ]; 
  50.  
  51. return $payment_gateway_class->process( $action_settings, $form_id, $data ); 
  52.  
  53. public function register_payment_gateways() 
  54. $this->payment_gateways = apply_filters( 'ninja_forms_register_payment_gateways', array() ); 
  55.  
  56. foreach( $this->payment_gateways as $gateway ) { 
  57.  
  58. if( ! is_subclass_of( $gateway, 'NF_Abstracts_PaymentGateway' ) ) { 
  59. continue; 
  60.  
  61. $this->_settings[ 'payment_gateways' ][ 'options' ][] = array( 
  62. 'label' => $gateway->get_name(),  
  63. 'value' => $gateway->get_slug(),  
  64. ); 
  65.  
  66. $this->_settings = array_merge( $this->_settings, $gateway->get_settings() ); 
  67.  
  68. public function maybe_remove_action( $action_type_settings ) 
  69. if( empty( $this->payment_gateways ) ) { 
  70. unset( $action_type_settings[ $this->_name ] ); 
  71.  
  72. return $action_type_settings;