Пример #1
0
    /**
     * Processes a payment using this Gateway
     */
    public function process($order, $options)
    {
        if (isset($options['config_id'])) {
            $config_id = $options['config_id'];
            $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
            if ($gateway) {
                $data = new Pronamic_WP_Pay_Extensions_AppThemes_PaymentData($order);
                if (filter_has_var(INPUT_POST, 'appthemes_pronamic_ideal')) {
                    $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data);
                    $error = $gateway->get_error();
                    if (is_wp_error($error)) {
                        foreach ($error->get_error_messages() as $message) {
                            echo $message;
                        }
                    } else {
                        $gateway->redirect($payment);
                    }
                } else {
                    ?>
					<form method="post" action="">
						<?php 
                    echo $gateway->get_input_html();
                    ?>

						<p>
							<?php 
                    printf('<input class="ideal-button" type="submit" name="appthemes_pronamic_ideal" value="%s" />', __('Pay with iDEAL', 'pronamic_ideal'));
                    ?>
						</p>
					</form>
					<?php 
                }
            }
        }
    }
Пример #2
0
 /**
  * Acquirrer field input
  *
  * @param string $field_content
  * @param string $field
  * @param string $value
  * @param string $lead_id
  * @param string $form_id
  */
 public static function acquirer_field_input($field_content, $field, $value, $lead_id, $form_id)
 {
     $type = RGFormsModel::get_input_type($field);
     if (Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE === $type) {
         $id = $field['id'];
         $field_id = IS_ADMIN || 0 === $form_id ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $class_suffix = RG_CURRENT_VIEW === 'entry' ? '_admin' : '';
         $size = rgar($field, 'size');
         $class = $size . $class_suffix;
         $css_class = trim(esc_attr($class) . ' gfield_ideal_acquirer_select');
         $tab_index = GFCommon::get_tabindex();
         $disabled_text = IS_ADMIN && 'entry' !== RG_CURRENT_VIEW ? "disabled='disabled'" : '';
         $html = '';
         $feed = get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, true);
         /**
          * Developing warning:
          * Don't use single quotes in the HTML you output, it is buggy in combination with SACK
          */
         if (IS_ADMIN) {
             if (null === $feed) {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php')), __('Create iDEAL feed', 'pronamic_ideal'));
             } else {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", get_edit_post_link($feed->id), __('Edit iDEAL feed', 'pronamic_ideal'));
             }
         }
         $html_input = '';
         $html_error = '';
         if (null !== $feed) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
             if ($gateway) {
                 $issuer_field = $gateway->get_issuer_field();
                 $error = $gateway->get_error();
                 if (is_wp_error($error)) {
                     $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
                     $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
                 } elseif ($issuer_field) {
                     $choices = $issuer_field['choices'];
                     $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $value);
                     // Double quotes are not working, se we replace them with an single quote
                     $options = str_replace('"', '\'', $options);
                     $html_input = '';
                     $html_input .= sprintf("<select name='input_%d' id='%s' class='%s' %s %s>", $id, $field_id, $css_class, $tab_index, $disabled_text);
                     $html_input .= sprintf('%s', $options);
                     $html_input .= sprintf('</select>');
                 }
             }
         }
         if ($html_error) {
             $html .= sprintf("<div class='gfield_description validation_message'>");
             $html .= sprintf('%s', $html_error);
             $html .= sprintf('</div>');
         } else {
             $html .= sprintf("<div class='ginput_container ginput_ideal'>");
             $html .= sprintf('%s', $html_input);
             $html .= sprintf('</div>');
         }
         $field_content = $html;
     }
     return $field_content;
 }
Пример #3
0
 /**
  * Payment fields
  *
  * @see https://github.com/woothemes/woocommerce/blob/v1.6.6/templates/checkout/form-pay.php#L66
  */
 function payment_fields()
 {
     // @see https://github.com/woothemes/woocommerce/blob/v1.6.6/classes/gateways/class-wc-payment-gateway.php#L181
     parent::payment_fields();
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->config_id);
     if ($gateway) {
         echo $gateway->get_input_html();
     }
 }
Пример #4
0
 /**
  * Advanced inputs
  *
  * @return string
  */
 private static function advanced_inputs()
 {
     $output = '';
     $config_id = get_option(self::OPTION_CONFIG_ID);
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $output = $gateway->get_input_html();
     }
     return $output;
 }
