MS_Gateway_Stripe_View_Settings

The Membership 2 MS Gateway Stripe View Settings class.

Defined (1)

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

/app/gateway/stripe/view/class-ms-gateway-stripe-view-settings.php  
  1. class MS_Gateway_Stripe_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. '%1$s<br />%2$s',  
  14. __( 'Best used for one-time payments.', 'membership2' ),  
  15. sprintf( 
  16. __( 'You can find your Stripe API Keys in your %sAccount Settings%s.', 'membership2' ),  
  17. '<a href="https://dashboard.stripe.com/account/apikeys" target="_blank">',  
  18. '</a>' 
  19. ); 
  20.  
  21. MS_Helper_Html::settings_box_header( '', $description ); 
  22. foreach ( $fields as $field ) { 
  23. MS_Helper_Html::html_element( $field ); 
  24. MS_Helper_Html::settings_box_footer(); 
  25. ?> 
  26. </form> 
  27. <?php 
  28. $html = ob_get_clean(); 
  29. return $html; 
  30.  
  31. protected function prepare_fields() { 
  32. $gateway = $this->data['model']; 
  33. $action = MS_Controller_Gateway::AJAX_ACTION_UPDATE_GATEWAY; 
  34. $nonce = wp_create_nonce( $action ); 
  35.  
  36. $fields = array( 
  37. 'mode' => array( 
  38. 'id' => 'mode',  
  39. 'title' => __( 'Mode', 'membership2' ),  
  40. 'type' => MS_Helper_Html::INPUT_TYPE_SELECT,  
  41. 'value' => $gateway->mode,  
  42. 'field_options' => $gateway->get_mode_types(),  
  43. 'class' => 'ms-text-large',  
  44. 'ajax_data' => array( 1 ),  
  45. ),  
  46.  
  47. 'test_secret_key' => array( 
  48. 'id' => 'test_secret_key',  
  49. 'title' => __( 'API Test Secret Key', 'membership2' ),  
  50. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  51. 'value' => $gateway->test_secret_key,  
  52. 'class' => 'ms-text-large',  
  53. 'ajax_data' => array( 1 ),  
  54. ),  
  55.  
  56. 'test_publishable_key' => array( 
  57. 'id' => 'test_publishable_key',  
  58. 'title' => __( 'API Test Publishable Key', 'membership2' ),  
  59. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  60. 'value' => $gateway->test_publishable_key,  
  61. 'class' => 'ms-text-large',  
  62. 'ajax_data' => array( 1 ),  
  63. ),  
  64.  
  65. 'secret_key' => array( 
  66. 'id' => 'secret_key',  
  67. 'title' => __( 'API Live Secret Key', 'membership2' ),  
  68. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  69. 'value' => $gateway->secret_key,  
  70. 'class' => 'ms-text-large',  
  71. 'ajax_data' => array( 1 ),  
  72. ),  
  73.  
  74. 'publishable_key' => array( 
  75. 'id' => 'publishable_key',  
  76. 'title' => __( 'API Live Publishable Key', 'membership2' ),  
  77. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  78. 'value' => $gateway->publishable_key,  
  79. 'class' => 'ms-text-large',  
  80. 'ajax_data' => array( 1 ),  
  81. ),  
  82.  
  83. 'pay_button_url' => array( 
  84. 'id' => 'pay_button_url',  
  85. 'title' => apply_filters( 
  86. 'ms_translation_flag',  
  87. __( 'Payment button label', 'membership2' ),  
  88. 'gateway-button' . $gateway->id 
  89. ),  
  90. 'type' => MS_Helper_Html::INPUT_TYPE_TEXT,  
  91. 'value' => $gateway->pay_button_url,  
  92. 'class' => 'ms-text-large',  
  93. 'ajax_data' => array( 1 ),  
  94. ),  
  95. ); 
  96.  
  97. // Process the fields and add missing default attributes. 
  98. foreach ( $fields as $key => $field ) { 
  99. if ( ! empty( $field['ajax_data'] ) ) { 
  100. $fields[ $key ]['ajax_data']['field'] = $fields[ $key ]['id']; 
  101. $fields[ $key ]['ajax_data']['_wpnonce'] = $nonce; 
  102. $fields[ $key ]['ajax_data']['action'] = $action; 
  103. $fields[ $key ]['ajax_data']['gateway_id'] = $gateway->id; 
  104.  
  105. return $fields; 
  106.