pronamic / wp-pronamic-pay-paypal

PayPal driver for the WordPress payment processing library.
http://www.wp-pay.org/gateways/paypal/
2 stars 2 forks source link

Payment status not updated on return #2

Open rvdsteege opened 1 year ago

rvdsteege commented 1 year ago

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:

https://github.com/pronamic/wp-pronamic-pay-paypal/blob/941b71a9ee8e5f804d1e3f6fc9aa7ed7998a66cb/src/Client.php#L39-L61

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