MS_Gateway_Paypalstandard_View_Settings

The Membership 2 MS Gateway Paypalstandard View Settings class.

Defined (1)

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

/app/gateway/paypalstandard/view/class-ms-gateway-paypalstandard-view-settings.php  
  1. class MS_Gateway_Paypalstandard_View_Settings extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $fields = $this->prepare_fields(); 
  5. $gateway = $this->data['model']; 
  6.  
  7. ob_start(); 
  8. // Render tabbed interface. 
  9. ?> 
  10. <form class="ms-gateway-settings-form ms-form"> 
  11. <?php 
  12. $description = sprintf( 
  13. '%s<br /> <br />%s<br /> <br />%s <strong>%s</strong><br /><a href="%s" target="_blank">%s</a>',  
  14. __( 'This advanced PayPal gateway will handle all payment types, including trial periods and recurring payments. However, it should not be used for permanent type meberships, as here it will display "pay again after 5 years" during checkout.', 'membership2' ),  
  15. __( 'In order for Membership 2 to function correctly you must setup an IPN listening URL with PayPal. Make sure to complete this step, otherwise we are not notified when a member cancels their subscription.', 'membership2' ),  
  16. __( 'Your IPN listening URL is:', 'membership2' ),  
  17. $this->data['model']->get_return_url(),  
  18. 'https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/',  
  19. __( 'Instructions »', 'membership2' ) 
  20. ); 
  21.  
  22. MS_Helper_Html::settings_box_header( '', $description ); 
  23. foreach ( $fields as $field ) { 
  24. MS_Helper_Html::html_element( $field ); 
  25. MS_Helper_Html::settings_box_footer(); 
  26. ?> 
  27. </form> 
  28. <?php 
  29. $html = ob_get_clean(); 
  30. return $html; 
  31.  
  32. protected function prepare_fields() { 
  33. $gateway = $this->data['model']; 
  34. $action = MS_Controller_Gateway::AJAX_ACTION_UPDATE_GATEWAY; 
  35. $nonce = wp_create_nonce( $action ); 
  36.  
  37. $fields = array( 
  38. 'merchant_id' => array( 
  39. 'id' => 'merchant_id',  
  40. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  41. 'title' => __( 'PayPal Merchant Account ID', 'membership2' ),  
  42. 'desc' => sprintf( 
  43. __( 'Note: This is <i>not the email address</i> but the merchant ID found in %syour PayPal profile%s. (in Sandbox mode use your Sandbox Email address)', 'membership2' ),  
  44. '<a href="https://www.paypal.com/webapps/customerprofile/summary.view" target="_blank">',  
  45. '</a>' 
  46. ),  
  47. 'value' => $gateway->merchant_id,  
  48. 'placeholder' => 'SGGGX43FAKKXN',  
  49. 'class' => 'ms-text-large',  
  50. 'ajax_data' => array( 1 ),  
  51. ),  
  52.  
  53. 'paypal_site' => array( 
  54. 'id' => 'paypal_site',  
  55. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  56. 'title' => __( 'PayPal Site', 'membership2' ),  
  57. 'field_options' => $gateway->get_paypal_sites(),  
  58. 'value' => $gateway->paypal_site,  
  59. 'class' => 'ms-text-large',  
  60. 'ajax_data' => array( 1 ),  
  61. ),  
  62.  
  63. 'mode' => array( 
  64. 'id' => 'mode',  
  65. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  66. 'title' => __( 'PayPal Mode', 'membership2' ),  
  67. 'value' => $gateway->mode,  
  68. 'field_options' => $gateway->get_mode_types(),  
  69. 'class' => 'ms-text-large',  
  70. 'ajax_data' => array( 1 ),  
  71. ),  
  72.  
  73. 'pay_button_url' => array( 
  74. 'id' => 'pay_button_url',  
  75. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  76. 'title' => apply_filters( 
  77. 'ms_translation_flag',  
  78. __( 'Payment button label or URL', 'membership2' ),  
  79. 'gateway-button' . $gateway->id 
  80. ),  
  81. 'value' => $gateway->pay_button_url,  
  82. 'class' => 'ms-text-large',  
  83. 'ajax_data' => array( 1 ),  
  84. ),  
  85. ); 
  86.  
  87. // Process the fields and add missing default attributes. 
  88. foreach ( $fields as $key => $field ) { 
  89. if ( ! empty( $field['ajax_data'] ) ) { 
  90. $fields[ $key ]['ajax_data']['field'] = $fields[ $key ]['id']; 
  91. $fields[ $key ]['ajax_data']['_wpnonce'] = $nonce; 
  92. $fields[ $key ]['ajax_data']['action'] = $action; 
  93. $fields[ $key ]['ajax_data']['gateway_id'] = $gateway->id; 
  94.  
  95. return $fields; 
  96.