Пример #5
0
 /**
  * Creates the billing form for this payment method type
  * @param \EE_Transaction $transaction
  * @return NULL
  */
 public function generate_new_billing_form(EE_Transaction $transaction = null)
 {
     $config_id = $this->_gateway->get_config_id();
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $form = new EE_Billing_Info_Form($this->_pm_instance, array('name' => 'Pronamic_WP_Pay_Billing_Form', 'subsections' => array('html' => new EE_Form_Section_HTML($gateway->get_input_html()))));
         return $form;
     }
     return null;
 }
Пример #6
0
 /**
  * Form gateway fields.
  *
  * @see https://github.com/Charitable/Charitable/blob/1.4.5/includes/donations/class-charitable-donation-form.php#L387
  * @since 1.0.2
  */
 public static function form_gateway_fields($fields, $gateway)
 {
     if (get_class() === get_class($gateway)) {
         $payment_method = $gateway->payment_method;
         $config_id = $gateway->get_value('config_id');
         $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
         if ($gateway) {
             $gateway->set_payment_method($payment_method);
             $fields['pronamic-pay-input-html'] = array('type' => '', 'gateway' => $gateway);
         }
     }
     return $fields;
 }
 /**
  * Get the gateway for this field.
  *
  * @return
  */
 private function get_gateway()
 {
     $gateway = null;
     if (isset($this->pronamicPayConfigId) && !empty($this->pronamicPayConfigId)) {
         $gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->pronamicPayConfigId);
     }
     if (!$gateway) {
         $feeds = get_pronamic_gf_pay_feeds_by_form_id($this->formId);
         foreach ($feeds as $feed) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
             if ($gateway && null !== $gateway->get_payment_method_field()) {
                 return $gateway;
             }
         }
     }
     return $gateway;
 }
Пример #8
0
 /**
  * Process donation.
  *
  * @since   1.0.0
  * @param   mixed                          $return
  * @param   int                            $donation_id
  * @param   Charitable_Donation_Processor  $processor
  * @param   string                         $gateway
  * @return mixed array or boolean
  */
 public static function pronamic_process_donation($return, $donation_id, $processor, $charitable_gateway)
 {
     $payment_method = $charitable_gateway->payment_method;
     $config_id = $charitable_gateway->get_value('config_id');
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if (!$gateway) {
         return false;
     }
     // Data
     $data = new Pronamic_WP_Pay_Extensions_Charitable_PaymentData($donation_id, $processor, $charitable_gateway);
     $gateway->set_payment_method($payment_method);
     $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data, $payment_method);
     $error = $gateway->get_error();
     if (is_wp_error($error)) {
         charitable_get_notices()->add_error($error->get_error_message());
         return false;
     }
     return array('redirect' => $payment->get_pay_redirect_url(), 'safe' => false);
 }
Пример #9
0
 /**
  * Set redirection info
  *
  * @see https://github.com/eventespresso/event-espresso-core/blob/4.6.17.p/core/libraries/payment_methods/EE_Offsite_Gateway.lib.php#L51-L59
  *
  * @param EEI_Payment $payment
  * @param type $billing_info
  * @param type $return_url
  * @param type $cancel_url
  */
 public function set_redirection_info($ee_payment, $billing_info = array(), $return_url = null, $notify_url = null, $cancel_url = null)
 {
     $pronamic_gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->_config_id);
     if ($pronamic_gateway) {
         $transaction = $ee_payment->transaction();
         $total_line_item = $transaction->total_line_item();
         $data = new Pronamic_WP_Pay_Extensions_EventEspresso_PaymentData($this, $total_line_item, $transaction);
         $pronamic_payment = Pronamic_WP_Pay_Plugin::start($this->_config_id, $pronamic_gateway, $data);
         $error = $pronamic_gateway->get_error();
         if (is_wp_error($error)) {
             // @see https://github.com/eventespresso/event-espresso-core/blob/4.6.18.p/caffeinated/payment_methods/Mijireh/EEG_Mijireh.gateway.php#L147
             $error_message = sprintf(__('Errors communicating with gateway: %s', 'pronamic_ideal'), implode(',', $error->get_error_messages()));
             EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
             throw new EE_Error($error_message);
         } else {
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_return', $return_url);
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_success', $return_url);
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_cancel', $cancel_url);
             update_post_meta($pronamic_payment->get_id(), '_pronamic_payment_url_error', $cancel_url);
             $redirect_url = $pronamic_payment->get_action_url();
             $redirect_args = $pronamic_gateway->get_output_fields();
             /*
              * Since Event Espresso uses an HTML form to redirect users to the payment gateway
              * we have to make sure an POST method is used when the redirect URL has query arguments.
              * Otheriwse the URL query arguments will be stripped by the users webbrowser.
              * Herefor we have to make sure the redirect arguments array is not empty.
              *
              * @see https://github.com/eventespresso/event-espresso-core/blob/4.6.18.p/core/db_classes/EE_Payment.class.php#L547
              * @see http://stackoverflow.com/q/1116019
              */
             if (false !== strpos($redirect_url, '?') && empty($redirect_args)) {
                 $redirect_args[] = '';
             }
             $ee_payment->set_redirect_url($redirect_url);
             $ee_payment->set_redirect_args($redirect_args);
         }
     } else {
         $error = Pronamic_WP_Pay_Plugin::get_default_error_message();
         // @see https://github.com/eventespresso/event-espresso-core/blob/4.6.18.p/caffeinated/payment_methods/Mijireh/EEG_Mijireh.gateway.php#L147
         throw new EE_Error($error);
     }
     return $ee_payment;
 }
