Beispiel #1
0
 /**
  * Update lead status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $source_id = $payment->get_source_id();
     $order = new WC_Order((int) $source_id);
     $gateway = new Pronamic_WP_Pay_Extensions_WooCommerce_IDealGateway();
     $data = new Pronamic_WP_Pay_Extensions_WooCommerce_PaymentData($order, $gateway);
     // Only update if order is not 'processing' or 'completed'
     // @see https://github.com/woothemes/woocommerce/blob/v2.0.0/classes/class-wc-order.php#L1279
     $should_update = !Pronamic_WP_Pay_Extensions_WooCommerce_WooCommerce::order_has_status($order, array(Pronamic_WP_Pay_Extensions_WooCommerce_WooCommerce::ORDER_STATUS_COMPLETED, Pronamic_WP_Pay_Extensions_WooCommerce_WooCommerce::ORDER_STATUS_PROCESSING));
     // Defaults
     $status = null;
     $url = $data->get_normal_return_url();
     $status = $payment->get_status();
     $payment_method_title = $order->payment_method_title;
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $url = $data->get_cancel_url();
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             if ($should_update) {
                 $note = sprintf('%s %s.', $payment_method_title, __('payment expired', 'pronamic_ideal'));
                 // WooCommerce PayPal gateway uses 'failed' order status for an 'expired' payment
                 // @see http://plugins.trac.wordpress.org/browser/woocommerce/tags/1.5.4/classes/gateways/class-wc-paypal.php#L557
                 $order->update_status(Pronamic_WP_Pay_Extensions_WooCommerce_WooCommerce::ORDER_STATUS_FAILED, $note);
             }
             $url = $data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             if ($should_update) {
                 $note = sprintf('%s %s.', $payment_method_title, __('payment failed', 'pronamic_ideal'));
                 $order->update_status(Pronamic_WP_Pay_Extensions_WooCommerce_WooCommerce::ORDER_STATUS_FAILED, $note);
             }
             $url = $data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             if ($should_update) {
                 // Payment completed
                 $order->add_order_note(sprintf('%s %s.', $payment_method_title, __('payment completed', 'pronamic_ideal')));
                 // Mark order complete
                 $order->payment_complete();
             }
             $url = $data->get_success_url();
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             if ($should_update) {
                 $order->add_order_note(sprintf('%s %s.', $payment_method_title, __('payment open', 'pronamic_ideal')));
             }
             break;
         default:
             if ($should_update) {
                 $order->add_order_note(sprintf('%s %s.', $payment_method_title, __('payment unknown', 'pronamic_ideal')));
             }
             break;
     }
     if ($can_redirect) {
         wp_redirect($url);
         exit;
     }
 }
Beispiel #2
0
 /**
  * Initialise form fields
  */
 function init_form_fields()
 {
     $description_prefix = '';
     if (Pronamic_WP_Pay_Extensions_WooCommerce_WooCommerce::version_compare('2.0.0', '<')) {
         $description_prefix = '<br />';
     }
     $this->form_fields = array('enabled' => array('title' => __('Enable/Disable', 'pronamic_ideal'), 'type' => 'checkbox', 'label' => __('Enable iDEAL', 'pronamic_ideal'), 'default' => 'no'), 'title' => array('title' => __('Title', 'pronamic_ideal'), 'type' => 'text', 'description' => $description_prefix . __('This controls the title which the user sees during checkout.', 'pronamic_ideal'), 'default' => $this->method_title), 'description' => array('title' => __('Description', 'pronamic_ideal'), 'type' => 'textarea', 'description' => $description_prefix . sprintf(__('Give the customer instructions for paying via %s, and let them know that their order won\'t be shipping until the money is received.', 'pronamic_ideal'), $this->method_title), 'default' => __('With iDEAL you can easily pay online in the secure environment of your own bank.', 'pronamic_ideal')), 'icon' => array('title' => __('Icon', 'pronamic_ideal'), 'type' => 'text', 'description' => sprintf('%s%s<br />%s', $description_prefix, __('This controls the icon which the user sees during checkout.', 'pronamic_ideal'), sprintf(__('Default: <code>%s</code>.', 'pronamic_ideal'), plugins_url('images/icon-24x24.png', Pronamic_WP_Pay_Plugin::$file))), 'default' => plugins_url('images/ideal/wc-icon.png', Pronamic_WP_Pay_Plugin::$file)), 'config_id' => array('title' => __('Configuration', 'pronamic_ideal'), 'type' => 'select', 'default' => '', 'options' => Pronamic_WP_Pay_Plugin::get_config_select_options($this->payment_method)), 'payment' => array('title' => __('Payment Options', 'pronamic_ideal'), 'type' => 'title', 'description' => ''), 'payment_description' => array('title' => __('Payment Description', 'pronamic_ideal'), 'type' => 'text', 'description' => sprintf('%s%s<br />%s<br />%s', $description_prefix, __('This controls the payment description.', 'pronamic_ideal'), sprintf(__('Default: <code>%s</code>.', 'pronamic_ideal'), Pronamic_WP_Pay_Extensions_WooCommerce_PaymentData::get_default_description()), sprintf(__('Tags: %s', 'pronamic_ideal'), sprintf('<code>%s</code> <code>%s</code> <code>%s</code>', '{order_number}', '{order_date}', '{blogname}'))), 'default' => Pronamic_WP_Pay_Extensions_WooCommerce_PaymentData::get_default_description()));
 }