示例#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;
     }
 }
示例#2
0
 /**
  * Update the status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  * @param boolean			  $can_redirect (optional, defaults to false)
  */
 public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $source_id = $payment->get_source_id();
     $data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($source_id, array());
     // Only update if order is not completed
     $should_update = edd_get_payment_status($source_id) !== Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH;
     // Defaults
     $status = null;
     $note = null;
     $url = $data->get_normal_return_url();
     $status = $payment->get_status();
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $url = $data->get_cancel_url();
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             if ($should_update) {
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_ABANDONED);
             }
             $url = $data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             if ($should_update) {
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_FAILED);
             }
             $url = $data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             if ($should_update) {
                 edd_insert_payment_note($source_id, __('Payment completed.', 'pronamic_ideal'));
                 /*
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L36
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L199-L206
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/payments/functions.php#L1312-L1332
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/gateways/paypal-standard.php#L555-L576
                  */
             }
             edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH);
             edd_empty_cart();
             $url = $data->get_success_url();
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             if ($should_update) {
                 edd_insert_payment_note($source_id, __('Payment open.', 'pronamic_ideal'));
             }
             break;
         default:
             if ($should_update) {
                 edd_insert_payment_note($source_id, __('Payment unknown.', 'pronamic_ideal'));
             }
             break;
     }
     if ($can_redirect) {
         wp_redirect($url, 303);
         exit;
     }
 }
 /**
  * Update the status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $source_id = $payment->get_source_id();
     $data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($source_id, array());
     // Only update if order is not completed
     $should_update = edd_get_payment_status($source_id) !== Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH;
     if ($should_update) {
         switch ($payment->get_status()) {
             case Pronamic_WP_Pay_Statuses::CANCELLED:
                 // Nothing to do?
                 break;
             case Pronamic_WP_Pay_Statuses::EXPIRED:
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_ABANDONED);
                 break;
             case Pronamic_WP_Pay_Statuses::FAILURE:
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_FAILED);
                 break;
             case Pronamic_WP_Pay_Statuses::SUCCESS:
                 edd_insert_payment_note($source_id, __('Payment completed.', 'pronamic_ideal'));
                 /*
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L36
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L199-L206
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/payments/functions.php#L1312-L1332
                  * @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/gateways/paypal-standard.php#L555-L576
                  */
                 edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH);
                 edd_empty_cart();
                 break;
             case Pronamic_WP_Pay_Statuses::OPEN:
                 edd_insert_payment_note($source_id, __('Payment open.', 'pronamic_ideal'));
                 break;
             default:
                 edd_insert_payment_note($source_id, __('Payment unknown.', 'pronamic_ideal'));
                 break;
         }
     }
 }
示例#4
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)
 {
     $merchant = new Pronamic_WP_Pay_Extensions_WPeCommerce_IDealMerchant($payment->get_source_id());
     $data = new Pronamic_WP_Pay_Extensions_WPeCommerce_PaymentData($merchant);
     $url = $data->get_normal_return_url();
     switch ($payment->status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $merchant->set_purchase_processed_by_purchid(Pronamic_WP_Pay_Extensions_WPeCommerce_WPeCommerce::PURCHASE_STATUS_INCOMPLETE_SALE);
             // $merchant->set_transaction_details( $payment->transaction->getId(), Pronamic_WP_Pay_Extensions_WPeCommerce_WPeCommerce::PURCHASE_STATUS_INCOMPLETE_SALE );
             $url = $data->get_cancel_url();
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             /*
              * Transactions results
              *
              * @see https://github.com/wp-e-commerce/WP-e-Commerce/blob/v3.8.9.5/wpsc-merchants/paypal-pro.merchant.php#L303
              */
             $session_id = get_post_meta($payment->get_id(), '_pronamic_payment_wpsc_session_id', true);
             transaction_results($session_id);
             $merchant->set_purchase_processed_by_purchid(Pronamic_WP_Pay_Extensions_WPeCommerce_WPeCommerce::PURCHASE_STATUS_ACCEPTED_PAYMENT);
             $url = $data->get_success_url();
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             break;
         default:
             break;
     }
     if ($can_redirect) {
         wp_redirect($url, 303);
         exit;
     }
 }