Пример #10
0
 /**
  * Initialize
  */
 public function init()
 {
     global $pronamic_pay_errors;
     $pronamic_pay_errors = array();
     if (filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
         $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
         if (wp_verify_nonce($nonce, 'pronamic_pay')) {
             $id = filter_input(INPUT_POST, 'pronamic_pay_form_id', FILTER_VALIDATE_INT);
             $config_id = get_post_meta($id, '_pronamic_payment_form_config_id', true);
             $valid = $this->validate();
             if ($valid) {
                 $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
                 if ($gateway) {
                     $data = new Pronamic_WP_Pay_PaymentFormData();
                     $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data);
                     $error = $gateway->get_error();
                     if (is_wp_error($error)) {
                         Pronamic_WP_Pay_Plugin::render_errors($error);
                     } else {
                         // @see https://github.com/WordImpress/Give/blob/1.1/includes/payments/functions.php#L172-L178
                         // @see https://github.com/woothemes/woocommerce/blob/2.4.3/includes/wc-user-functions.php#L36-L118
                         $first_name = filter_input(INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING);
                         $last_name = filter_input(INPUT_POST, 'pronamic_pay_last_name', FILTER_SANITIZE_STRING);
                         $email = filter_input(INPUT_POST, 'pronamic_pay_email', FILTER_VALIDATE_EMAIL);
                         $user = get_user_by('email', $email);
                         if (!$user) {
                             // Make a random string for password
                             $password = wp_generate_password(10);
                             // Make a user with the username as the email
                             $user_id = wp_insert_user(array('user_login' => $email, 'user_pass' => $password, 'user_email' => $email, 'role' => 'payer', 'first_name' => $first_name, 'last_name' => $last_name));
                             // User
                             $user = new WP_User($user_id);
                         }
                         wp_update_post(array('ID' => $payment->post->ID, 'post_author' => $user->ID));
                         $gateway->redirect($payment);
                     }
                     exit;
                 }
             }
         }
     }
 }
Пример #11
0
 /**
  * Submit to gateway
  */
 public function submit()
 {
     $config_id = get_option(Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::OPTION_CONFIG_ID);
     // Set process to 'order_received' (2)
     // @see http://plugins.trac.wordpress.org/browser/wp-e-commerce/tags/3.8.7.6.2/wpsc-includes/merchant.class.php#L301
     // @see http://plugins.trac.wordpress.org/browser/wp-e-commerce/tags/3.8.7.6.2/wpsc-core/wpsc-functions.php#L115
     $this->set_purchase_processed_by_purchid(Pronamic_WP_Pay_Extensions_WPeCommerce_WPeCommerce::PURCHASE_STATUS_ORDER_RECEIVED);
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $data = new Pronamic_WP_Pay_Extensions_WPeCommerce_PaymentData($this);
         $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data);
         update_post_meta($payment->get_id(), '_pronamic_payment_wpsc_purchase_id', $data->get_purchase_id());
         update_post_meta($payment->get_id(), '_pronamic_payment_wpsc_session_id', $data->get_session_id());
         $error = $gateway->get_error();
         if (is_wp_error($error)) {
             // @todo what todo?
         } else {
             $gateway->redirect($payment);
         }
     }
 }
 /**
  * Process donation.
  *
  * @param   int                            $donation_id
  * @param   Charitable_Donation_Processor  $processor
  * @param   string                         $gateway
  * @since   1.0.0
  */
 public static function process_donation($donation_id, $processor, $gateway = null)
 {
     if (null === $gateway) {
         $gateway = new self();
     } else {
         $gateway = new $gateway();
     }
     $payment_method = $gateway->payment_method;
     $config_id = $gateway->get_value('config_id');
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         // Data
         $data = new Pronamic_WP_Pay_Extensions_Charitable_PaymentData($donation_id, $processor);
         $gateway->set_payment_method($payment_method);
         $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data, $payment_method);
         $error = $gateway->get_error();
         if (!is_wp_error($error)) {
             // Redirect
             $gateway->redirect($payment);
         }
     }
 }
