当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Subscriptions_Manager::process_subscription_payments_on_order方法代码示例

本文整理汇总了PHP中WC_Subscriptions_Manager::process_subscription_payments_on_order方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions_Manager::process_subscription_payments_on_order方法的具体用法?PHP WC_Subscriptions_Manager::process_subscription_payments_on_order怎么用?PHP WC_Subscriptions_Manager::process_subscription_payments_on_order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Subscriptions_Manager的用法示例。


在下文中一共展示了WC_Subscriptions_Manager::process_subscription_payments_on_order方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: scheduled_subscription_payment

 /**
  * scheduled_subscription_payment
  *
  * Hooked to woocommerce_scheduled_subscription_payment_{gateway_id}
  * Completes recurring payments for a subscription
  */
 public function scheduled_subscription_payment($amount_to_charge, $order)
 {
     $this->log(__FUNCTION__, "Info: Beginning processing of scheduled payment for order {$order->id} for the amount of {$amount_to_charge}");
     $this->log(__FUNCTION__, "Info: Merchant ID = {$this->merchant_id}");
     // token is required
     $payment_method_token = get_post_meta($order->id, '_wc_paypal_braintree_payment_method_token', true);
     if (empty($payment_method_token)) {
         $this->log(__FUNCTION__, "Error: Payment method token is missing on order meta");
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
         return;
     }
     // as is the customer id
     $braintree_customer_id = get_post_meta($order->id, '_wc_paypal_braintree_customer_id', true);
     if (empty($braintree_customer_id)) {
         $this->log(__FUNCTION__, "Error: Braintree customer ID is missing on order meta");
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
         return;
     }
     // Create the gateway instance
     require_once dirname(__FILE__) . '/../braintree_sdk/lib/Braintree.php';
     $gateway = new Braintree_Gateway(array('accessToken' => $this->merchant_access_token));
     // Process the sale with the stored token and customer
     $sale_args = apply_filters('wc_gateway_paypal_braintree_sale_args', array('amount' => $amount_to_charge, 'paymentMethodToken' => $payment_method_token, 'recurring' => true, 'customerId' => $braintree_customer_id, 'channel' => 'WooThemes_BT', 'orderId' => $order->id, 'options' => array('submitForSettlement' => true, 'storeInVaultOnSuccess' => true)));
     try {
         $result = $gateway->transaction()->sale($sale_args);
     } catch (Exception $e) {
         $this->log(__FUNCTION__, 'Error: Unable to process scheduled payment. Reason: ' . $e->getMessage());
         return false;
     }
     if (!$result->success) {
         $this->log(__FUNCTION__, "Error: Unable to process scheduled payment: {$result->message}");
         return false;
     }
     $transaction_id = $result->transaction->id;
     $this->log(__FUNCTION__, "Info: Successfully processed schedule payment, transaction id = {$transaction_id}");
     WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     $this->log(__FUNCTION__, "Info: Completed processing of scheduled payment for order {$order->id}");
     $order->add_order_note(sprintf(__('PayPal Braintree charge complete (Charge ID: %s)', 'woocommerce-gateway-paypal-braintree'), $transaction_id));
     $order->payment_complete($transaction_id);
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:46,代码来源:class-wc-gateway-paypal-braintree-subscription.php

示例2: process_scheduled_subscription_payment

 /**
  * process_scheduled_subscription_payment function.
  *
  * @param float $amount_to_charge The amount to charge.
  * @param WC_Order $order The WC_Order object of the order which the subscription was purchased in.
  * @param int $product_id The ID of the subscription product for which this payment relates.
  */
 public function process_scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     $result = $this->process_subscription_payment($order, $amount_to_charge);
     if (is_wp_error($result)) {
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     } else {
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     }
 }
开发者ID:bmcgowan,项目名称:woocommerce-payeezy,代码行数:16,代码来源:class-wc-payeezy-gateway-addons-deprecated.php

