I just installed Paypal Restful 1.01 on our test server and came up against an issue with card processing.
Code:
2024-03-09 14:04:23: (checkout_process) ==> Start createOrder
TokenCache::get, using saved access-token; expires in 32362 seconds.
The curlPost (v2/checkout/orders) request was unsuccessful.
{
"errNum": 400,
"errMsg": "",
"curlErrno": 0,
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"details": [
{
"field": "\/purchase_units\/@reference_id=='default'\/supplementary_data\/card\/level3\/ships_from_postal_code",
"value": "TQ12 5TZ",
"location": "body",
"issue": "must match \"^[a-zA-Z0-9_'.-]*$\""
}
],
"debug_id": "8a641239069c5"
}
...
2024-03-09 14:04:23: (checkout_process) ==> End createOrderAn error occurred when we tried to process your credit card. Please try again, select an alternate payment method or contact us for assistance.
A correctly-formatted UK postcode has a space in it, as above. Paypal appears to have rejected it because it isn't expecting a space. This is not necessarily the fault of the Zen Cart payment module but I managed to get around it by editing includes/modules/payment/paypal/PayPalRestful/Zc2Pp/CreatePayPalOrderRequest.php, changing:
Code:
if (SHIPPING_ORIGIN_ZIP !== '') {
$level_3['ships_from_postal_code'] = SHIPPING_ORIGIN_ZIP;
}
to:
Code:
if (SHIPPING_ORIGIN_ZIP !== '') {
$level_3['ships_from_postal_code'] = str_replace(' ', '', SHIPPING_ORIGIN_ZIP);
}
at line 466 to remove the space.
After that, the card payment went through fine. It might be worth looking into this further as the workaround might not be the right way to fix it.
Bookmarks