Пример #13
0
function get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, $with_ideal_issuers = false)
{
    $feeds = get_pronamic_gf_pay_feeds_by_form_id($form_id);
    if (!empty($feeds)) {
        $form = RGFormsModel::get_form_meta($form_id);
        if ($with_ideal_issuers) {
            foreach ($feeds as $feed) {
                $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
                if ($gateway && null !== $gateway->get_issuers()) {
                    return $feed;
                }
            }
        } else {
            foreach ($feeds as $feed) {
                if (Pronamic_WP_Pay_Extensions_GravityForms_Util::is_condition_true($form, $feed)) {
                    return $feed;
                }
            }
        }
    }
    return null;
}
Пример #14
0
 /**
  * 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>');
         }
     }
 }
Пример #15
0
 public static function update_payment($payment = null, $can_redirect = true)
 {
     if ($payment) {
         $gateway = Pronamic_WP_Pay_Plugin::get_gateway($payment->config_id);
         if ($gateway) {
             $old_status = strtolower($payment->status);
             if (strlen($old_status) <= 0) {
                 $old_status = 'unknown';
             }
             $gateway->update_status($payment);
             $new_status = strtolower($payment->status);
             pronamic_wp_pay_update_payment($payment);
             if (defined('DOING_CRON') && (empty($payment->status) || $payment->status === Pronamic_WP_Pay_Gateways_IDealAdvancedV3_Status::OPEN)) {
                 $can_redirect = false;
             }
             do_action("pronamic_payment_status_update_{$payment->source}_{$old_status}_to_{$new_status}", $payment, $can_redirect);
             do_action("pronamic_payment_status_update_{$payment->source}", $payment, $can_redirect);
             do_action('pronamic_payment_status_update', $payment, $can_redirect);
             if ($can_redirect) {
                 $url = home_url('/');
                 $page_id = null;
                 switch ($payment->status) {
                     case Pronamic_WP_Pay_Statuses::CANCELLED:
                         $page_id = pronamic_pay_get_page_id('cancel');
                         break;
                     case Pronamic_WP_Pay_Statuses::EXPIRED:
                         $page_id = pronamic_pay_get_page_id('expired');
                         break;
                     case Pronamic_WP_Pay_Statuses::FAILURE:
                         $page_id = pronamic_pay_get_page_id('error');
                         break;
                     case Pronamic_WP_Pay_Statuses::OPEN:
                         $page_id = pronamic_pay_get_page_id('unknown');
                         break;
                     case Pronamic_WP_Pay_Statuses::SUCCESS:
                         $page_id = pronamic_pay_get_page_id('completed');
                         break;
                     default:
                         $page_id = pronamic_pay_get_page_id('unknown');
                         break;
                 }
                 if (!empty($page_id)) {
                     $page_url = get_permalink($page_id);
                     if (false !== $page_url) {
                         $url = $page_url;
                     }
                 }
                 wp_redirect($url);
                 exit;
             }
         }
     }
 }
 /**
  * Advanced inputs
  *
  * @return string
  */
 public static function advanced_inputs()
 {
     $output = '';
     $config_id = get_option(Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::OPTION_IDEAL_CONFIG_ID);
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $gateway->set_payment_method(Pronamic_WP_Pay_PaymentMethods::IDEAL);
         $output = $gateway->get_input_html();
     }
     return $output;
 }
    /**
     * Display gateway
     */
    public static function display_gateway($payment_data)
    {
        $config_id = get_option(self::OPTION_CONFIG_ID);
        $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
        if ($gateway) {
            $data = new Pronamic_WP_Pay_Extensions_EventEspressoLegacy_PaymentData($payment_data);
            ?>
			<div id="pronamic-payment-option-dv" class="payment-option-dv">
				<a id="pronamic-payment-option-lnk" class="pronamic-option-lnk display-the-hidden" rel="pronamic-payment-option-form" style="cursor:pointer;">
					<?php 
            printf('<img alt="%s" src="%s" />', esc_attr__('Pay with iDEAL', 'pronamic_ideal'), esc_attr(plugins_url('images/ideal.nl/iDEAL-Payoff-2-klein.gif', Pronamic_WP_Pay_Plugin::$file)));
            ?>
				</a>

				<div id="pronamic-payment-option-form-dv" class="hide-if-js">
					<h3 class="payment_header">
						<?php 
            _e('iDEAL', 'pronamic_ideal');
            ?>
					</h3>

					<div class="event_espresso_form_wrapper">
						<form method="post" action="<?php 
            echo esc_attr($data->get_notify_url());
            ?>
">
							<?php 
            echo $gateway->get_input_html();
            ?>

							<p>
								<?php 
            printf('<input class="ideal-button allow-leave-page" type="submit" name="event_espresso_pronamic_ideal" value="%s" />', __('Pay with iDEAL', 'pronamic_ideal'));
            ?>
							</p>
						</form>
					</div>

					<p class="choose-diff-pay-option-pg">
						<a class="hide-the-displayed" rel="pronamic-payment-option-form" style="cursor:pointer;"><?php 
            _e('Choose a different payment option', 'pronamic_ideal');
            ?>
</a>
					</p>
				</div>
			</div>

			<?php 
        }
    }
