Skip to content

Commit

Permalink
Merge pull request #1251 from angelleye/PFW-323
Browse files Browse the repository at this point in the history
Send Line Item Details to PayPal, PFW-323
  • Loading branch information
Drew Angell committed Dec 8, 2018
2 parents 174372a + 7d17209 commit 282a670
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
Expand Up @@ -502,13 +502,12 @@ public function angelleye_do_express_checkout_payment_request() {
}
if ($this->gateway->send_items) {
$Payment['order_items'] = $this->order_param['order_items'];
$Payment['taxamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['taxamt']);
$Payment['shippingamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['shippingamt']);
$Payment['itemamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['itemamt']);
} else {
$Payment['order_items'] = array();
}
$Payment['taxamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['taxamt']);
$Payment['shippingamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['shippingamt']);
$Payment['itemamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['itemamt']);

$REVIEW_RESULT = !empty($paypal_express_checkout['ExpresscheckoutDetails']) ? $paypal_express_checkout['ExpresscheckoutDetails'] : array();
$PaymentRedeemedOffers = array();
if ((isset($REVIEW_RESULT) && !empty($REVIEW_RESULT)) && isset($REVIEW_RESULT['WALLETTYPE0'])) {
Expand Down Expand Up @@ -806,12 +805,12 @@ public function angelleye_set_express_checkout_request() {
if(isset($this->cart_param['is_calculation_mismatch']) && $this->cart_param['is_calculation_mismatch'] == false) {
if ($this->gateway->send_items) {
$Payment['order_items'] = $this->cart_param['order_items'];
$Payment['taxamt'] = $this->cart_param['taxamt'];
$Payment['shippingamt'] = $this->cart_param['shippingamt'];
$Payment['itemamt'] = $this->cart_param['itemamt'];
} else {
$Payment['order_items'] = array();
}
$Payment['taxamt'] = $this->cart_param['taxamt'];
$Payment['shippingamt'] = $this->cart_param['shippingamt'];
$Payment['itemamt'] = $this->cart_param['itemamt'];
}
array_push($Payments, $Payment);
$PayPalRequestData = array(
Expand Down
24 changes: 13 additions & 11 deletions classes/wc-gateway-paypal-advanced-angelleye.php
Expand Up @@ -551,12 +551,8 @@ public function get_secure_token($order) {

$PaymentData = $this->calculation_angelleye->order_calculation($order_id);

if( !empty($PaymentData['discount_amount']) && $PaymentData['discount_amount'] > 0 ) {
$paypal_args['discount'] = $PaymentData['discount_amount'];
}

$paypal_args['ITEMAMT'] = 0;
if ($this->send_items && ($length_error == 0 || count($PaymentData['order_items']) < 11 )) {
$paypal_args['ITEMAMT'] = 0;
$item_loop = 0;
foreach ($PaymentData['order_items'] as $_item) {
$paypal_args['L_NUMBER' . $item_loop] = $_item['number'];
Expand All @@ -571,13 +567,19 @@ public function get_secure_token($order) {
$paypal_args['ITEMAMT'] = $PaymentData['itemamt'];
}

if( $order->get_total() != $PaymentData['shippingamt'] ) {
$paypal_args['FREIGHTAMT'] = $PaymentData['shippingamt'];
} else {
$paypal_args['FREIGHTAMT'] = 0.00;
}
if ($this->send_items ) {
if( $order->get_total() != $PaymentData['shippingamt'] ) {
$paypal_args['FREIGHTAMT'] = $PaymentData['shippingamt'];
} else {
$paypal_args['FREIGHTAMT'] = 0.00;
}

$paypal_args['TAXAMT'] = $PaymentData['taxamt'];
if( !empty($PaymentData['discount_amount']) && $PaymentData['discount_amount'] > 0 ) {
$paypal_args['discount'] = $PaymentData['discount_amount'];
}
$paypal_args['TAXAMT'] = $PaymentData['taxamt'];
}

$paypal_param = $paypal_args;

try {
Expand Down
10 changes: 5 additions & 5 deletions classes/wc-gateway-paypal-pro-angelleye.php
Expand Up @@ -1026,8 +1026,6 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp
'amt' => AngellEYE_Gateway_Paypal::number_format($order->get_total()), // Required. Total amount of order, including shipping, handling, and tax.
'currencycode' => version_compare(WC_VERSION, '3.0', '<') ? $order->get_order_currency() : $order->get_currency(), // Required. Three-letter currency code. Default is USD.
'insuranceamt' => '', // Total shipping insurance costs for this order.
'shipdiscamt' => '0.00', // Shipping discount for the order, specified as a negative number.
'handlingamt' => '0.00', // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt.
'desc' => '', // Description of the order the customer is purchasing. 127 char max.
'custom' => apply_filters( 'ae_ppddp_custom_parameter', json_encode( array( 'order_id' => version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id(), 'order_key' => version_compare( WC_VERSION, '3.0', '<' ) ? $order->order_key : $order->get_order_key() ) ) , $order ), // Free-form field for your own use. 256 char max.
'invnum' => $this->invoice_id_prefix . preg_replace("/[^a-zA-Z0-9]/", "", str_replace("#","",$order->get_order_number())), // Your own invoice or tracking number
Expand Down Expand Up @@ -1094,9 +1092,11 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp
/**
* Shipping/tax/item amount
*/
$PaymentDetails['taxamt'] = $PaymentData['taxamt'];
$PaymentDetails['shippingamt'] = $PaymentData['shippingamt'];
$PaymentDetails['itemamt'] = $PaymentData['itemamt'];
if ($this->send_items) {
$PaymentDetails['taxamt'] = $PaymentData['taxamt'];
$PaymentDetails['shippingamt'] = $PaymentData['shippingamt'];
$PaymentDetails['itemamt'] = $PaymentData['itemamt'];
}
}

/**
Expand Down
23 changes: 10 additions & 13 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Expand Up @@ -613,15 +613,12 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
$PayPalRequestData['SHIPTOCOUNTRY'] = version_compare(WC_VERSION, '3.0', '<') ? $order->shipping_country : $order->get_shipping_country();
$PayPalRequestData['SHIPTOZIP'] = version_compare(WC_VERSION, '3.0', '<') ? $order->shipping_postcode : $order->get_shipping_postcode();
}

$PaymentData = $this->calculation_angelleye->order_calculation($order_id);

if( !empty($PaymentData['discount_amount']) && $PaymentData['discount_amount'] > 0 ) {
$PayPalRequestData['discount'] = $PaymentData['discount_amount'];
}

$OrderItems = array();
if ($this->send_items) {
if( !empty($PaymentData['discount_amount']) && $PaymentData['discount_amount'] > 0 ) {
$PayPalRequestData['discount'] = $PaymentData['discount_amount'];
}
$item_loop = 0;
foreach ($PaymentData['order_items'] as $_item) {
$Item['L_NUMBER' . $item_loop] = $_item['number'];
Expand All @@ -639,14 +636,14 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
/**
* Shipping/tax/item amount
*/
if( $order->get_total() != $PaymentData['shippingamt'] ) {
$PayPalRequestData['freightamt'] = $PaymentData['shippingamt'];
} else {
$PayPalRequestData['freightamt'] = 0.00;
}

$PayPalRequestData['taxamt'] = $PaymentData['taxamt'];

if ($this->send_items) {
if( $order->get_total() != $PaymentData['shippingamt'] ) {
$PayPalRequestData['freightamt'] = $PaymentData['shippingamt'];
} else {
$PayPalRequestData['freightamt'] = 0.00;
}
$PayPalRequestData['taxamt'] = $PaymentData['taxamt'];
$PayPalRequestData['ITEMAMT'] = $PaymentData['itemamt'];
$PayPalRequestData = array_merge($PayPalRequestData, $OrderItems);
}
Expand Down

0 comments on commit 282a670

Please sign in to comment.