示例3: scheduled_subscription_payment

 /**
  * scheduled_subscription_payment function.
  *
  * @param $amount_to_charge float The amount to charge.
  * @param $order WC_Order The WC_Order object of the order which the subscription was purchased in.
  * @param $product_id int The ID of the subscription product for which this payment relates.
  * @access public
  * @return void
  */
 function scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     $result = $this->process_subscription_payment($order, $amount_to_charge);
     if (is_wp_error($result)) {
         $order->add_order_note(sprintf(__('eWAY subscription renewal failed - %s', 'wc-eway'), $this->response_message_lookup($result->get_error_message())));
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     } else {
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     }
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:19,代码来源:class-wc-gateway-eway-subscriptions.php

示例4: process_paypal_ipn_request


//.........这里部分代码省略.........
             // Payment completed
             if ($is_payment_change) {
                 $order->add_order_note(__('IPN subscription payment method changed.', WC_Subscriptions::$text_domain));
             } else {
                 $order->add_order_note(__('IPN subscription sign up completed.', WC_Subscriptions::$text_domain));
             }
             if (self::$debug) {
                 if ($is_payment_change) {
                     self::$log->add('paypal', 'IPN subscription payment method changed for order ' . $order_id);
                 } else {
                     self::$log->add('paypal', 'IPN subscription sign up completed for order ' . $order_id);
                 }
             }
             break;
         case 'subscr_payment':
             if ('completed' == strtolower($transaction_details['payment_status'])) {
                 // Store PayPal Details
                 update_post_meta($order_id, 'PayPal Transaction ID', $transaction_details['txn_id']);
                 update_post_meta($order_id, 'Payer PayPal first name', $transaction_details['first_name']);
                 update_post_meta($order_id, 'Payer PayPal last name', $transaction_details['last_name']);
                 update_post_meta($order_id, 'PayPal Payment type', $transaction_details['payment_type']);
                 // Subscription Payment completed
                 $order->add_order_note(__('IPN subscription payment completed.', WC_Subscriptions::$text_domain));
                 if (self::$debug) {
                     self::$log->add('paypal', 'IPN subscription payment completed for order ' . $order_id);
                 }
                 // First payment on order, process payment & activate subscription
                 if ($is_first_payment) {
                     $order->payment_complete();
                     WC_Subscriptions_Manager::activate_subscriptions_for_order($order);
                 } else {
                     // We don't need to reactivate the subscription because Subs didn't suspend it
                     remove_action('reactivated_subscription_paypal', __CLASS__ . '::reactivate_subscription_with_paypal', 10, 2);
                     WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
                     add_action('reactivated_subscription_paypal', __CLASS__ . '::reactivate_subscription_with_paypal', 10, 2);
                 }
             } elseif ('failed' == strtolower($transaction_details['payment_status'])) {
                 // Subscription Payment completed
                 $order->add_order_note(__('IPN subscription payment failed.', WC_Subscriptions::$text_domain));
                 if (self::$debug) {
                     self::$log->add('paypal', 'IPN subscription payment failed for order ' . $order_id);
                 }
                 // First payment on order, don't generate a renewal order
                 if ($is_first_payment) {
                     remove_action('processed_subscription_payment_failure', 'WC_Subscriptions_Renewal_Order::generate_failed_payment_renewal_order', 10, 2);
                 }
                 WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
             } else {
                 if (self::$debug) {
                     self::$log->add('paypal', 'IPN subscription payment notification received for order ' . $order_id . ' with status ' . $transaction_details['payment_status']);
                 }
             }
             break;
         case 'subscr_cancel':
             if ('true' == get_post_meta($order_id, '_wcs_changing_payment_from_paypal_to_paypal', true)) {
                 // The flag has served its purpose
                 delete_post_meta($order_id, '_wcs_changing_payment_from_paypal_to_paypal');
                 if (self::$debug) {
                     self::$log->add('paypal', 'IPN subscription cancellation request ignored as changing PayPal to PayPal, for order ' . $order_id);
                 }
             } else {
                 WC_Subscriptions_Manager::cancel_subscriptions_for_order($order);
                 // Subscription Cancellation Completed
                 $order->add_order_note(__('IPN subscription cancelled for order.', WC_Subscriptions::$text_domain));
                 if (self::$debug) {
                     self::$log->add('paypal', 'IPN subscription cancelled for order ' . $order_id);
开发者ID:bulats,项目名称:chef,代码行数:67,代码来源:gateway-paypal-standard-subscriptions.php

示例5: process_renewal_payment_1_5

 /**
  * Process subscription renewal
  *
  * @since 4.1.0
  * @param float $amount_to_charge subscription amount to charge, could include multiple renewals if they've previously failed and the admin has enabled it
  * @param WC_Order $order original order containing the subscription
  * @param int $product_id the subscription product id
  */
 public function process_renewal_payment_1_5($amount_to_charge, $order, $product_id)
 {
     try {
         // set order defaults
         $order = $this->get_gateway()->get_order($order->id);
         // zero-dollar subscription renewal. weird, but apparently it happens
         if (0 == $amount_to_charge) {
             // add order note
             $order->add_order_note(sprintf(_x('%s0 Subscription Renewal Approved', 'Supports direct credit card subscriptions', $this->get_gateway()->get_text_domain()), get_woocommerce_currency_symbol()));
             // update subscription
             WC_Subscriptions_Manager::process_subscription_payments_on_order($order, $product_id);
             return;
         }
         // set the amount to charge, ensuring that we have a decimal point, even if it's 1.00
         $order->payment_total = SV_WC_Helper::number_format($amount_to_charge);
         // required
         if (!$order->payment->token || !$order->get_user_id()) {
             throw new SV_WC_Payment_Gateway_Exception('Subscription Renewal: Payment Token or User ID is missing/invalid.');
         }
         // get the token, we've already verified it's good
         $token = $this->get_gateway()->get_payment_token($order->get_user_id(), $order->payment->token);
         // perform the transaction
         if ($this->get_gateway()->is_credit_card_gateway()) {
             if ($this->get_gateway()->perform_credit_card_charge()) {
                 $response = $this->get_gateway()->get_api()->credit_card_charge($order);
             } else {
                 $response = $this->get_gateway()->get_api()->credit_card_authorization($order);
             }
         } elseif ($this->get_gateway()->is_echeck_gateway()) {
             $response = $this->get_gateway()->get_api()->check_debit($order);
         }
         // check for success
         if ($response->transaction_approved()) {
             // order note based on gateway type
             if ($this->get_gateway()->is_credit_card_gateway()) {
                 $message = sprintf(_x('%s %s Subscription Renewal Payment Approved: %s ending in %s (expires %s)', 'Supports direct credit card subscriptions', $this->get_gateway()->get_text_domain()), $this->get_gateway()->get_method_title(), $this->get_gateway()->perform_credit_card_authorization() ? 'Authorization' : 'Charge', $token->get_card_type() ? $token->get_type_full() : 'card', $token->get_last_four(), $token->get_exp_month() . '/' . $token->get_exp_year());
             } elseif ($this->get_gateway()->is_echeck_gateway()) {
                 // there may or may not be an account type (checking/savings) available, which is fine
                 $message = sprintf(_x('%s Check Subscription Renewal Payment Approved: %s account ending in %s', 'Supports direct cheque subscriptions', $this->get_gateway()->get_text_domain()), $this->get_gateway()->get_method_title(), $token->get_account_type(), $token->get_last_four());
             }
             // add order note
             $order->add_order_note($message);
             // set transaction ID manually, WCS 1.5.x calls WC_Order::payment_complete() internally
             if ($response->get_transaction_id()) {
                 update_post_meta($order->id, '_transaction_id', $response->get_transaction_id());
             }
             // update subscription
             WC_Subscriptions_Manager::process_subscription_payments_on_order($order, $product_id);
         } else {
             // failure
             throw new SV_WC_Payment_Gateway_Exception(sprintf('%s: %s', $response->get_status_code(), $response->get_status_message()));
         }
     } catch (SV_WC_Plugin_Exception $e) {
         // don't mark the order as failed, Subscriptions will handle marking the renewal order as failed
         $order->add_order_note(sprintf(_x('%s Renewal Payment Failed (%s)', $this->get_gateway()->get_text_domain()), $this->get_gateway()->get_method_title(), $e->getMessage()));
         // update subscription
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     }
 }
开发者ID:shredzjc,项目名称:wc-plugin-framework,代码行数:67,代码来源:class-sv-wc-payment-gateway-integration-subscriptions.php

示例6: scheduled_subscription_payment

 /**
  * In typical PayPal style, there are a couple of important limitations we need to work around:
  *
  * 1. PayPal does not support subscriptions with a $0 recurring total. As a result, we treat it
  * as a normal purchase and then handle the subscription renewals here.
  *
  * 2. PayPal make no guarantee about when a recurring payment will be charged. This creates issues for
  * suspending a subscription until the payment is processed. Specifically, if PayPal processed a payment
  * *before* it was due, we can't suspend the subscription when it is due because it will remain suspended
  * until the next payment. As a result, subscriptions for PayPal are not suspended. However, if there was
  * an issue with the subscription sign-up or payment that was not correctly reported to the store, then the
  * subscription would remain active. No renewal order would be generated, because no payments are completed,
  * so physical subscriptions would not be affected, however, subscriptions to digital goods would be affected.
  *
  * @since 1.4.3
  */
 public static function scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     if (0 == $amount_to_charge) {
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     } else {
         $hook_args = array('subscription_key' => WC_Subscriptions_Manager::get_subscription_key($order->id, $product_id));
         $one_day_from_now = gmdate('U') + 60 * 60 * 24;
         wp_schedule_single_event($one_day_from_now, 'paypal_check_subscription_payment', $hook_args);
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:26,代码来源:gateway-paypal-standard-subscriptions.php

示例7: scheduled_subscription_payment

 /**
  * Process a scheduled payment
  *
  * @access      public
  * @param       float $amount_to_charge
  * @param       WC_Order $order
  * @param       int $product_id
  * @return      void
  */
 public function scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     $this->order = $order;
     $charge = $this->process_subscription_payment($amount_to_charge);
     if ($charge) {
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     } else {
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     }
 }
开发者ID:tccyp001,项目名称:onemore-wordpress,代码行数:19,代码来源:class-s4wc_subscriptions_gateway.php

示例8: scheduled_subscription_payment

 /**
  * scheduled_subscription_payment function.
  *
  * @param $amount_to_charge float The amount to charge.
  * @param $order            WC_Order The WC_Order object of the order which the subscription was purchased in.
  * @param $product_id       int The ID of the subscription product for which this payment relates.
  *
  * @access public
  * @return void
  *
  * @since 0.6.0
  */
 public function scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     // Process the payment
     $result = $this->process_subscription_payment($order, $amount_to_charge);
     // If the process results in error, then marked order as failed. If not, continue subscription
     if (is_wp_error($result)) {
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     } else {
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     }
 }
开发者ID:RexAK,项目名称:woocommerce-cardconnect-2,代码行数:23,代码来源:class-wc-gateway-cardconnect-addons.php

示例9: scheduled_subscription_payment

 /**
  * Process the subscription payment (manually... well via wp_cron)
  *
  * @param $amount the amount for this payment
  * @param $order the order ID
  * @param $product_id the product ID
  */
 function scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     $this->params = array();
     $this->params["amount"] = (int) ($amount_to_charge * 100);
     $this->params["test"] = $test_mode;
     $this->params["reference"] = $order->id . "-" . date("dmY");
     // Reference for order ID 123 will become 123-01022012
     $token = get_post_meta($order->id, "fatzebra_card_token", true);
     $this->params["card_token"] = $token;
     $ip = get_post_meta($post_id, "Customer IP Address", true);
     if (empty($ip)) {
         $ip = "127.0.0.1";
     }
     $this->params["customer_ip"] = $ip;
     $this->params["deferred"] = false;
     $result = $this->do_payment($this->params);
     if (is_wp_error($result)) {
         $error = "";
         $txn_id = "None";
         switch ($result->get_error_code()) {
             case 1:
                 // Non-200 response, so failed... (e.g. 401, 403, 500 etc).
                 $error = $result->get_error_message();
                 break;
             case 2:
                 // Gateway error (data etc)
                 $errors = $result->get_error_data();
                 $error = implode(", ", $errors);
                 error_log("WooCommerce Fat Zebra - Gateway Error: " . print_r($errors, true));
                 break;
             case 3:
                 // Declined - error data is array with keys: message, id
                 $error = $this->response_data->response->message;
                 $txn_id = $this->response_data->response->transaction_id;
                 break;
             case 4:
                 // Exception caught, something bad happened. Data is exception
             // Exception caught, something bad happened. Data is exception
             default:
                 $error = "Unknown - Error - See error log";
                 error_log("WC Fat Zebra (Subscriptions) - Unknown Error (exception): " . print_r($result->get_error_data(), true));
                 break;
         }
         // Add the error details and return
         $order->add_order_note(__("Subscription Payment Failed: " . $error . ". Transaction ID: " . $txn_id));
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     } else {
         // Success! Returned is an array with the transaction ID etc
         // Update the subscription and return
         // Add a note to the order
         $order->add_order_note(__("Subscription Payment Successful. Transaction ID: " . $result["transaction_id"]));
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     }
 }