Пример #18
0
    /**
     * Display payment form.
     *
     * @param float $amount
     * @param       $user
     * @param int   $product_id
     * @param int   $txn_id
     * @see https://gitlab.com/pronamic/memberpress/blob/1.2.4/app/lib/MeprBaseGateway.php#L230-233
     */
    public function display_payment_form($amount, $user, $product_id, $txn_id)
    {
        $product = new MeprProduct($product_id);
        $coupon = false;
        $txn = new MeprTransaction($txn_id);
        // Artifically set the price of the $prd in case a coupon was used
        if ($product->price !== $amount) {
            $coupon = true;
            $product->price = $amount;
        }
        $invoice = MeprTransactionsHelper::get_invoice($txn);
        echo $invoice;
        // WPCS: XSS ok.
        ?>
		<div class="mp_wrapper mp_payment_form_wrapper">
			<form action="" method="post" id="payment-form" class="mepr-form" novalidate>
				<input type="hidden" name="mepr_process_payment_form" value="Y" />
				<input type="hidden" name="mepr_transaction_id" value="<?php 
        echo esc_attr($txn_id);
        ?>
" />
				<input type="hidden" name="pronamic_pay_memberpress_pay" value="1" />

				<div class="mepr_spacer">&nbsp;</div>

				<?php 
        // Gateway
        $config_id = $this->settings->config_id;
        $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
        if ($gateway) {
            echo $gateway->get_input_html();
            // WPCS: XSS ok.
        }
        ?>

				<div class="mepr_spacer">&nbsp;</div>

				<input type="submit" class="mepr-submit" value="<?php 
        esc_attr_e('Pay', 'pronamic_ideal');
        ?>
" />
				<img src="<?php 
        echo esc_attr(admin_url('images/loading.gif'));
        ?>
" style="display: none;" class="mepr-loading-gif" />
				<?php 
        MeprView::render('/shared/has_errors', get_defined_vars());
        ?>

				<noscript><p class="mepr_nojs"><?php 
        esc_html_e('JavaScript is disabled in your browser. You will not be able to complete your purchase until you either enable JavaScript in your browser, or switch to a browser that supports it.', 'pronamic_ideal');
        ?>
</p></noscript>
			</form>
		</div>
		<?php 
    }
 /**
  * Process payment start
  *
  * @param EE_Line_Item $total_line_item
  * @param $transaction
  */
 public function process_payment_start(EE_Line_Item $total_line_item, $transaction = null)
 {
     if (!$transaction) {
         $transaction = $total_line_item->transaction();
     }
     $config_id = $this->_payment_settings['config_id'];
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $data = new Pronamic_WP_Pay_Extensions_EventEspresso_PaymentData($this, $total_line_item, $transaction);
         $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data);
         $error = $gateway->get_error();
         if (!is_wp_error($error)) {
             $offsite_form = $this->submitPayment();
             $offsite_form['form'] = $gateway->get_form_html($payment, true);
             $this->_EEM_Gateways->set_off_site_form($offsite_form);
             $this->redirect_after_reg_step_3();
         }
     }
 }
