Skip to content

Commit

Permalink
Merge pull request #1327 from angelleye/PFW-433
Browse files Browse the repository at this point in the history
Woo Subscriptions issue ( regression testing ), PFW-433
  • Loading branch information
kcppdevelopers committed Jul 10, 2019
2 parents b6aa053 + 6b769d4 commit af29706
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 5 deletions.
6 changes: 5 additions & 1 deletion angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ public function angelleye_is_display_paypal_transaction_details($post_id) {
$_payment_method = $old_wc ? get_post_meta($order_id, '_payment_method', true) : get_post_meta($order->get_id(), '_payment_method', true);
$_payment_action = $old_wc ? get_post_meta($order_id, '_payment_action', true) : get_post_meta($order->get_id(), '_payment_action', true);
if (isset($_payment_method) && !empty($_payment_method) && isset($_payment_action) && !empty($_payment_action)) {
if (($_payment_method == 'paypal_pro' || $_payment_method == 'paypal_express' || $_payment_method == 'paypal_pro_payflow' || $_payment_method == 'braintree') && $_payment_method != "Sale") {
if ( (($_payment_method == 'paypal_pro' || $_payment_method == 'paypal_express' || $_payment_method == 'paypal_pro_payflow' || $_payment_method == 'braintree')) && ($_payment_method != "Sale" && $order->get_total() > 0)) {
return true;
} else {
return false;
Expand Down Expand Up @@ -1672,6 +1672,10 @@ public static function angelleye_paypal_for_woocommerce_is_set_sandbox_product()
if (isset(WC()->cart) && sizeof(WC()->cart->get_cart()) > 0) {
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
$product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
$product_type = get_post_type($product_id);
if($product_type == 'product_variation') {
$product_id = wp_get_post_parent_id($product_id);
}
$_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true);
if ($_enable_sandbox_mode == 'yes') {
$is_sandbox_set = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ public function angelleye_do_express_checkout_payment() {
update_post_meta($order->get_id(), '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '' );
update_post_meta($order->get_id(), 'paypal_email', $payeremail);
}
$order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : ''));
if( !empty($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'])) {
$order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : ''));
}
WC()->cart->empty_cart();
wc_clear_notices();
$this->angelleye_wp_safe_redirect(add_query_arg('utm_nooverride', '1', $this->gateway->get_return_url($order)), 'do_express_checkout_payment');
Expand Down Expand Up @@ -457,9 +459,9 @@ public function angelleye_do_express_checkout_payment() {
} else {
update_post_meta($order->get_id(), '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '' );
}

$order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']));

if( !empty($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'])) {
$order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']));
}
WC()->cart->empty_cart();
wc_clear_notices();
$this->angelleye_wp_safe_redirect(add_query_arg('utm_nooverride', '1', $this->gateway->get_return_url($order)), 'do_express_checkout_payment');
Expand Down Expand Up @@ -1371,6 +1373,7 @@ public function DoReferenceTransaction($order_id) {
$PayPalRequestData['PaymentDetails'] = $PaymentDetails;
$this->paypal_response = $this->paypal->DoReferenceTransaction($PayPalRequestData);
AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'DoExpressCheckoutPayment', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify);
$this->save_payment_token($order, $referenceid);
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Endpoint: ' . $this->gateway->API_Endpoint);
$PayPalRequest = isset($this->paypal_response['RAWREQUEST']) ? $this->paypal_response['RAWREQUEST'] : '';
Expand Down
4 changes: 4 additions & 0 deletions classes/wc-gateway-braintree-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa
$product = $order->get_product_from_item($values);
$product_id = $product->get_id();
if (!empty($product_id)) {
$product_type = get_post_type($product_id);
if($product_type == 'product_variation') {
$product_id = wp_get_post_parent_id($product_id);
}
$_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true);
if ($_enable_sandbox_mode == 'yes') {
$this->sandbox = true;
Expand Down
4 changes: 4 additions & 0 deletions classes/wc-gateway-paypal-advanced-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa
foreach ($order->get_items() as $cart_item_key => $values) {
$product = $order->get_product_from_item($values);
$product_id = $product->get_id();
$product_type = get_post_type($product_id);
if($product_type == 'product_variation') {
$product_id = wp_get_post_parent_id($product_id);
}
if( !empty($product_id) ) {
$_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true);
if ($_enable_sandbox_mode == 'yes') {
Expand Down
4 changes: 4 additions & 0 deletions classes/wc-gateway-paypal-credit-cards-rest-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa
$product = $order->get_product_from_item($values);
$product_id = $product->get_id();
if( !empty($product_id) ) {
$product_type = get_post_type($product_id);
if($product_type == 'product_variation') {
$product_id = wp_get_post_parent_id($product_id);
}
$_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true);
if ($_enable_sandbox_mode == 'yes') {
$this->testmode = true;
Expand Down
17 changes: 17 additions & 0 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,15 @@ public function process_subscription_payment($order_id) {
$result = $paypal_express_request->DoReferenceTransaction($order_id);
if (!empty($result['ACK']) && $result['ACK'] == 'Success' || $result['ACK'] == 'SuccessWithWarning') {
$paypal_express_request->update_payment_status_by_paypal_responce($order_id, $result);
if ( isset( WC()->cart ) || '' != WC()->cart ) {
if ( ! WC()->cart->is_empty() ) {
WC()->cart->empty_cart();
return array(
'result' => 'success',
'redirect' => add_query_arg( 'utm_nooverride', '1', $this->get_return_url($order) )
);
}
}
} else {
$ErrorCode = urldecode(!empty($result["L_ERRORCODE0"]) ? $result["L_ERRORCODE0"] : '');
$ErrorLongMsg = urldecode(!empty($result["L_LONGMESSAGE0"]) ? $result["L_LONGMESSAGE0"] : '');
Expand Down Expand Up @@ -2140,6 +2149,10 @@ public function free_signup_order_payment($order_id) {
$token_id = wc_clean($_POST['wc-paypal_express-payment-token']);
$token = WC_Payment_Tokens::get($token_id);
$order->payment_complete($token->get_token());
$payment_tokens_id = $token->get_token();
require_once( PAYPAL_FOR_WOOCOMMERCE_PLUGIN_DIR . '/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php' );
$paypal_express_request = new WC_Gateway_PayPal_Express_Request_AngellEYE($this);
$paypal_express_request->save_payment_token($order, $payment_tokens_id);
update_post_meta($order_id, '_first_transaction_id', $token->get_token());
$order->add_order_note('Payment Action: ' . $this->payment_action);
WC()->cart->empty_cart();
Expand Down Expand Up @@ -2197,6 +2210,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa
$product = $order->get_product_from_item($values);
$product_id = $product->get_id();
if( !empty($product_id) ) {
$product_type = get_post_type($product_id);
if($product_type == 'product_variation') {
$product_id = wp_get_post_parent_id($product_id);
}
$_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true);
if ($_enable_sandbox_mode == 'yes') {
$this->testmode = true;
Expand Down
8 changes: 8 additions & 0 deletions classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,10 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp
$token_id = wc_clean( $_POST['wc-paypal_pro-payment-token'] );
$token = WC_Payment_Tokens::get( $token_id );
$order->add_payment_token($token);
if( $this->is_subscription($order_id) ) {
$TRANSACTIONID = $PayPalResult['TRANSACTIONID'];
$this->save_payment_token($order, $TRANSACTIONID);
}
} else {
$TRANSACTIONID = $PayPalResult['TRANSACTIONID'];
$token = new WC_Payment_Token_CC();
Expand Down Expand Up @@ -1983,6 +1987,10 @@ public function angelleye_reload_gateway_credentials_for_woo_subscription_renewa
$product = $order->get_product_from_item($values);
$product_id = $product->get_id();
if( !empty($product_id) ) {
$product_type = get_post_type($product_id);
if($product_type == 'product_variation') {
$product_id = wp_get_post_parent_id($product_id);
}
$_enable_sandbox_mode = get_post_meta($product_id, '_enable_sandbox_mode', true);
if ($_enable_sandbox_mode == 'yes') {
$this->testmode = true;
Expand Down

0 comments on commit af29706

Please sign in to comment.