Skip to content

Commit

Permalink
Merge pull request #1145 from angelleye/PFW-129
Browse files Browse the repository at this point in the history
No Billing Phone Number submitted in PayPal Payflow Pro, ref #1123 PF…
  • Loading branch information
Andrew Angell committed Jun 15, 2018
2 parents 7c2e34a + 41b3e3b commit 9c537c7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,9 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
$billing_postcode = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_postcode : $order->get_billing_postcode();
$billing_country = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_country : $order->get_billing_country();
$billing_state = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_state : $order->get_billing_state();
$billing_email = version_compare(WC_VERSION, '3.0', '<') ? $order->billing_email : $order->get_billing_email();

$billing_phone = version_compare( WC_VERSION, '3.0', '<' ) ? $order->billing_phone : $order->get_billing_phone();
$billing_email = version_compare( WC_VERSION, '3.0', '<' ) ? $order->billing_email : $order->get_billing_email();

if (!empty($_POST['paypal_pro_payflow-card-cardholder-first'])) {
$firstname = wc_clean($_POST['paypal_pro_payflow-card-cardholder-first']);
} else {
Expand Down Expand Up @@ -584,7 +585,7 @@ function do_payment($order, $card_number, $card_exp, $card_csc) {
'orderid' => $this->invoice_id_prefix . preg_replace("/[^a-zA-Z0-9]/", "", $order->get_order_number()), // Checks for duplicate order. If you pass orderid in a request and pass it again in the future the response returns DUPLICATE=2 along with the orderid
'orderdesc' => 'Order ' . $order->get_order_number() . ' on ' . get_bloginfo('name'), //
'billtoemail' => $billing_email, // Account holder's email address.
'billtophonenum' => '', // Account holder's phone number.
'billtophonenum' => $billing_phone, // Account holder's phone number.
'billtofirstname' => $firstname, // Account holder's first name.
'billtomiddlename' => '', // Account holder's middle name.
'billtolastname' => $lastname, // Account holder's last name.
Expand Down Expand Up @@ -1227,7 +1228,8 @@ public function add_payment_method() {
$billtostate = (get_user_meta($customer_id, 'billing_state', true)) ? get_user_meta($customer_id, 'billing_state', true) : get_user_meta($customer_id, 'shipping_state', true);
$billtocountry = (get_user_meta($customer_id, 'billing_country', true)) ? get_user_meta($customer_id, 'billing_country', true) : get_user_meta($customer_id, 'shipping_country', true);
$billtozip = (get_user_meta($customer_id, 'billing_postcode', true)) ? get_user_meta($customer_id, 'billing_postcode', true) : get_user_meta($customer_id, 'shipping_postcode', true);

$billing_phone = (get_user_meta($customer_id, 'billing_phone', true)) ? get_user_meta($customer_id, 'billing_phone', true) : '';

$PayPalRequestData = array(
'tender' => 'C',
'trxtype' => 'A',
Expand All @@ -1239,7 +1241,7 @@ public function add_payment_method() {
'orderid' => '',
'orderdesc' => '',
'billtoemail' => '',
'billtophonenum' => '',
'billtophonenum' => $billing_phone,
'billtofirstname' => $billtofirstname,
'billtomiddlename' => '',
'billtolastname' => $billtolastname,
Expand Down Expand Up @@ -1342,6 +1344,8 @@ public function process_subscription_payment($order, $amount, $payment_token = n
$billing_email = version_compare(WC_VERSION, '3.0', '<') ? $billing_email : $order->get_billing_email();
$customer_note_value = version_compare(WC_VERSION, '3.0', '<') ? wptexturize($order->customer_note) : wptexturize($order->get_customer_note());
$customer_note = $customer_note_value ? substr(preg_replace("/[^A-Za-z0-9 ]/", "", $customer_note_value), 0, 256) : '';
$billing_phone = version_compare( WC_VERSION, '3.0', '<' ) ? $order->billing_phone : $order->get_billing_phone();

$PayPalRequestData = array(
'tender' => 'C', // Required. The method of payment. Values are: A = ACH, C = Credit Card, D = Pinless Debit, K = Telecheck, P = PayPal
'trxtype' => ($this->payment_action == 'Authorization' || $order->get_total() == 0 ) ? 'A' : 'S', // Required. Indicates the type of transaction to perform. Values are: A = Authorization, B = Balance Inquiry, C = Credit, D = Delayed Capture, F = Voice Authorization, I = Inquiry, L = Data Upload, N = Duplicate Transaction, S = Sale, V = Void
Expand All @@ -1354,7 +1358,7 @@ public function process_subscription_payment($order, $amount, $payment_token = n
'orderid' => $this->invoice_id_prefix . preg_replace("/[^a-zA-Z0-9]/", "", $order->get_order_number()), // Checks for duplicate order. If you pass orderid in a request and pass it again in the future the response returns DUPLICATE=2 along with the orderid
'orderdesc' => 'Order ' . $order->get_order_number() . ' on ' . get_bloginfo('name'), //
'billtoemail' => $billing_email, // Account holder's email address.
'billtophonenum' => '', // Account holder's phone number.
'billtophonenum' => $billing_phone, // Account holder's phone number.
'billtostreet' => $billing_address_1 . ' ' . $billing_address_2, // The cardholder's street address (number and street name). 150 char max
'billtocity' => $billing_city, // Bill to city. 45 char max
'billtostate' => $billing_state, // Bill to state.
Expand Down Expand Up @@ -1556,6 +1560,8 @@ public function are_reference_transactions_enabled($token_id) {
$billtostate = (get_user_meta($customer_id, 'billing_state', true)) ? get_user_meta($customer_id, 'billing_state', true) : get_user_meta($customer_id, 'shipping_state', true);
$billtocountry = (get_user_meta($customer_id, 'billing_country', true)) ? get_user_meta($customer_id, 'billing_country', true) : get_user_meta($customer_id, 'shipping_country', true);
$billtozip = (get_user_meta($customer_id, 'billing_postcode', true)) ? get_user_meta($customer_id, 'billing_postcode', true) : get_user_meta($customer_id, 'shipping_postcode', true);
$billing_phone = (get_user_meta($customer_id, 'billing_phone', true)) ? get_user_meta($customer_id, 'billing_phone', true) : '';

$PayPalRequestData = array(
'tender' => 'C',
'trxtype' => 'A',
Expand All @@ -1567,7 +1573,7 @@ public function are_reference_transactions_enabled($token_id) {
'orderid' => '',
'orderdesc' => '',
'billtoemail' => '',
'billtophonenum' => '',
'billtophonenum' => $billing_phone,
'billtofirstname' => $billtofirstname,
'billtomiddlename' => '',
'billtolastname' => $billtolastname,
Expand Down

0 comments on commit 9c537c7

Please sign in to comment.