/** * send the eWAY payment request and retrieve and parse the response * @return EwayPaymentsStoredResponse * @param string $xml eWAY payment request as an XML document, per eWAY specifications */ private function sendPayment($xml) { // use sandbox if not from live website $url = $this->isLiveSite ? self::REALTIME_API_LIVE : self::REALTIME_API_SANDBOX; // execute the cURL request, and retrieve the response try { $responseXML = EwayPaymentsPlugin::curlSendRequest($url, $xml, $this->sslVerifyPeer); } catch (EwayPaymentsException $e) { throw new EwayPaymentsException("Error posting eWAY payment to $url: " . $e->getMessage()); } $response = new EwayPaymentsStoredResponse(); $response->loadResponseXML($responseXML); return $response; }
/** * display payment form on checkout page */ public function payment_fields() { if ($this->eway_card_form == 'yes') { // use standard WooCommerce credit card form $this->credit_card_form(); } else { // build drop-down items for months $optMonths = ''; foreach (array('01','02','03','04','05','06','07','08','09','10','11','12') as $option) { $optMonths .= "<option value='$option'>$option</option>\n"; } // build drop-down items for years $thisYear = (int) date('Y'); $optYears = ''; foreach (range($thisYear, $thisYear + 15) as $year) { $optYears .= "<option value='$year'>$year</option>\n"; } // load payment fields template with passed values $settings = $this->settings; EwayPaymentsPlugin::loadTemplate('woocommerce-eway-fields.php', compact('optMonths', 'optYears', 'settings')); } }
/** * send the eWAY payment request and retrieve and parse the response * * @return EwayPaymentsResponse * @param string $xml eWAY payment request as an XML document, per eWAY specifications */ private function sendPayment($xml) { // select endpoint URL, use sandbox if not from live website if (!empty($this->customerCountryCode)) { // use Beagle anti-fraud endpoints $url = $this->isLiveSite ? self::REALTIME_BEAGLE_API_LIVE : self::REALTIME_BEAGLE_API_SANDBOX; } else if (empty($this->cardVerificationNumber)) { // no CVN -- do these endpoints still work? $url = $this->isLiveSite ? self::REALTIME_API_LIVE : self::REALTIME_API_SANDBOX; } else { // normal Direct Payments endpoints with CVN verification $url = $this->isLiveSite ? self::REALTIME_CVN_API_LIVE : self::REALTIME_CVN_API_SANDBOX; } // execute the cURL request, and retrieve the response try { $responseXML = EwayPaymentsPlugin::curlSendRequest($url, $xml, $this->sslVerifyPeer); } catch (EwayPaymentsException $e) { throw new EwayPaymentsException("Error posting eWAY payment to $url: " . $e->getMessage()); } $response = new EwayPaymentsResponse(); $response->loadResponseXML($responseXML); return $response; }
/** * tell wp-e-commerce about fields we require on the checkout form */ protected static function setCheckoutFields() { global $gateway_checkout_form_fields; // check if this gateway is selected for checkout payments if (in_array(self::WPSC_GATEWAY_NAME, (array) get_option('custom_gateway_options'))) { // build drop-down items for months $optMonths = ''; foreach (array('01','02','03','04','05','06','07','08','09','10','11','12') as $option) { $optMonths .= "<option value='$option'>$option</option>\n"; } // build drop-down items for years $thisYear = (int) date('Y'); $optYears = ''; foreach (range($thisYear, $thisYear + 15) as $year) { $optYears .= "<option value='$year'>$year</option>\n"; } // use TH for field label cells if selected, otherwise use TD (default wp-e-commerce behaviour) $th = get_option('wpsc_merchant_eway_th') ? 'th' : 'td'; // optional message to show above credit card fields $card_msg = esc_html(get_option('wpsc_merchant_eway_card_msg')); // load template with passed values, capture output and register ob_start(); EwayPaymentsPlugin::loadTemplate('wpsc-eway-fields.php', compact('th', 'card_msg', 'optMonths', 'optYears')); $gateway_checkout_form_fields[self::WPSC_GATEWAY_NAME] = ob_get_clean(); } }
/** * get HTML for checkout form * @param string $form * @param AWPCP_Payment_Transaction $transaction * @return string */ public function awpcpCheckoutForm($form, $transaction) { if ($transaction->get('payment-method') == self::PAYMENT_METHOD) { $item = $transaction->get_item(0); // no support for multiple items if (is_null($item)) { return __('There was an error processing your payment.', 'AWPCP'); } // get URL for where to post the checkout form data if ($this->paymentsAPI) { $checkoutURL = $this->paymentsAPI->get_return_url($transaction); } else { list($checkoutURL) = awpcp_payment_urls($transaction); } $card_msg = esc_html(get_awpcp_option('eway_card_message')); // build drop-down items for months $optMonths = ''; foreach (array('01','02','03','04','05','06','07','08','09','10','11','12') as $option) { $optMonths .= "<option value='$option'>$option</option>\n"; } // build drop-down items for years $thisYear = (int) date('Y'); $optYears = ''; foreach (range($thisYear, $thisYear + 15) as $year) { $optYears .= "<option value='$year'>$year</option>\n"; } // load template with passed values ob_start(); EwayPaymentsPlugin::loadTemplate('awcp-eway-fields.php', compact('checkoutURL', 'card_msg', 'optMonths', 'optYears')); $form = ob_get_clean(); } return $form; }
<?php // WooCommerce admin settings page ?> <img style="float:right" src="<?php echo esc_url(EwayPaymentsPlugin::getUrlPath()); ?>images/eway-siteseal.png" /> <h3><?php echo esc_html($this->admin_page_heading); ?></h3> <p><?php echo esc_html($this->admin_page_description); ?></p> <table class="form-table"> <?php $this->generate_settings_html(); ?> </table> <script> (function($) { /** * check whether both the sandbox (test) mode and Stored Payments are selected, * show warning message if they are */ function setVisibility() { var useTest = ($("#woocommerce_eway_payments_eway_sandbox").filter(":checked").val() === "1"), useBeagle = ($("#woocommerce_eway_payments_eway_beagle").filter(":checked").val() === "1"), useStored = ($("#woocommerce_eway_payments_eway_stored").filter(":checked").val() === "1"); function display(element, visible) { if (visible) element.css({display: "none"}).show(750); else element.hide(); } display($("#woocommerce-eway-admin-stored-test"), (useTest && useStored));
/** * Outputs custom content and credit card information. */ public function booking_form(){ $card_msg = esc_html(get_option('em_' . EM_EWAY_GATEWAY . '_card_msg')); $card_num = esc_html(self::getPostValue('x_card_num')); $card_name = esc_html(self::getPostValue('x_card_name')); $card_code = esc_html(self::getPostValue('x_card_code')); // build drop-down items for months $optMonths = ''; $exp_date_month = self::getPostValue('x_exp_date_month'); foreach (array('01','02','03','04','05','06','07','08','09','10','11','12') as $option) { $selected = selected($option, $exp_date_month, false); $optMonths .= "<option $selected value='$option'>$option</option>\n"; } // build drop-down items for years $thisYear = (int) date('Y'); $optYears = ''; $exp_date_year = self::getPostValue('x_exp_date_year'); foreach (range($thisYear, $thisYear + 15) as $year) { $selected = selected($year, $exp_date_year, false); $optYears .= "<option $selected value='$year'>$year</option>\n"; } // load template with passed values, capture output and register EwayPaymentsPlugin::loadTemplate('eventsmanager-eway-fields.php', compact('card_msg', 'card_num', 'card_name', 'card_code', 'optMonths', 'optYears')); }