开发者ID:atomixdesign,项目名称:FatZebra-WooCommerce,代码行数:61,代码来源:class-wc-fatzebra-masterpass.php

示例10: process_ipn

 /**
  * Process the IPN response from Amazon. This is specific for processing a subscription renewal IPN response
  * as it requires marking the order using WCS-specific methods instead of changing the order status. All
  * non-subscription renewal IPNs are processed using the parent class process_ipn() method
  *
  * @since 2.0
  */
 public function process_ipn()
 {
     extract($this->get_ipn_data());
     try {
         // verify all required IPN data is present, signature is valid, etc.
         $this->verify_ipn_data($order, $data);
         // process the IPN status for subscription renewal payments
         if ($GLOBALS['wc_amazon_fps']->is_subscriptions_active() && WC_Subscriptions_Order::order_contains_subscription($order) && false !== strpos($data['callerReference'], '-')) {
             // update subscription, note 'PENDING' status is not parsed here as it's not useful for a subscription renewal
             switch ($data['transactionStatus']) {
                 case 'SUCCESS':
                     $order->add_order_note(sprintf(__('Amazon Subscription Renewal Transaction Approved (ID: %s)', WC_Amazon_FPS::TEXT_DOMAIN), $data['transactionId']));
                     WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
                     break;
                 case 'FAILURE':
                     $order->add_order_note(sprintf(__('Amazon Subscription Renewal Transaction Failed (ID: %s - Code: %s - %s', WC_Amazon_FPS::TEXT_DOMAIN), $data['transactionId'], $data['statusCode'], $data['statusMessage']));
                     WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
                     break;
                 case 'CANCELLED':
                     $order->add_order_note(sprintf(__('Amazon Subscription Renewal Transaction Cancelled (ID: %s)', WC_Amazon_FPS::TEXT_DOMAIN), $data['transactionId']));
                     WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
                     break;
             }
         } else {
             // otherwise process IPN response as normal
             parent::process_ipn_status($order, $data);
         }
     } catch (Exception $e) {
         $this->mark_order_as_failed($order, __('IPN: ', WC_Amazon_FPS::TEXT_DOMAIN) . $e->getMessage());
     }
     // send success
     header('HTTP/1.1 200 OK');
 }
