コード例 #1
0
ファイル: Extension.php プロジェクト: daanbakker1995/vanteun
 /**
  * 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
ファイル: Extension.php プロジェクト: daanbakker1995/vanteun
 /**
  * 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;
     }
 }
コード例 #3
0
ファイル: Extension.php プロジェクト: daanbakker1995/vanteun
 /**
  * Update lead status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $status = $payment->get_status();
     $url = M_get_returnurl_permalink();
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $url = M_get_registrationcompleted_permalink();
             break;
     }
     if ($url && $can_redirect) {
         wp_redirect($url, 303);
         exit;
     }
 }
コード例 #4
0
ファイル: Extension.php プロジェクト: daanbakker1995/vanteun
 /**
  * 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;
     }
 }
コード例 #5
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)
 {
     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;
         }
     }
 }
コード例 #6
0
ファイル: Extension.php プロジェクト: wp-pay-extensions/give
 /**
  * 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;
     }
 }
コード例 #7
0
ファイル: Extension.php プロジェクト: daanbakker1995/vanteun
 /**
  * Update lead status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  * @param bool                 $can_redirect
  */
 public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = true)
 {
     // Get return URLs
     $url_return = get_post_meta($payment->get_id(), '_pronamic_payment_url_return', true);
     $url_success = get_post_meta($payment->get_id(), '_pronamic_payment_url_success', true);
     $url_cancel = get_post_meta($payment->get_id(), '_pronamic_payment_url_cancel', true);
     $url_error = get_post_meta($payment->get_id(), '_pronamic_payment_url_error', true);
     $url = $url_return;
     $status = Pronamic_WP_Pay_Extensions_EventEspresso_PaymentStatuses::PENDING;
     // Status
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             $url = $url_cancel;
             $status = Pronamic_WP_Pay_Extensions_EventEspresso_PaymentStatuses::CANCELLED;
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             $url = $url_error;
             $status = Pronamic_WP_Pay_Extensions_EventEspresso_PaymentStatuses::FAILED;
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             $url = $url_error;
             $status = Pronamic_WP_Pay_Extensions_EventEspresso_PaymentStatuses::FAILED;
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $url = $url_success;
             $status = Pronamic_WP_Pay_Extensions_EventEspresso_PaymentStatuses::APPROVED;
             break;
     }
     if (version_compare(EVENT_ESPRESSO_VERSION, '4.6', '>=')) {
         // Transaction
         $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
         $ee_transaction = EEM_Transaction::instance()->get_one_by_ID($payment->get_source_id());
         if ($transaction_processor->reg_step_completed($ee_transaction, 'finalize_registration')) {
             // Set redirect URL to thank you page
             $url = EE_Config::instance()->core->thank_you_page_url(array('e_reg_url_link' => $ee_transaction->primary_registration()->reg_url_link(), 'ee_payment_method' => 'pronamic'));
         } else {
             $ee_payment = $ee_transaction->last_payment();
             // Payment status has changed, save.
             if ($ee_payment && $ee_payment->status() !== $status) {
                 $ee_payment->set_status($status);
                 $ee_payment->save();
             }
             if ($can_redirect) {
                 $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
                 $payment_processor->finalize_payment_for($ee_transaction, true);
             }
         }
     }
     // Redirect
     if ($can_redirect) {
         wp_redirect($url, 303);
         exit;
     }
 }
コード例 #8
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;
     }
 }
コード例 #9
0
 /**
  * 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;
         }
     }
 }
コード例 #10
0
 /**
  * Status update
  */
 public function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $user_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', true);
     $sub_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', true);
     $amount = $payment->get_amount();
     $currency = $payment->get_currency();
     $status = $payment->get_status();
     $note = '';
     // Membership record transaction
     // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L176
     $this->pronamic_record_transaction($user_id, $sub_id, $amount, $currency, time(), $payment->get_id(), $status, $note);
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L871
             do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $member = new M_Membership($user_id);
             if ($member) {
                 $member->create_subscription($sub_id, $this->gateway);
             }
             // Added for affiliate system link
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L790
             do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L901
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             break;
     }
 }
コード例 #11
0
 /**
  * Update lead status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $invoice_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_invoice_id', true);
     $user_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', true);
     $sub_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', true);
     $amount = $payment->get_amount();
     $currency = $payment->get_currency();
     $status = $payment->get_status();
     $note = '';
     if (Pronamic_WP_Pay_Class::method_exists('MS_Factory', 'load') && class_exists('MS_Model_Invoice')) {
         $invoice = MS_Factory::load('MS_Model_Invoice', $invoice_id);
         $gateway_id = $invoice->gateway_id;
     } else {
         // Versions prior to Membership 2 only supported the iDEAL gateway.
         $gateway_id = 'pronamic_ideal';
     }
     if (isset(self::$gateways[$gateway_id])) {
         $gateway_class = self::$gateways[$gateway_id];
         if (class_exists($gateway_class)) {
             $gateway = new $gateway_class();
         }
         // Membership record transaction
         // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L176
         $gateway->pronamic_record_transaction($user_id, $sub_id, $amount, $currency, time(), $payment->get_id(), $status, $note);
     }
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::OPEN:
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L871
             do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/class-ms-factory.php#L116-L184
             // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-invoice.php
             if (isset($gateway, $invoice) && !$invoice->is_paid()) {
                 $invoice->pay_it($gateway->gateway, $payment->get_id());
             }
             if (class_exists('M_Membership')) {
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->create_subscription($sub_id, $gateway->gateway);
                 }
             }
             // Added for affiliate system link
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L790
             do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L901
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             break;
     }
 }