GFPaystationOptionsAdmin

The Gravity Forms Paystation (3 party hosted) GFPaystationOptionsAdmin class.

Defined (1)

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

/class.GFPaystationOptionsAdmin.php  
  1. class GFPaystationOptionsAdmin { 
  2.  
  3. private $plugin; // handle to the plugin object 
  4. private $menuPage; // slug for admin menu page 
  5. private $scriptURL = ''; 
  6. private $frm; // handle for the form validator 
  7.  
  8. // ==================================================================================================================================== 
  9. /** 
  10. * The controller. 
  11. * @param GFDpsPaystationPlugin $plugin handle to the plugin object 
  12. * @param string $menuPage URL slug for this admin menu page 
  13. */ 
  14. // ==================================================================================================================================== 
  15. public function __construct($plugin, $menuPage) { 
  16.  
  17. $this->plugin = $plugin; 
  18. $this->menuPage = $menuPage; 
  19. $this->scriptURL = parse_url($_SERVER['SCRIPT_NAME'], PHP_URL_PATH) . "?page={$menuPage}"; 
  20.  
  21. // ==================================================================================================================================== 
  22. /** 
  23. * Process the admin request 
  24. */ 
  25. // ==================================================================================================================================== 
  26. public function process() { 
  27.  
  28. echo "<div class='wrap'>\n"; 
  29. screen_icon(); 
  30. echo "<h2>Gravity Forms Paystation (3 party hosted) Settings</h2>\n"; 
  31.  
  32. $this->frm = new GFPaystationOptionsForm(); 
  33.  
  34. if ($this->frm->isFormPost()) { 
  35.  
  36. if (!wp_verify_nonce($_POST[$this->menuPage . '_wpnonce'], 'save')) 
  37. die('Security exception'); 
  38.  
  39. $errmsg = $this->frm->validate(); 
  40. if (empty($errmsg)) { 
  41. $this->plugin->options['paystationId'] = $this->frm->paystationId; 
  42. $this->plugin->options['gatewayId'] = $this->frm->gatewayId; 
  43. $this->plugin->options['securityHash'] = $this->frm->securityHash; 
  44. $this->plugin->options['testMode'] = $this->frm->testMode; 
  45.  
  46.  
  47. update_option(GFPAYSTATION_PLUGIN_OPTIONS, $this->plugin->options); 
  48. $this->plugin->showMessage(__('Options saved.')); 
  49. else { 
  50. $this->plugin->showError($errmsg); 
  51. else { 
  52. // Initialise form from stored options 
  53. $this->frm->paystationId = $this->plugin->options['paystationId']; 
  54. $this->frm->gatewayId = $this->plugin->options['gatewayId']; 
  55. $this->frm->testMode = $this->plugin->options['testMode'] == 'Y' ? 'Y' : 'N'; 
  56. $this->frm->securityHash = $this->plugin->options['securityHash']; 
  57.  
  58. $feedsURL = 'edit.php?post_type=' . GFPAYSTATION_TYPE_FEED; 
  59.  
  60. ?> 
  61. <form action="<?php echo $this->scriptURL; ?>" method="post"> 
  62. <table class="form-table"> 
  63. <tr> 
  64. <th>Paystation Id:</th> 
  65. <td valign='top'> 
  66. <input type='text' class="regular-text" name='paystationId' value="<?php echo htmlspecialchars($this->frm->paystationId); ?>" /> 
  67. </td> 
  68. <td> 
  69. Enter you Paystation account id here. If you don't have an account yet, please see <a href='http://www.paystation.co.nz/getting_started_overview' target='_blank'>the Overview page</a> on the Paystation website. 
  70. </td> 
  71. </tr> 
  72. <tr> 
  73. <th>Gateway Id:</th> 
  74. <td valign='top'> 
  75. <input type='text' class="regular-text" name='gatewayId' value="<?php echo htmlspecialchars($this->frm->gatewayId); ?>" /> 
  76. </td> 
  77. <td> 
  78. Here you need to enter the name of your payment gateway as detailed in the email we will have sent you after your Paystation account was created. 
  79. </td> 
  80. </tr> 
  81. <tr> 
  82. <th>Security Hash:</th> 
  83. <td valign='top'> 
  84. <input type='text' class="regular-text" name='securityHash' value="<?php echo htmlspecialchars($this->frm->securityHash); ?>" /> 
  85. </td> 
  86. <td> 
  87. Please enter a collection of letters and numbers here to use as a hash when dealing with responses from the Paystation system. 
  88. Suggested length is 8 to 20 characters. If you ever change this you will need to let us know otherwise this plugin will ignore responses from Paystation. 
  89. </td> 
  90. </tr> 
  91. <tr> 
  92. <th>Test Mode:</th> 
  93. <td valign='top'> 
  94. <input type="radio" name="testMode" value="Y" <?php checked($this->frm->testMode, 'Y'); ?> /> Yes    
  95. <input type="radio" name="testMode" value="N" <?php checked($this->frm->testMode, 'N'); ?> /> No 
  96. </td> 
  97. <td> 
  98. For information about how to use your account in test mode, including some test credit card numbers, please refer to the email you received with your  
  99. Paystation account information, or visit the <a href='http://paystation.co.nz/test-card-numbers' target='_blank'>Test Card Numbers</a> page. 
  100. </td> 
  101. </tr> 
  102. </table> 
  103. <p class="submit"> 
  104. <input type="submit" name="Submit" class="button-primary" value="Save Changes" /> 
  105. <input type="hidden" name="action" value="save" /> 
  106. <?php wp_nonce_field('save', $this->menuPage . '_wpnonce'); ?> 
  107. </p> 
  108. </form> 
  109. <p><a href="<?php echo $feedsURL; ?>">Edit feeds mapping form fields to Paystation (3 party hosted) API parameters</a></p> 
  110. </div> 
  111. <?php