Page 1 of 1

[BUG] - Paypal Express Checkout API

Posted: Sat Dec 17, 2011 4:04 am
by straightlight
There seem to be a bug and strange function name in Paypal Express Checkout API payment module.

In catalog/controller/payment/pp_express.php file.

Then looking at this variable: $api_url, it doesn't seem to exist elsewhere from that line:

Code: Select all

$response = $this->sendTransactionToGateway($api_url, $post_string);
This should rather be replaced with:

Code: Select all

$response = $this->sendTransactionToGateway($api_endpoint, $post_string);
As for this ( osCommerce ? ) function:

Code: Select all

$params['SHIPTOSTATE'] = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);
I can't see anywhere else in OpenCart where the SHIPTOSTATE is being converted as such and neither I can find this function name. Although, I can't find an alternative approach for this field for OpenCart yet. Perhaps the dev team would like to shade some lights on this one. It would also be great stating regarding this unknown constant name: MODULE_PAYMENT_pp_EXPRESS_TRANSACTION_METHOD where it may be originating from.

Additionally, I'd like to state that:

Code: Select all

$payment_data = array(
			'USER'          => $this->config->get('pp_direct_username'),
			'PWD'           => $this->config->get('pp_direct_password'),
			'VERSION'       => '3.2',
			'SIGNATURE'     => $this->config->get('pp_direct_signature'),
			'METHOD'        => 'DoExpressCheckoutPayment',
			'TOKEN'         => $ppe_token,
			'PAYMENTACTION' => (MODULE_PAYMENT_pp_EXPRESS_TRANSACTION_METHOD == 'Sale') ? 'Sale' : 'Authorization',
			'PAYERID'       => $ppe_payerid,
			'AMT'           => $this->format_raw($order->info['total']),
			'CURRENCYCODE'  => $order->info['currency'],
			'BUTTONSOURCE'  => 'osCommerce22_Default_EC'
		);

		if (is_numeric($sendto) && ($sendto > 0)) {
			$params['SHIPTONAME'] = $order->delivery['firstname'] . ' ' . $order->delivery['lastname'];
			$params['SHIPTOSTREET'] = $order->delivery['street_address'];
			$params['SHIPTOCITY'] = $order->delivery['city'];
			$params['SHIPTOSTATE'] = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);
			$params['SHIPTOCOUNTRYCODE'] = $order->delivery['country']['iso_code_2'];
			$params['SHIPTOZIP'] = $order->delivery['postcode'];
		}
should rather be replaced with:

Code: Select all

$payment_data = array(
			'USER'          => $this->config->get('pp_direct_username'),
			'PWD'           => $this->config->get('pp_direct_password'),
			'VERSION'       => '3.2',
			'SIGNATURE'     => $this->config->get('pp_direct_signature'),
			'METHOD'        => 'DoExpressCheckoutPayment',
                        // $ppe_token ?
			'TOKEN'         => $ppe_token,
                        // MODULE_PAYMENT_pp_EXPRESS_TRANSACTION_METHOD ?
			'PAYMENTACTION' => (MODULE_PAYMENT_pp_EXPRESS_TRANSACTION_METHOD == 'Sale') ? 'Sale' : 'Authorization',
                        // $ppe_payerid ?
			'PAYERID'       => $ppe_payerid,
                        // format_raw method ?
			'AMT'           => $this->format_raw($order_info['total']),
			'CURRENCYCODE'  => $order_info['currency_code'],
			'BUTTONSOURCE'  => 'OpenCart1513_Default_EC'
		);

		if (is_numeric($sendto) && ($sendto > 0)) {
			$params['SHIPTONAME'] = $order_info['shipping_firstname'] . ' ' . $order_info['shipping_lastname'];
			$params['SHIPTOSTREET'] = $order_info['shipping_address_1'];
			$params['SHIPTOCITY'] = $order_info['shipping_city'];
			// Until the next solution ?
			//$params['SHIPTOSTATE'] = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);
			$params['SHIPTOCOUNTRYCODE'] = $order_info['iso_code_2'];
			$params['SHIPTOZIP'] = $order_info['shipping_postcode'];
		}

Re: [BUG] - Paypal Express Checkout API

Posted: Sat Dec 17, 2011 4:13 am
by straightlight
I added a few comments and replacements from the code above.