/** * Purchase button * * @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/includes/payment.form.php#L78 * * @param M_Subscription $subscription * @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.subscription.php * * @param array $pricing * @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.subscription.php#L110 * * array( * array( * 'period' => '1', * 'amount' => '50.00', * 'type' => 'indefinite', * 'unit' => 'm' * ) * ) * * @param int $user_id WordPress user/member ID */ public function purchase_button($subscription, $pricing, $user_id) { if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::is_pricing_free($pricing)) { // @todo what todo? return; } else { $membership = Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::get_membership($user_id); $config_id = get_option(Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::OPTION_CONFIG_ID); $data = new Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_PaymentData($subscription, $membership); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id); $gateway->set_payment_method($this->payment_method); if ($gateway) { // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/membershipadmin.php#K2908 if ('new' === strtolower(Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::get_option('formtype'))) { $action = add_query_arg(array('action' => 'buynow', 'subscription' => $data->get_subscription_id()), admin_url('admin-ajax.php')); } else { $action = '#pronamic-pay-form'; } printf('<form id="pronamic-pay-form" method="post" action="%s">', $action); printf('<img src="%s" alt="%s" />', esc_attr(plugins_url('images/ideal-logo-pay-off-2-lines.png', Pronamic_WP_Pay_Plugin::$file)), esc_attr__('iDEAL - Online payment through your own bank', 'pronamic_ideal')); echo '<div style="margin-top: 1em;">'; echo $gateway->get_input_html(); // Data $fields = array('subscription_id' => $data->get_subscription_id(), 'user_id' => $user_id); // Coupon if (function_exists('membership_get_current_coupon')) { $coupon = membership_get_current_coupon(); if ($coupon) { $fields['coupon_code'] = $coupon->get_coupon_code(); } } echo Pronamic_IDeal_IDeal::htmlHiddenFields($fields); // Submit button printf('<input type="submit" name="pronamic_pay_membership_%s" value="%s" />', esc_attr($this->gateway), esc_attr__('Pay', 'pronamic_ideal')); echo '</div>'; if (isset($this->error) && is_wp_error($this->error)) { foreach ($this->error->get_error_messages() as $message) { echo $message, '<br />'; } } printf('</form>'); } } }
/** * Get the output HTML * * @return string */ public function get_output_html() { $fields = $this->get_output_fields(); return Pronamic_IDeal_IDeal::htmlHiddenFields($fields); }
/** * Handles the generation of the form from shortcode arguments. * * Expected shortcode example (made by generator) * * [pronamic_ideal_s2member cost="10" period="1 Y" level="1" description="asdfasdfasdfas asdf asdf asdfa" ] * * period represents one of the predetermined durations they can * selected from the dropdown. * * cost is set by the shortcode generator. Must be ISO standard format ( . as decimal seperator ) * * level is the level access upon payment will be granted. * * description is text shown at payment. * * @param array $atts All arguments inside the shortcode */ public function shortcode_pay($atts) { $this->index++; $defaults = array('period' => null, 'cost' => null, 'level' => null, 'description' => __('iDEAL s2Member Payment || {{order_id}}', 'pronamic_ideal'), 'button_text' => __('Pay', 'pronamic_ideal'), 'ccaps' => null); // Combine the passed options $atts = shortcode_atts($defaults, $atts); $atts['order_id'] = uniqid(); // Output $output = ''; // Get the config ID $config_id = get_option('pronamic_pay_s2member_config_id'); // Get the gateway from the configuration $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id); if ($gateway) { // Data $data = new Pronamic_WP_Pay_Extensions_S2Member_PaymentData($atts); // Hash $hash_data = array('order_id' => $atts['order_id'], 'period' => $atts['period'], 'cost' => $atts['cost'], 'level' => $atts['level'], 'description' => $atts['description'], 'ccaps' => $atts['ccaps']); // Output $output .= $this->payment_error(); $output .= '<form method="post" action="">'; if (!is_user_logged_in()) { $output .= sprintf('<label for="%s">%s</label>', esc_attr('pronamic_pay_s2member_email'), esc_html__('Email', 'pronamic_ideal')); $output .= ' '; $output .= sprintf('<input id="%s" name="%s" value="%s" type="text" />', esc_attr('pronamic_pay_s2member_email'), esc_attr('pronamic_pay_s2member_email'), $data->get_email()); $output .= ' '; } $output .= $gateway->get_input_html(); $output .= ' '; $output .= Pronamic_IDeal_IDeal::htmlHiddenFields(array('pronamic_pay_s2member_index' => $this->index, 'pronamic_pay_s2member_hash' => $this->create_hash($hash_data), 'pronamic_pay_s2member_data[order_id]' => $atts['order_id'], 'pronamic_pay_s2member_data[period]' => $atts['period'], 'pronamic_pay_s2member_data[cost]' => $atts['cost'], 'pronamic_pay_s2member_data[level]' => $atts['level'], 'pronamic_pay_s2member_data[description]' => $atts['description'], 'pronamic_pay_s2member_data[ccaps]' => $atts['ccaps'])); $output .= sprintf('<input name="%s" value="%s" type="submit" />', esc_attr('pronamic_pay_s2member'), esc_attr($atts['button_text'])); $output .= '</form>'; } return $output; }
/** * Get HTML fields * * @return string */ public function get_html_fields() { return Pronamic_IDeal_IDeal::htmlHiddenFields(array(Pronamic_Gateways_Adyen_Parameters::MERCHANT_REFERENCE => $this->get_merchant_reference(), Pronamic_Gateways_Adyen_Parameters::PAYMENT_AMOUNT => Pronamic_WP_Util::amount_to_cents($this->get_payment_amount()), Pronamic_Gateways_Adyen_Parameters::CURRENCY_CODE => $this->get_currency_code(), Pronamic_Gateways_Adyen_Parameters::SHIP_BEFORE_DATE => Pronamic_WP_Util::format_date('Y-m-d', $this->get_ship_before_date()), Pronamic_Gateways_Adyen_Parameters::SKIN_CODE => $this->get_skin_code(), Pronamic_Gateways_Adyen_Parameters::MERCHANT_ACCOUNT => $this->get_merchant_account(), Pronamic_Gateways_Adyen_Parameters::SHOPPER_LOCALE => $this->get_shopper_locale(), Pronamic_Gateways_Adyen_Parameters::ORDER_DATA => base64_encode(gzencode($this->get_order_data())), Pronamic_Gateways_Adyen_Parameters::SESSION_VALIDITY => Pronamic_WP_Util::format_date(DATE_ATOM, $this->get_session_validity()), Pronamic_Gateways_Adyen_Parameters::MERCHANT_SIGNATURE => $this->get_signature(), Pronamic_Gateways_Adyen_Parameters::SHOPPER_EMAIL => $this->get_shopper_email(), Pronamic_Gateways_Adyen_Parameters::SHOPPER_REFERENCE => $this->get_shopper_reference())); }
public function to_html() { global $current_user; $subscription = $this->data['ms_relationship']; $membership = $subscription->get_membership(); $invoice = $subscription->get_current_invoice(); $ms_gateway = $this->data['gateway']; $gateway = Pronamic_WP_Pay_Plugin::get_gateway($ms_gateway->config_id); // Don't set payment method here as the issuer id is unknown when Pronamic_WP_Pay_Plugin::start() creates // the payment. Therefore, any chosen banks won't get used for the payment. $data = new Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_PaymentData($subscription, $membership); $html = ''; if ($gateway) { ob_start(); $gateway->set_payment_method($this->payment_method); echo '<form id="pronamic-pay-form" method="post">'; // Button image URL $button_image_url = plugins_url('images/ideal-logo-pay-off-2-lines.png', Pronamic_WP_Pay_Plugin::$file); if (isset($ms_gateway->button_image_url) && '' !== $ms_gateway->button_image_url) { $button_image_url = $ms_gateway->button_image_url; } // Button description $button_description = __('iDEAL - Online payment through your own bank', 'pronamic_ideal'); if (isset($ms_gateway->button_description) && '' !== $ms_gateway->button_description) { $button_description = $ms_gateway->button_description; } printf('<img src="%s" alt="%s" />', esc_attr($button_image_url), esc_attr($button_description)); echo '<div style="margin-top: 1em;">'; echo $gateway->get_input_html(); // Data $fields = array('subscription_id' => $data->get_subscription_id(), 'user_id' => $current_user->ID, 'invoice_id' => $invoice->id); echo Pronamic_IDeal_IDeal::htmlHiddenFields($fields); // Submit button printf(' <input type="submit" name="pronamic_pay_membership_%s" value="%s" />', esc_attr($ms_gateway->gateway), esc_attr__('Pay', 'pronamic_ideal')); echo '</div>'; $error = $gateway->get_error(); if (is_wp_error($error)) { foreach ($error->get_error_messages() as $message) { echo $message, '<br />'; } } ?> </form> <?php $payment_form = apply_filters('ms_gateway_form', ob_get_clean(), $ms_gateway, $invoice, $this); $row_class = 'gateway_' . $ms_gateway->id; if (!$ms_gateway->is_live_mode()) { $row_class .= ' sandbox-mode'; } ob_start(); ?> <tr class="<?php echo esc_attr($row_class); ?> "> <td class="ms-buy-now-column" colspan="2"> <?php echo $payment_form; ?> </td> </tr> <?php $html = ob_get_clean(); $html = apply_filters('ms_gateway_button', $html, $ms_gateway->id, $this); } return $html; }
/** * Process gateway */ public static function gateway_process($order_values) { // If gateway wasn't selected then immediately return if ('pronamic_ideal' !== $order_values['cp_payment_method']) { return; } // Add transaction entry $transaction_id = Pronamic_WP_Pay_Extensions_ClassiPress_ClassiPress::add_transaction_entry($order_values); // Handle gateway global $app_abbr; $config_id = get_option($app_abbr . '_pronamic_ideal_config_id'); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id); if ($gateway) { $data = new Pronamic_WP_Pay_Extensions_ClassiPress_PaymentData($order_values); if ($gateway->is_html_form()) { $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data); echo $gateway->get_form_html($payment, $auto_submit = true); } if ($gateway->is_http_redirect()) { // Hide the checkout page container HTML element echo '<style type="text/css">.thankyou center { display: none; }</style>'; ?> <form class="form_step" method="post" action=""> <?php echo Pronamic_IDeal_IDeal::htmlHiddenFields(array('cp_payment_method' => 'pronamic_ideal', 'oid' => $data->get_order_id())); echo $gateway->get_input_html(); ?> <p class="btn1"> <?php printf('<input class="ideal-button" type="submit" name="classipress_pronamic_ideal" value="%s" />', __('Pay with iDEAL', 'pronamic_ideal')); ?> </p> </form> <?php } } }