MS_Gateway_Authorize_View_Button

The Membership 2 MS Gateway Authorize View Button class.

Defined (1)

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

/app/gateway/authorize/view/class-ms-gateway-authorize-view-button.php  
  1. class MS_Gateway_Authorize_View_Button extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $fields = $this->prepare_fields(); 
  5. $subscription = $this->data['ms_relationship']; 
  6. $invoice = $subscription->get_current_invoice(); 
  7. $gateway = $this->data['gateway']; 
  8.  
  9. // Force ssl url 
  10. $action_url = MS_Model_Pages::get_page_url( MS_Model_Pages::MS_PAGE_MEMBERSHIPS, true ); 
  11. $action_url = apply_filters( 
  12. 'ms_gateway_authorize_view_button_form_action_url',  
  13. $action_url 
  14. ); 
  15.  
  16. $row_class = 'gateway_' . $gateway->id; 
  17. if ( ! $gateway->is_live_mode() ) { 
  18. $row_class .= ' sandbox-mode'; 
  19.  
  20. ob_start(); 
  21. ?> 
  22. <form action="<?php echo esc_url( $action_url ); ?>" method="post"> 
  23. <?php MS_Helper_Html::html_element( $fields['_wpnonce'] ); ?> 
  24. <?php MS_Helper_Html::html_element( $fields['gateway'] ); ?> 
  25. <?php MS_Helper_Html::html_element( $fields['ms_relationship_id'] ); ?> 
  26. <?php MS_Helper_Html::html_element( $fields['step'] ); ?> 
  27. <?php MS_Helper_Html::html_element( $fields['submit'] ); ?> 
  28. </form> 
  29. <?php 
  30. $payment_form = apply_filters( 
  31. 'ms_gateway_form',  
  32. ob_get_clean(),  
  33. $gateway,  
  34. $invoice,  
  35. $this 
  36. ); 
  37.  
  38. ob_start(); 
  39. ?> 
  40. <tr class="<?php echo esc_attr( $row_class ); ?>"> 
  41. <td class="ms-buy-now-column" colspan="2"> 
  42. <?php echo $payment_form; ?> 
  43. </td> 
  44. </tr> 
  45. <?php 
  46. $html = ob_get_clean(); 
  47.  
  48. $html = apply_filters( 
  49. 'ms_gateway_button-' . $gateway->id,  
  50. $html,  
  51. $this 
  52. ); 
  53.  
  54. $html = apply_filters( 
  55. 'ms_gateway_button',  
  56. $html,  
  57. $gateway->id,  
  58. $this 
  59. ); 
  60.  
  61. return $html; 
  62.  
  63. private function prepare_fields() { 
  64. $gateway = $this->data['gateway']; 
  65. $subscription = $this->data['ms_relationship']; 
  66.  
  67. $fields = array( 
  68. '_wpnonce' => array( 
  69. 'id' => '_wpnonce',  
  70. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  71. 'value' => wp_create_nonce( 
  72. $this->data['gateway']->id . '_' . $subscription->id 
  73. ),  
  74. ),  
  75. 'gateway' => array( 
  76. 'id' => 'gateway',  
  77. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  78. 'value' => $gateway->id,  
  79. ),  
  80. 'ms_relationship_id' => array( 
  81. 'id' => 'ms_relationship_id',  
  82. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  83. 'value' => $subscription->id,  
  84. ),  
  85. 'step' => array( 
  86. 'id' => 'step',  
  87. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  88. 'value' => $this->data['step'],  
  89. ),  
  90. ); 
  91. if ( 0 === strpos( $gateway->pay_button_url, 'http' ) ) { 
  92. $fields['submit'] = array( 
  93. 'id' => 'submit',  
  94. 'type' => MS_Helper_Html::INPUT_TYPE_IMAGE,  
  95. 'value' => $gateway->pay_button_url,  
  96. ); 
  97. } else { 
  98. $fields['submit'] = array( 
  99. 'id' => 'submit',  
  100. 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT,  
  101. 'value' => $gateway->pay_button_url ? $gateway->pay_button_url : __( 'Signup', 'membership2' ),  
  102. ); 
  103.  
  104. return apply_filters( 
  105. 'ms_gateway_authorize_view_button_prepare_fields',  
  106. $fields 
  107. );