Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment status not updated on return #2

Open
rvdsteege opened this issue Jan 23, 2023 · 0 comments
Open

Payment status not updated on return #2

rvdsteege opened this issue Jan 23, 2023 · 0 comments

Comments

@rvdsteege
Copy link
Member

From customer:

currently running the addon in sandbox mode and as seen in PayPal test payments work fine so far, but the only thing which is missing is the transaction feedback so all test payments remain status pending...
So far I couldn't find any failure - any hint is welcome.
Redirect URL in PayPal sandbox account is set to beta.●●●●●●●●●●.●●●

Pronamic Pay Version 9.1.3
Pronamic Pay PayPal Add-On Version 2.1.0
(2.3.0 not running as php update to v8 isn't yet possible)

I was able to reproduce the issue in a sandbox environment. The PDT notification validation always seems to result in INVALID:

/**
* Validate Payment Data Transfer (PDT) notification.
*
* @param string[] $data Request data.
* @return bool
*/
public function validate_notification( $data ) {
$url = \add_query_arg(
$data,
$this->config->get_ipn_pb_url() . '?cmd=_notify-validate'
);
/*
* Request notification validation.
*
* Note: A delay in processing by PayPal can result in 'Bad Request' response,
* even though payment has been completed successfully.
*/
$request = Http::get( $url );
// Check response body.
return NotificationValidationStatuses::VERIFIED === $request->body();
}

I'm not sure why it's not working, but I can't imagine this didn't work when it was implemented:

To retrieve the PayPal transaction details (including payment status), it seems we need to update the request in the gateway status update:

$request = Http::post(
	$this->config->get_webscr_url(),
	[
		'body' => [
			'cmd' => '_notify-synch',

			// PayPal transaction ID from $_GET['tx'].
			'tx'  => $transaction_id,

			// PayPal Identity Token for Payment Data Transfer.
			'at'  => '',
		],
	]
);
Sample response.

 

SUCCESS
mc_gross=32.00
protection_eligibility=Eligible
item_number1=
payer_id=UPWNER4BLMTHQ
tax=0.00
payment_date=04%3A45%3A15+Jan+23%2C+2023+PST
payment_status=Completed
charset=UTF-8
mc_shipping=0.00
mc_handling=0.00
first_name=John
mc_fee=1.44
custom=41906
payer_status=verified
business=sb-●●●●●●●●●●●●%40business.example.com
num_cart_items=1
mc_handling1=0.00
payer_email=sb-●●●●●●●●●●●●●●%40personal.example.com
mc_shipping1=0.00
tax1=0.00
txn_id=3KW53494YN666957W
payment_type=instant
last_name=Doe
item_name1=Test
receiver_email=sb-●●●●●●●●●●●●%40business.example.com
payment_fee=
shipping_discount=0.00
quantity1=1
insurance_amount=0.00
receiver_id=E4VWCXY4SY4C
txn_type=cart
discount=0.00
mc_gross_1=32.00
mc_currency=EUR
residence_country=NL
shipping_method=Default
transaction_subject=
payment_gross=

The Identity Token is displayed in the website preferences in the PayPal account when Auto Return and Payment Data Transfer are both enabled.

Internal Help Scout ticket: https://secure.helpscout.net/conversation/2131149837/25091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant