コード例 #1
0
	/**
	* 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'));
		}
	}
コード例 #2
0
	/**
	* 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;
	}
コード例 #3
0
	/**
	* 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();
		}
	}
	/**
	* 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'));
	}