Пример #20
0
 /**
  * Payment method select options
  */
 public function get_payment_method_select_options()
 {
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->config_id);
     if ($gateway) {
         $payment_method_field = $gateway->get_payment_method_field();
         if ($payment_method_field) {
             return $payment_method_field['choices'][0]['options'];
         }
     }
     return array('' => _x('All', 'Payment method field', 'pronamic_ideal'));
 }
<?php

global $pronamic_ideal_errors;
$gateway = Pronamic_WP_Pay_Plugin::get_gateway(get_the_ID());
if ($gateway) {
    wp_nonce_field('test_pay_gateway', 'pronamic_pay_test_nonce');
    echo $gateway->get_input_html();
    //xss ok
    if ($gateway->has_error()) {
        $pronamic_ideal_errors[] = $gateway->get_error();
    }
    include Pronamic_WP_Pay_Plugin::$dirname . '/views/errors.php';
    ?>

	<p>
		<label for="test_amount">&euro;</label>
		<input name="test_amount" id="test_amount" value="" class="small-text" type="text" />

		<?php 
    submit_button(__('Test', 'pronamic_ideal'), 'secondary', 'test_pay_gateway', false);
    ?>
	</p>

	<?php 
    $is_ideal = false;
    $is_ideal |= $gateway instanceof Pronamic_WP_Pay_Gateways_IDealBasic_Gateway;
    $is_ideal |= $gateway instanceof Pronamic_WP_Pay_Gateways_IDealAdvanced_Gateway;
    $is_ideal |= $gateway instanceof Pronamic_WP_Pay_Gateways_IDealAdvancedV3_Gateway;
    if ($is_ideal) {
        include Pronamic_WP_Pay_Plugin::$dirname . '/views/ideal-test-cases.php';
    }
Пример #22
0
 /**
  * Process the payment and return the result
  */
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     // Mark as on-hold (we're awaiting the payment)
     $order->update_status('pending', __('Pending iDEAL payment.', 'pronamic_ideal'));
     // Do specifiek iDEAL variant processing
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->config_id);
     if ($gateway) {
         if ($gateway->is_http_redirect()) {
             $return = $this->process_gateway_http_redirect($order, $gateway);
         }
         if ($gateway->is_html_form()) {
             $return = $this->process_gateway_html_form($order);
         }
         if (!$gateway->has_feedback()) {
         }
     }
     return $return;
 }
 /**
  * The $purchase_data array consists of the following data:
  *
  * $purchase_data = array(
  *   'downloads'    => array of download IDs,
  *   'tax'          => taxed amount on shopping cart
  *   'subtotal'     => total price before tax
  *   'price'        => total price of cart contents after taxes,
  *   'purchase_key' => Random key
  *   'user_email'   => $user_email,
  *   'date'         => date( 'Y-m-d H:i:s' ),
  *   'user_id'      => $user_id,
  *   'post_data'    => $_POST,
  *   'user_info'    => array of user's information and used discount code
  *   'cart_details' => array of cart details,
  * );
  */
 public function process_purchase($purchase_data)
 {
     $config_id = edd_get_option($this->id . '_config_id');
     // Collect payment data
     $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => $this->id, 'status' => 'pending');
     // Record the pending payment
     $payment_id = edd_insert_payment($payment_data);
     // Check payment
     if (!$payment_id) {
         // Log error
         edd_record_gateway_error(__('Payment Error', 'pronamic_ideal'), sprintf(__('Payment creation failed before sending buyer to the payment provider. Payment data: %s', 'pronamic_ideal'), json_encode($payment_data)), $payment_id);
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     } else {
         $data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($payment_id, $payment_data);
         $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
         if ($gateway) {
             // Start
             $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data, $this->payment_method);
             $error = $gateway->get_error();
             if (is_wp_error($error)) {
                 edd_record_gateway_error(__('Payment Error', 'pronamic_ideal'), sprintf(__('Payment creation failed before sending buyer to the payment provider. Payment data: %s', 'pronamic_ideal'), json_encode($payment_data)), $payment_id);
                 edd_set_error('pronamic_pay_error', Pronamic_WP_Pay_Plugin::get_default_error_message());
                 foreach ($error->get_error_messages() as $i => $message) {
                     edd_set_error('pronamic_pay_error_' . $i, $message);
                 }
                 edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
             } else {
                 // Transaction ID
                 // @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.3/includes/payments/functions.php#L1400-L1416
                 edd_set_payment_transaction_id($payment_id, $payment->get_transaction_id());
                 // Payment note
                 $payment_link = add_query_arg(array('post' => $payment->get_id(), 'action' => 'edit'), admin_url('post.php'));
                 $note = sprintf(__('Payment %s pending.', 'pronamic_ideal'), sprintf('<a href="%s">#%s</a>', $payment_link, $payment->get_id()));
                 edd_insert_payment_note($payment_id, $note);
                 $gateway->redirect($payment);
                 exit;
             }
         } else {
             edd_set_error('pronamic_pay_error', Pronamic_WP_Pay_Plugin::get_default_error_message());
             edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
         }
     }
 }
