public function generateFormData($amount, $currency, $itemName, $itemId, $recurringInterval = false, $recurringUnit = false, array $extraData = array()) { initPaymentwallConfigs($this->options->get('Paymentwall_appKey'), $this->options->get('Paymentwall_appSecret')); $itemParts = explode('|', $itemId, 4); $upgradeId = $itemParts[3]; $validationType = $itemParts[0]; $validation = XenForo_Visitor::getInstance()->get('csrf_token_page'); $this->_assertAmount($amount); $this->_assertCurrency($currency); $this->_assertItem($itemName, $itemId); $this->_assertRecurring($recurringInterval, $recurringUnit); $userid = XenForo_Visitor::getInstance()->get('user_id'); $custom = $userid . '|' . $upgradeId . '|' . $validationType . '|' . $validation; $widget = new Paymentwall_Widget($userid, $this->options->get('Paymentwall_widgetCode'), array(new Paymentwall_Product($itemId, $amount, $currency, $itemName)), array('email' => XenForo_Visitor::getInstance()->get('email'), 'integration_module' => 'xenforo', 'test_mode' => $this->options->get('Paymentwall_testMode'), 'success_url' => $this->_generateReturnUrl($extraData), 'custom' => $custom)); $callToAction = new XenForo_Phrase('Paymentwall_call_to_action'); $form = <<<EOF <form action="{$widget->getUrl()}" method="POST"> <input type="submit" value="{$callToAction}" class="button" /> </form> EOF; return $form; }
/** * Validates the callback request is valid. If failure happens, the response should * tell the processor to retry. * @return bool * */ public function validateRequest() { initPaymentwallConfigs($this->options->get('Paymentwall_appKey'), $this->options->get('Paymentwall_appSecret')); $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']); if ($pingback->validate()) { return true; } else { $this->logMessages[] = $pingback->getErrorSummary(); return false; } }