MS_Gateway_Free

Free Gateway.

Defined (1)

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

/app/gateway/free/class-ms-gateway-free.php  
  1. class MS_Gateway_Free extends MS_Gateway { 
  2.  
  3. const ID = 'free'; 
  4.  
  5. /** 
  6. * Gateway singleton instance. 
  7. * @since 1.0.0 
  8. * @var string $instance 
  9. */ 
  10. public static $instance; 
  11.  
  12. /** 
  13. * Hook to show payment info. 
  14. * This is called by the MS_Factory 
  15. * @since 1.0.0 
  16. */ 
  17. public function after_load() { 
  18. parent::after_load(); 
  19.  
  20. $this->id = self::ID; 
  21. $this->name = __( 'Free Gateway', 'membership2' ); 
  22. $this->group = ''; 
  23. $this->active = true; 
  24. $this->manual_payment = true; // Recurring billed/paid manually 
  25.  
  26. /** 
  27. * Return status if all fields are configured 
  28. * @since 1.0.0 
  29. * @return bool 
  30. */ 
  31. public function is_configured() { 
  32. // Free products need no payment-configuration. Always true. 
  33. return true; 
  34.  
  35. /** 
  36. * Processes purchase action. 
  37. * This can happen when a 100% coupon is applied and an otherwise paid 
  38. * membership becomes a free membership during checkout. 
  39. * We need to confirm that it's actually free and mark it paid. 
  40. * @since 1.0.0 
  41. * @param MS_Model_Relationship $subscription The related membership relationship. 
  42. */ 
  43. public function process_purchase( $subscription ) { 
  44. do_action( 
  45. 'ms_gateway_free_process_purchase_before',  
  46. $subscription,  
  47. $this 
  48. ); 
  49.  
  50. $invoice = $subscription->get_current_invoice(); 
  51.  
  52. if ( 0 == $invoice->total || $invoice->uses_trial ) { 
  53. // Free, just process. 
  54. $invoice->pay_it( self::ID, '' ); 
  55.  
  56. return apply_filters( 
  57. 'ms_gateway_free_process_purchase',  
  58. $invoice,  
  59. $this 
  60. ); 
  61.