Skip to content

Commit de509f8

Browse files
committed
Conditionally set PAYPAL_PARTNER_ATTRIBUTION_ID in API configurations for improved flexibility
1 parent 4fcba9c commit de509f8

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

angelleye-includes/paypal-rest-api-utility.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,13 @@ public function set_payment() {
367367
public function getAuth() {
368368
$this->mode = $this->testmode == true ? 'SANDBOX' : 'LIVE';
369369
$auth = new ApiContext(new OAuthTokenCredential($this->rest_client_id, $this->rest_secret_id));
370-
$auth->setConfig(array('mode' => $this->mode, 'http.headers.PayPal-Partner-Attribution-Id' => PAYPAL_PARTNER_ATTRIBUTION_ID, 'log.LogEnabled' => $this->debug, 'log.LogLevel' => ($this->mode == 'SANDBOX') ? 'DEBUG' : 'INFO', 'log.FileName' => angelleye_get_log_path('paypal_credit_card_rest')));
370+
$config = [
371+
'mode' => $this->mode, 'log.LogEnabled' => $this->debug, 'log.LogLevel' => ($this->mode == 'SANDBOX') ? 'DEBUG' : 'INFO', 'log.FileName' => angelleye_get_log_path('paypal_credit_card_rest')
372+
];
373+
if (defined('PAYPAL_PARTNER_ATTRIBUTION_ID') && !empty(PAYPAL_PARTNER_ATTRIBUTION_ID)) {
374+
$config['http.headers.PayPal-Partner-Attribution-Id'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
375+
}
376+
$auth->setConfig($config);
371377
return $auth;
372378
}
373379

classes/wc-gateway-braintree-angelleye.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,9 @@ public function angelleye_do_payment($order) {
14111411
}
14121412
$request_data['orderId'] = $order->get_order_number();
14131413
$request_data['options'] = $this->get_braintree_options();
1414-
$request_data['channel'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
1414+
if (defined('PAYPAL_PARTNER_ATTRIBUTION_ID') && !empty(PAYPAL_PARTNER_ATTRIBUTION_ID)) {
1415+
$request_data['channel'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
1416+
}
14151417
if (!empty($this->softdescriptor)) {
14161418
$request_data['descriptor'] = array('name' => $this->softdescriptor);
14171419
}
@@ -2413,7 +2415,9 @@ public function process_subscription_payment($order, $amount, $payment_token = n
24132415
}
24142416
$request_data['orderId'] = $order->get_order_number();
24152417
$request_data['options'] = $this->get_braintree_options();
2416-
$request_data['channel'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
2418+
if (defined('PAYPAL_PARTNER_ATTRIBUTION_ID') && !empty(PAYPAL_PARTNER_ATTRIBUTION_ID)) {
2419+
$request_data['channel'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
2420+
}
24172421
if ($this->debug) {
24182422
$this->add_log('Begin Transaction::sale() request');
24192423
$this->add_log('Order: ' . print_r($order->get_order_number(), true));

classes/wc-gateway-paypal-advanced-angelleye.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,12 @@ public function inquiry_transaction($order, $order_id) {
200200
'PWD[' . strlen($this->password) . ']' => $this->password,
201201
'ORIGID' => wc_clean($_POST['PNREF']),
202202
'TENDER' => 'C',
203-
'TRXTYPE' => 'I',
204-
'BUTTONSOURCE' => PAYPAL_PARTNER_ATTRIBUTION_ID
203+
'TRXTYPE' => 'I'
205204
);
206205

206+
if (defined('PAYPAL_PARTNER_ATTRIBUTION_ID') && !empty(PAYPAL_PARTNER_ATTRIBUTION_ID)) {
207+
$paypal_args['BUTTONSOURCE'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
208+
}
207209
$postData = ''; //stores the post data string
208210
foreach ($paypal_args as $key => $val) {
209211
$postData .= '&' . $key . '=' . $val;
@@ -509,9 +511,11 @@ public function get_secure_token($order) {
509511
'PAGEBUTTONBGCOLOR' => ltrim($this->page_button_bgcolor, '#'),
510512
'PAGEBUTTONTEXTCOLOR' => ltrim($this->page_button_textcolor, '#'),
511513
'LABELTEXTCOLOR' => ltrim($this->settings['label_textcolor'], '#'),
512-
'MERCHDESCR' => $this->softdescriptor,
513-
'BUTTONSOURCE' => PAYPAL_PARTNER_ATTRIBUTION_ID
514+
'MERCHDESCR' => $this->softdescriptor
514515
);
516+
if (defined('PAYPAL_PARTNER_ATTRIBUTION_ID') && !empty(PAYPAL_PARTNER_ATTRIBUTION_ID)) {
517+
$paypal_args['BUTTONSOURCE'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
518+
}
515519
if (empty($shipping_state)) {
516520
$paypal_args['SHIPTOSTATE[' . strlen($shipping_city) . ']'] = $shipping_city;
517521
} else {
@@ -1200,9 +1204,11 @@ public function create_reference_transaction($token, $order) {
12001204
'SHIPTOCITY[' . strlen($shipping_city) . ']' => $shipping_city,
12011205
'SHIPTOZIP' => $shipping_postcode,
12021206
'SHIPTOCOUNTRY[' . strlen($shipping_country) . ']' => $shipping_country,
1203-
'MERCHDESCR' => $this->softdescriptor,
1204-
'BUTTONSOURCE' => PAYPAL_PARTNER_ATTRIBUTION_ID
1207+
'MERCHDESCR' => $this->softdescriptor
12051208
);
1209+
if (defined('PAYPAL_PARTNER_ATTRIBUTION_ID') && !empty(PAYPAL_PARTNER_ATTRIBUTION_ID)) {
1210+
$paypal_args['BUTTONSOURCE'] = PAYPAL_PARTNER_ATTRIBUTION_ID;
1211+
}
12061212
if ($this->is_subscription($order_id)) {
12071213
$paypal_args['origid'] = $order->get_meta( '_payment_tokens_id', true);
12081214
}

0 commit comments

Comments
 (0)