Пример #24
0
 /**
  * Entry post save
  *
  * @param array $lead
  * @param array $form
  */
 public function entry_post_save($lead, $form)
 {
     if ($this->is_processing($form)) {
         // Payment ID
         $payment_id = gform_get_meta($lead['id'], 'pronamic_payment_id');
         if (!empty($payment_id)) {
             return $lead;
         }
         // Gateway
         $this->gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->feed->config_id);
         if (!$this->gateway) {
             return $lead;
         }
         // New payment
         $data = new Pronamic_WP_Pay_Extensions_GravityForms_PaymentData($form, $lead, $this->feed);
         $payment_method = $data->get_payment_method();
         // Set payment method to iDEAL if issuer_id is set
         if (null === $data->get_payment_method() && null !== $data->get_issuer_id()) {
             $payment_method = Pronamic_WP_Pay_PaymentMethods::IDEAL;
         }
         $this->payment = Pronamic_WP_Pay_Plugin::start($this->feed->config_id, $this->gateway, $data, $payment_method);
         $this->error = $this->gateway->get_error();
         // Updating lead's payment_status to Processing
         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::PROCESSING;
         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_AMOUNT] = $this->payment->get_amount();
         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_DATE] = gmdate('y-m-d H:i:s');
         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::TRANSACTION_TYPE] = Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::TRANSACTION_TYPE_PAYMENT;
         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::TRANSACTION_ID] = $this->payment->get_transaction_id();
         // Update entry meta with payment ID
         gform_update_meta($lead['id'], 'pronamic_payment_id', $this->payment->get_id());
         // Update entry meta with feed ID
         gform_update_meta($lead['id'], 'ideal_feed_id', $this->feed->id);
         // Update entry meta with current payment gateway
         gform_update_meta($lead['id'], 'payment_gateway', 'pronamic_pay');
         // Update lead
         Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::update_entry($lead);
     }
     return $lead;
 }
 /**
  * Render field.
  *
  * @param array $field
  */
 private function render_field($field)
 {
     $config_id = get_option('pronamic_pay_config_id');
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         // Always use iDEAL payment method for issuer field
         $payment_method = $gateway->get_payment_method();
         $gateway->set_payment_method(Pronamic_WP_Pay_PaymentMethods::IDEAL);
         $issuer_field = $gateway->get_issuer_field();
         $error = $gateway->get_error();
         if (is_wp_error($error)) {
             $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
             $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
         } elseif ($issuer_field) {
             $choices = $issuer_field['choices'];
             $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices);
             printf('<select name="%s" id="%s">', esc_attr(sprintf('item_meta[%s]', $field['id'])), esc_attr(sprintf('field_%s', $field['field_key'])));
             echo $options;
             echo '</select>';
         }
         // Reset payment method to original value
         $gateway->set_payment_method($payment_method);
     }
 }
Пример #26
0
<?php

