From a8ad96c7fe243874045f5920403967851b3dbab1 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Mon, 26 Nov 2018 17:25:54 +0530 Subject: [PATCH] Feature Request: Adding PayPal fee as meta data, PFW-299 --- angelleye-includes/angelleye-utility.php | 6 ++++++ .../class-wc-gateway-paypal-express-request-angelleye.php | 2 ++ angelleye-includes/paypal-rest-api-utility.php | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/angelleye-includes/angelleye-utility.php b/angelleye-includes/angelleye-utility.php index db134068b..255a3acb3 100644 --- a/angelleye-includes/angelleye-utility.php +++ b/angelleye-includes/angelleye-utility.php @@ -2227,4 +2227,10 @@ public function angelleye_wc_braintree_docapture($order) { } } } + + public static function angelleye_add_paypal_payment_meta($order_id, $payment_meta) { + foreach ($payment_meta as $key => $value) { + update_post_meta($order_id, $key, wc_clean($value)); + } + } } diff --git a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php index 0cf9b42df..459f84e57 100644 --- a/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php +++ b/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php @@ -333,6 +333,8 @@ public function angelleye_do_express_checkout_payment() { if ($this->gateway->payment_action != 'Sale') { AngellEYE_Utility::angelleye_paypal_for_woocommerce_add_paypal_transaction($this->paypal_response, $order, $this->gateway->payment_action); } + $payment_meta = array('Payment type' => !empty($this->paypal_response['PAYMENTINFO_0_PAYMENTTYPE']) ? $this->paypal_response['PAYMENTINFO_0_PAYMENTTYPE'] : '', 'PayPal Transaction Fee' => !empty($this->paypal_response['PAYMENTINFO_0_FEEAMT']) ? $this->paypal_response['PAYMENTINFO_0_FEEAMT'] : ''); + AngellEYE_Utility::angelleye_add_paypal_payment_meta($order_id, $payment_meta); if ($this->response_helper->ec_is_response_success($this->paypal_response)) { do_action('ae_add_custom_order_note', $order, $card = null, $token = null, $this->paypal_response); apply_filters('woocommerce_payment_successful_result', array('result' => 'success'), $order_id); diff --git a/angelleye-includes/paypal-rest-api-utility.php b/angelleye-includes/paypal-rest-api-utility.php index cfb5eadf6..6ecb6b637 100644 --- a/angelleye-includes/paypal-rest-api-utility.php +++ b/angelleye-includes/paypal-rest-api-utility.php @@ -343,7 +343,7 @@ public function set_payment() { public function getAuth() { $this->mode = $this->testmode == true ? 'SANDBOX' : 'LIVE'; $auth = new ApiContext(new OAuthTokenCredential($this->rest_client_id, $this->rest_secret_id)); - $auth->setConfig(array('mode' => $this->mode, 'http.headers.PayPal-Partner-Attribution-Id' => 'AngellEYE_SP_WooCommerce', 'log.LogEnabled' => $this->debug , 'log.LogLevel' => ($this->mode == 'DEBUG') ? 'DEBUG' : 'INFO', 'log.FileName' => wc_get_log_file_path('paypal_credit_card_rest'))); + $auth->setConfig(array('mode' => $this->mode, 'http.headers.PayPal-Partner-Attribution-Id' => 'AngellEYE_SP_WooCommerce', 'log.LogEnabled' => $this->debug , 'log.LogLevel' => ($this->mode == 'SANDBOX') ? 'DEBUG' : 'INFO', 'log.FileName' => wc_get_log_file_path('paypal_credit_card_rest'))); return $auth; }