示例#5
0
 /**
  * Update the status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  * @param bool                 $can_redirect (optional, defaults to false)
  */
 public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     // Create empty payment data object to be able to get the URLs
     $empty_data = new Pronamic_WP_Pay_Extensions_IThemesExchange_PaymentData(0, new stdClass());
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $url = $empty_data->get_cancel_url();
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             $url = $empty_data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             $url = $empty_data->get_error_url();
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $transient_transaction = it_exchange_get_transient_transaction(self::$slug, $payment->get_source_id());
             // Create transaction
             $transaction_id = it_exchange_add_transaction(self::$slug, $payment->get_source_id(), Pronamic_WP_Pay_Extensions_IThemesExchange_IThemesExchange::ORDER_STATUS_PAID, $transient_transaction['customer_id'], $transient_transaction['transaction_object']);
             // A transaction ID is numeric on success
             if (!is_numeric($transaction_id)) {
                 $url = $empty_data->get_error_url();
                 break;
             }
             $data = new Pronamic_WP_Pay_Extensions_IThemesExchange_PaymentData($transaction_id, new stdClass());
             $url = $data->get_success_url();
             it_exchange_empty_shopping_cart();
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             $url = $empty_data->get_normal_return_url();
             break;
     }
     if ($can_redirect) {
         wp_redirect($url, 303);
         exit;
     }
 }
 /**
  * Update lead status of the specified payment
  *
  * @see https://github.com/Charitable/Charitable/blob/1.1.4/includes/gateways/class-charitable-gateway-paypal.php#L229-L357
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     global $transaction;
     $transaction_id = $payment->get_source_id();
     $transaction = new MeprTransaction($transaction_id);
     $should_update = !Pronamic_WP_Pay_Extensions_MemberPress_MemberPress::transaction_has_status($transaction, array(MeprTransaction::$failed_str, MeprTransaction::$complete_str));
     if ($should_update) {
         $gateway = new Pronamic_WP_Pay_Extensions_MemberPress_Gateway();
         switch ($payment->get_status()) {
             case Pronamic_WP_Pay_Statuses::CANCELLED:
             case Pronamic_WP_Pay_Statuses::EXPIRED:
             case Pronamic_WP_Pay_Statuses::FAILURE:
                 $gateway->record_payment_failure();
                 break;
             case Pronamic_WP_Pay_Statuses::SUCCESS:
                 $gateway->record_payment();
                 break;
             case Pronamic_WP_Pay_Statuses::OPEN:
             default:
                 break;
         }
     }
 }
示例#7
0
 /**
  * Update lead status of the specified payment
  *
  * @see https://github.com/Charitable/Charitable/blob/1.1.4/includes/gateways/class-charitable-gateway-paypal.php#L229-L357
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $donation_id = $payment->get_source_id();
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             give_update_payment_status($donation_id, 'cancelled');
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             give_update_payment_status($donation_id, 'abandoned');
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             give_update_payment_status($donation_id, 'failed');
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             give_update_payment_status($donation_id, 'publish');
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             give_update_payment_status($donation_id, 'pending');
             break;
     }
 }
 /**
  * Source column
  */
 public static function source_text($text, Pronamic_Pay_Payment $payment)
 {
     $url = add_query_arg(array('page' => 'events', 'event_admin_reports' => 'event_list_attendees', 'all_a' => 'true'), admin_url('admin.php'));
     $text = '';
     $text .= __('Event Espresso', 'pronamic_ideal') . '<br />';
     $text .= sprintf('<a href="%s">%s</a>', esc_attr($url), sprintf(__('Attendee #%s', 'pronamic_ideal'), $payment->get_source_id()));
     return $text;
 }
示例#9
0
 /**
  * Source column
  */
 public static function source_text($text, Pronamic_Pay_Payment $payment)
 {
     $url = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $payment->get_source_id()), admin_url('admin.php'));
     $text = '';
     $text .= __('Event Espresso', 'pronamic_ideal') . '<br />';
     $text .= sprintf('<a href="%s">%s</a>', esc_attr($url), sprintf(__('Transaction %s', 'pronamic_ideal'), $payment->get_source_id()));
     return $text;
 }