开发者ID:Qualitair,项目名称:ecommerce,代码行数:40,代码来源:class-wc-gateway-amazon-fps-addons.php

示例11: scheduled_subscription_payment

 /**
  * Scheduled subscription payment.
  *
  * @since  2.0
  **/
 function scheduled_subscription_payment($amount_to_charge, $order)
 {
     // Check if order was created using this method
     if ($this->id == get_post_meta($order->id, '_payment_method', true)) {
         // Prevent hook from firing twice
         if (!get_post_meta($order->id, '_schedule_klarna_subscription_payment', true)) {
             $result = $this->process_subscription_payment($amount_to_charge, $order);
             if (false == $result) {
                 WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
             } else {
                 WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
                 $order->payment_complete();
                 // Need to mark new order complete, so Subscription is marked as Active again
             }
             add_post_meta($order->id, '_schedule_klarna_subscription_payment', 'no', true);
         } else {
             delete_post_meta($order->id, '_schedule_klarna_subscription_payment', 'no');
         }
     }
 }
开发者ID:NoviumDesign,项目名称:polefitness,代码行数:25,代码来源:class-klarna-checkout.php

示例12: process_subscription_renewal_payment

 /**
  * Process subscription renewal
  *
  * @since 2.0
  * @param float $amount_to_charge subscription amount to charge, could include multiple renewals if they've previously failed and the admin has enabled it
  * @param \WC_Order $order original order containing the subscription
  * @param int $product_id the ID of the subscription product
  * @throws WC_Gateway_Braintree_Exception
  * @throws Exception
  */
 public function process_subscription_renewal_payment($amount_to_charge, $order, $product_id)
 {
     try {
         // set order defaults
         $order = $this->get_order($order->id);
         // set the amount to charge
         $order->braintree_order['amount'] = $amount_to_charge;
         // set credit card token
         $order->braintree_order['paymentMethodToken'] = get_post_meta($order->id, '_wc_braintree_cc_token', true);
         // required
         if (!$order->braintree_order['customerId'] || !$order->braintree_order['paymentMethodToken']) {
             throw new Exception(__('Subscription Renewal: Customer ID or Credit Card Token is missing.', WC_Braintree::TEXT_DOMAIN));
         }
         $response = Braintree_Transaction::sale($order->braintree_order);
         // check for success
         if ($response->success) {
             // add order note
             $order->add_order_note(sprintf(__('Braintree Subscription Renewal Payment Approved (Transaction ID: %s) ', WC_Braintree::TEXT_DOMAIN), $response->transaction->id));
             // update subscription
             WC_Subscriptions_Manager::process_subscription_payments_on_order($order, $product_id);
         } else {
             // failure
             throw new WC_Gateway_Braintree_Exception('transaction', $response);
         }
     } catch (WC_Gateway_Braintree_Exception $e) {
         // mark order as failed, which adds an order note for the admin and displays a generic "payment error" to the customer
         $this->mark_order_as_failed($order, $e->getMessage());
         // add detailed debugging information
         $this->add_debug_message($e->getErrors());
         // update subscription
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     } catch (Braintree_Exception_Authorization $e) {
         $this->mark_order_as_failed($order, __('Authorization failed, ensure that your API key is correct and has permissions to create transactions.', WC_Braintree::TEXT_DOMAIN));
         // update subscription
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     } catch (Exception $e) {
         $this->mark_order_as_failed($order, sprintf(__('%s - Error Type %s', WC_Braintree::TEXT_DOMAIN), $e->getMessage(), get_class($e)));
         // update subscription
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:51,代码来源:class-wc-gateway-braintree-addons.php

示例13: scheduled_subscription_payment

 /**
  * @param float $amount
  * @param WC_Order $order
  * @param int $product_id
  * @return bool|WP_Error
  */
 public function scheduled_subscription_payment($amount, $order, $product_id)
 {
     global $x3m_account_funds;
     $order_items = $order->get_items();
     $product = $order->get_product_from_item(array_shift($order_items));
     $subscription_name = sprintf(__('Subscription for "%s"', 'wc_account_funds'), $product->get_title()) . ' ' . sprintf(__('(Order %s)', 'wc_account_funds'), $order->get_order_number());
     $user_id = get_post_meta($order->id, '_customer_user', true);
     $error = false;
     if (!$user_id) {
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
         return new WP_Error('accountfunds', __('Customer not found', 'wc_account_funds'));
     }
     $funds = $x3m_account_funds->get_account_funds($user_id, false);
     if ($amount > $funds) {
         WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order, $product_id);
         return new WP_Error('accountfunds', __('Insufficient funds', 'wc_account_funds'));
     }
     $funds -= $amount;
     update_user_meta($user_id, 'account_funds', $funds);
     $order->add_order_note(__('Account Funds subscription payment completed', 'wc_account_funds'));
     WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     return true;
 }
开发者ID:bulbulbigboss,项目名称:bigboss-woocommerce-deposit-funds,代码行数:29,代码来源:Bigboss-WooCommerce-deposit-funds-getaways.php

示例14: process_scheduled_subscription_payment

 /**
  * Process a payment for an ongoing subscription.
  */
 function process_scheduled_subscription_payment($amount_to_charge, $order, $product_id)
 {
     $user = new WP_User($order->user_id);
     $this->check_payment_method_conversion($user->user_login, $user->ID);
     $customer_vault_ids = get_user_meta($user->ID, 'customer_vault_ids', true);
     $payment_method_number = get_post_meta($order->id, 'payment_method_number', true);
     $inspire_request = array('username' => $this->username, 'password' => $this->password, 'amount' => $amount_to_charge, 'type' => $this->salemethod, 'billing_method' => 'recurring');
     $id = $customer_vault_ids[$payment_method_number];
     if (substr($id, 0, 1) !== '_') {
         $inspire_request['customer_vault_id'] = $id;
     } else {
         $inspire_request['customer_vault_id'] = $user->user_login;
         $inspire_request['billing_id'] = substr($id, 1);
         $inspire_request['ver'] = 2;
     }
     $response = $this->post_and_get_response($inspire_request);
     if ($response['response'] == 1) {
         // Success
         $order->add_order_note(__('Inspire Commerce scheduled subscription payment completed. Transaction ID: ', 'woocommerce') . $response['transactionid']);
         WC_Subscriptions_Manager::process_subscription_payments_on_order($order);
     } else {
         if ($response['response'] == 2) {
             // Decline
             $order->add_order_note(__('Inspire Commerce scheduled subscription payment failed. Payment declined.', 'woocommerce'));
             WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
         } else {
             if ($response['response'] == 3) {
                 // Other transaction error
                 $order->add_order_note(__('Inspire Commerce scheduled subscription payment failed. Error: ', 'woocommerce') . $response['responsetext']);
                 WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($order);
             } else {
                 // No response or unexpected response
                 $order->add_order_note(__('Inspire Commerce scheduled subscription payment failed. Couldn\'t connect to gateway server.', 'woocommerce'));
             }
         }
     }
 }
开发者ID:shubham79,项目名称:Jhintaak,代码行数:40,代码来源:gateway-inspire.php

示例15: process_subscription_payment_on_child_order

 /**
  * If the payment for a renewal order has previously failed and is then paid, we need to make sure the
  * subscription payment function is called.
  *
  * @param int $user_id The id of the user who purchased the subscription
  * @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
  * @since 1.2
  */
 public static function process_subscription_payment_on_child_order($order_id, $payment_status = 'completed')
 {
     if (self::is_renewal($order_id, array('order_role' => 'child'))) {
         $child_order = new WC_Order($order_id);
         $parent_order = self::get_parent_order($child_order);
         $subscriptions_in_order = $child_order->get_items();
         // Should only be one subscription in the renewal order, but just in case
         foreach ($subscriptions_in_order as $item) {
             $item_id = WC_Subscriptions_Order::get_items_product_id($item);
             if (WC_Subscriptions_Order::is_item_subscription($parent_order, $item_id)) {
                 if ('failed' == $payment_status) {
                     // Don't duplicate renewal order
                     remove_action('processed_subscription_payment_failure', __CLASS__ . '::generate_failed_payment_renewal_order', 10, 2);
                     WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($parent_order->id, $item_id);
                     // But make sure orders are still generated for other payments in the same request
                     add_action('processed_subscription_payment_failure', __CLASS__ . '::generate_failed_payment_renewal_order', 10, 2);
                 } else {
                     // Don't duplicate renewal order
                     remove_action('processed_subscription_payment', __CLASS__ . '::generate_paid_renewal_order', 10, 2);
                     WC_Subscriptions_Manager::process_subscription_payments_on_order($parent_order->id, $item_id);
                     // But make sure orders are still generated for other payments in the same request
                     add_action('processed_subscription_payment', __CLASS__ . '::generate_paid_renewal_order', 10, 2);
                     // Reactivate the subscription - activate_subscription doesn't operate on child orders
                     $subscription_key = WC_Subscriptions_Manager::get_subscription_key($parent_order->id, $item_id);
                     WC_Subscriptions_Manager::reactivate_subscription($parent_order->customer_user, $subscription_key);
                 }
             }
         }
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:38,代码来源:class-wc-subscriptions-renewal-order.php


注:本文中的WC_Subscriptions_Manager::process_subscription_payments_on_order方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。