wagnerwagner / merx

Merx is a plugin to create online shops with Kirby.
https://merx.wagnerwagner.de
102 stars 10 forks source link

Paypal gateway failing on version 1.8 #80

Open guidoferreyra opened 4 months ago

guidoferreyra commented 4 months ago

I just updated merx from 1.7.x to 1.8.1 and when using Paypal gateway I get the following error:

The payment could not be initialized."
--
key | "error.merx.initializePayment"
file | ".../site/plugins/merx/src/Merx.php"
line | 256
details | Object { message: 'Undefined array key "id"', code: 2, file: ".../site/plugins/merx/src/Gateways.php", … }
message | 'Undefined array key "id"'
code | 2
file | ".../site/plugins/merx/src/Gateways.php"
line | 56
code | 500

Let me know how can I help you to debug this.

tobiasfabian commented 3 months ago

Hi @guidoferreyra,

thanks for your report.

This must be an error from the PayPal API. I have added error handling for such PayPal API errors to the develop branch. (https://github.com/wagnerwagner/merx/commit/0601716c1d7af9d6ad735004d97d9e71f76acd89) You can download and install the latest commit and check the error message for further details.

The error response will look something like this:

{
    "status": "error",
    "message": "PayPal error",
    "code": 400,
    "key": "error.merx.paypalError",
    "details": {
        "paypalResponse": {
            "name": "INVALID_REQUEST",
            "message": "Request is not well-formed, syntactically incorrect, or violates schema.",
            "debug_id": "8314d1585f68e",
            "details": [
                {
                    "field": "/purchase_units/@reference_id=='default'/amount/currency_code",
                    "value": "",
                    "location": "body",
                    "issue": "MISSING_REQUIRED_PARAMETER",
                    "description": "A required field / parameter is missing."
                }
            ],
            "links": [
                {
                    "href": "https://developer.paypal.com/docs/api/orders/v2/#error-MISSING_REQUIRED_PARAMETER",
                    "rel": "information_link",
                    "encType": "application/json"
                }
            ]
        }
    }
}

Let me know if this solves your problem.