lastError = ''; $this->logIpn = TRUE; $this->ipnResponse = ''; $this->testMode = FALSE; } /** * Adds a key=>value pair to the fields array * * @param string key of field * @param string value of field * @return */ public function addField($field, $value) { $this->fields["$field"] = $value; } /** * Submit Payment Button * * Generates a form with hidden elements from the fields array * and displays the payment button that goes to the payment form. * * @param string value of button url * @param string type of gateway * @return void */ public function submitButton($button_url, $gateway) { $this->prepareSubmit(); global $gateway_name; echo '
  • '; foreach ($this->fields as $name => $value) { echo "\n"; } echo ''; echo '
  • '; } /** * Submit Payment Request (redirect) * * Generates a form with hidden elements from the fields array * and submits it to the payment gateway URL. The user is presented * a redirecting message along with a button to click. * * @param string value of buttn text * @return void */ public function submitPayment() { $this->prepareSubmit(); echo "\n"; echo "Processing Payment...\n"; echo "\n"; echo "

    Please wait, your order is being processed and you"; echo " will be redirected to the payment website.

    \n"; echo "
    gatewayUrl . "\">\n"; foreach ($this->fields as $name => $value) { echo "\n"; //echo 'Field name: ' . $name . ' Field value : ' . $value . '
    '; } echo "



    If you are not automatically redirected to "; echo "the payment website within 5 seconds...

    \n"; echo "

    \n"; echo "
    \n"; echo "\n"; } /** * Perform any pre-posting actions * * @param none * @return none */ protected function prepareSubmit() { // Fill if needed } /** * Enables the test mode * * @param none * @return none */ abstract protected function enableTestMode(); /** * Validate the IPN notification * * @param none * @return boolean */ abstract protected function validateIpn(); /** * Logs the IPN results * * @param boolean IPN result * @return void */ public function logResults($success) { if (!$this->logIpn) return; // Timestamp $text = '[' . date('m/d/Y g:i A') . '] - '; // Success or failure being logged? $text .= ( $success) ? "SUCCESS!\n" : 'FAIL: ' . $this->lastError . "\n"; // Log the POST variables $text .= "IPN POST Vars from gateway:\n"; foreach ($this->ipnData as $key => $value) { $text .= "$key=$value, "; } // Log the response from the paypal server $text .= "\nIPN Response from gateway Server:\n " . $this->ipnResponse; // Write to log if (is_writable($this->ipnLogFile)) { $fp = @fopen($this->ipnLogFile, 'a'); @fwrite($fp, $text . "\n\n"); @fclose($fp); } } public function dump_fields() { // Used for debugging, this function will output all the field/value pairs // that are currently defined in the instance of the class using the // add_field() function. global $gateway_name; // echo '

    PaymentGateway->dump_fields() Output:

    '; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; ksort($this->fields); foreach ($this->fields as $key => $value) { echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
    ' . $gateway_name . ' debug output
    ' . __('Field Name', 'event_espresso') . '' . __('Value', 'event_espresso') . '
    ' . $key . '' . htmlspecialchars($value) .' 
    '; } } }