global $pronamic_pay_errors;
$config_id = get_post_meta($id, '_pronamic_payment_form_config_id', true);
$button_text = get_post_meta($id, '_pronamic_payment_form_button_text', true);
$button_text = empty($button_text) ? __('Pay Now', 'pronamic_ideal') : $button_text;
$amount_method = get_post_meta($id, '_pronamic_payment_form_amount_method', true);
$amount_choices = get_post_meta($id, '_pronamic_payment_form_amount_choices', true);
$methods_with_choices = array(Pronamic_WP_Pay_Admin_FormPostType::AMOUNT_METHOD_CHOICES_ONLY, Pronamic_WP_Pay_Admin_FormPostType::AMOUNT_METHOD_CHOICES_AND_INPUT);
$gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
if ($gateway) {
    ?>

	<div class="pronamic-pay-form-wrap">

		<?php 
    if (!is_singular('pronamic_pay_form')) {
        ?>

			<h2 class="pronamic-pay-form-title"><?php 
        echo esc_html(get_the_title($id));
        ?>
</h2>

		<?php 
    }
    ?>

		<form id="pronamic-pay-form-<?php 
    echo esc_attr($id);
    ?>
Пример #27
0
 /**
  * Check if an iDEAL payment needs to be processed.
  */
 public static function process_payment()
 {
     $do_process_payment = filter_input(INPUT_POST, 'pronamic_ideal_process_payment', FILTER_SANITIZE_STRING);
     if (strlen($do_process_payment) <= 0) {
         return;
     }
     // Prepare transaction data
     $unique_hash = it_exchange_create_unique_hash();
     $current_customer = it_exchange_get_current_customer();
     $transaction_object = it_exchange_generate_transaction_object();
     if (!$transaction_object instanceof stdClass) {
         return;
     }
     it_exchange_add_transient_transaction(self::$slug, $unique_hash, $current_customer->ID, $transaction_object);
     $configuration_id = self::get_gateway_configuration_id();
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($configuration_id);
     if ($gateway) {
         $data = new Pronamic_WP_Pay_Extensions_IThemesExchange_PaymentData($unique_hash, $transaction_object);
         $payment = Pronamic_WP_Pay_Plugin::start($configuration_id, $gateway, $data);
         $gateway->redirect($payment);
         exit;
     }
 }
 /**
  * Redirect for payment.
  *
  * @see https://github.com/wp-premium/formidable-paypal/blob/3.02/controllers/FrmPaymentsController.php#L274-L311
  */
 public function redirect_for_payment($entry_id, $form_id)
 {
     $config_id = get_option('pronamic_pay_config_id');
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $data = new Pronamic_WP_Pay_Extensions_FormidableForms_PaymentData($entry_id, $form_id, $this->action);
         $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data, Pronamic_WP_Pay_PaymentMethods::IDEAL);
         $error = $gateway->get_error();
         if (!is_wp_error($error)) {
             // Redirect
             $gateway->redirect($payment);
         }
     }
 }
Пример #29
0
 /**
  * Maybe test payment
  */
 public function maybe_test_payment()
 {
     if (filter_has_var(INPUT_POST, 'test_pay_gateway') && check_admin_referer('test_pay_gateway', 'pronamic_pay_test_nonce')) {
         $id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT);
         $gateway = Pronamic_WP_Pay_Plugin::get_gateway($id);
         if ($gateway) {
             $amount = filter_input(INPUT_POST, 'test_amount', FILTER_VALIDATE_FLOAT, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('decimal' => pronamic_pay_get_decimal_separator())));
             $data = new Pronamic_WP_Pay_PaymentTestData(wp_get_current_user(), $amount);
             $payment = Pronamic_WP_Pay_Plugin::start($id, $gateway, $data);
             $error = $gateway->get_error();
             if (is_wp_error($error)) {
                 Pronamic_WP_Pay_Plugin::render_errors($error);
             } else {
                 $gateway->redirect($payment);
             }
             exit;
         }
     }
 }
Пример #30
0
    /**
     * Inputs
     */
    public function inputs($inputs)
    {
        $result = '';
        $gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->config_id);
        if ($gateway) {
            $result .= '<div id="pronamic_ideal_inputs">';
            $result .= $gateway->get_input_html();
            $result .= '</div>';
            // Only show extra fields on this paymethod/gateway
            $script = '
				(function($) {
					$(document).bind("shopp_paymethod", function(event, paymethod) {
						if(paymethod) {
							var fields = $("#pronamic_ideal_inputs");

							if(paymethod.indexOf("' . sanitize_title_with_dashes($this->settings['label']) . '") !== -1) {
								fields.show();
							} else {
								fields.hide();
							}
						}
					});
				})(jQuery);
			';
            add_storefrontjs($script);
        }
        return $inputs . $result;
    }