/app/gateway/authorize/view/class-ms-gateway-authorize-view-button.php

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