示例#10
0
 /**
  * Update lead status of the specified payment
  *
  * @param string $payment
  */
 public function update_status(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $lead_id = $payment->get_source_id();
     $lead = RGFormsModel::get_lead($lead_id);
     if ($lead) {
         $form_id = $lead['form_id'];
         $form = RGFormsModel::get_form($form_id);
         $feed = get_pronamic_gf_pay_feed_by_entry_id($lead_id);
         $data = new Pronamic_WP_Pay_Extensions_GravityForms_PaymentData($form, $lead, $feed);
         if ($feed) {
             $url = null;
             switch ($payment->status) {
                 case Pronamic_WP_Pay_Statuses::CANCELLED:
                     $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::CANCELLED;
                     $url = $data->get_cancel_url();
                     break;
                 case Pronamic_WP_Pay_Statuses::EXPIRED:
                     $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::EXPIRED;
                     $url = $feed->get_url(Pronamic_WP_Pay_Extensions_GravityForms_Links::EXPIRED);
                     break;
                 case Pronamic_WP_Pay_Statuses::FAILURE:
                     $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::FAILED;
                     $url = $data->get_error_url();
                     break;
                 case Pronamic_WP_Pay_Statuses::SUCCESS:
                     if (!Pronamic_WP_Pay_Extensions_GravityForms_Entry::is_payment_approved($lead)) {
                         // Only fullfill order if the payment isn't approved aloready
                         $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::APPROVED;
                         // @see https://github.com/gravityforms/gravityformspaypal/blob/2.3.1/class-gf-paypal.php#L1741-L1742
                         if ($this->addon) {
                             $action = array('id' => $payment->get_transaction_id(), 'type' => 'complete_payment', 'transaction_id' => $payment->get_transaction_id(), 'amount' => $payment->get_amount(), 'entry_id' => $lead['id']);
                             $this->addon->complete_payment($lead, $action);
                         }
                         $this->fulfill_order($lead);
                     }
                     $url = $data->get_success_url();
                     break;
                 case Pronamic_WP_Pay_Statuses::OPEN:
                 default:
                     $url = $data->get_normal_return_url();
                     break;
             }
             Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::update_entry($lead);
             if ($url && $can_redirect) {
                 wp_redirect($url);
                 exit;
             }
         }
     }
 }
示例#11
0
 /**
  * Update lead status of the specified payment
  *
  * @see https://github.com/Charitable/Charitable/blob/1.1.4/includes/gateways/class-charitable-gateway-paypal.php#L229-L357
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $donation_id = $payment->get_source_id();
     $donation = new Charitable_Donation($donation_id);
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $donation->update_status('charitable-cancelled');
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             $donation->update_status('charitable-failed');
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             $donation->update_status('charitable-failed');
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $donation->update_status('charitable-completed');
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             $donation->update_status('charitable-pending');
             break;
     }
 }
示例#12
0
 /**
  * Source column
  */
 public static function source_text($text, Pronamic_Pay_Payment $payment)
 {
     $text = '';
     $text .= __('AppThemes', 'pronamic_ideal') . '<br />';
     $text .= sprintf('<a href="%s">%s</a>', get_edit_post_link($payment->get_source_id()), sprintf(__('Order #%s', 'pronamic_ideal'), $payment->get_source_id()));
     return $text;
 }
 /**
  * Update lead status of the specified payment
  *
  * @param string $payment
  */
 public function update_status(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $lead_id = $payment->get_source_id();
     $lead = RGFormsModel::get_lead($lead_id);
     if (!$lead) {
         return;
     }
     $form_id = $lead['form_id'];
     $form = RGFormsModel::get_form($form_id);
     $feed = get_pronamic_gf_pay_feed_by_entry_id($lead_id);
     if (!$feed) {
         return;
     }
     $data = new Pronamic_WP_Pay_Extensions_GravityForms_PaymentData($form, $lead, $feed);
     switch ($payment->status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::CANCELLED;
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::EXPIRED;
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::FAILED;
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             if (!Pronamic_WP_Pay_Extensions_GravityForms_Entry::is_payment_approved($lead)) {
                 // Only fullfill order if the payment isn't approved already
                 $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS] = Pronamic_WP_Pay_Extensions_GravityForms_PaymentStatuses::APPROVED;
                 // @see https://github.com/wp-premium/gravityformspaypal/blob/2.3.1/class-gf-paypal.php#L1741-L1742
                 if ($this->addon) {
                     $action = array('id' => $payment->get_transaction_id(), 'type' => 'complete_payment', 'transaction_id' => $payment->get_transaction_id(), 'amount' => $payment->get_amount(), 'entry_id' => $lead['id']);
                     $this->addon->complete_payment($lead, $action);
                 }
                 $this->fulfill_order($lead);
             }
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             // Nothing to do.
             break;
     }
     // Update payment status property of lead
     Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::update_entry_property($lead['id'], Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS, $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::PAYMENT_STATUS]);
 }
示例#14
0
 /**
  * Source column
  */
 public static function source_text($text, Pronamic_Pay_Payment $payment)
 {
     $text = '';
     $text .= __('Shopp', 'pronamic_ideal') . '<br />';
     $text .= sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => 'shopp-orders', 'id' => $payment->get_source_id()), admin_url('admin.php')), sprintf(__('Order #%s', 'pronamic_ideal'), $payment->get_source_id()));
     return $text;
 }
示例#15
0
 /**
  * Source column
  */
 public static function source_text($text, Pronamic_Pay_Payment $payment)
 {
     $text = '';
     $text .= __('ClassiPress', 'pronamic_ideal') . '<br />';
     $text .= sprintf('<a href="%s">%s</a>', add_query_arg('page', 'transactions', admin_url('admin.php')), sprintf(__('Order #%s', 'pronamic_ideal'), $payment->get_source_id()));
     return $text;
 }