The user can make payments to my site with paypal. Everything is fine until the user sends to the paypal request a non-english character.
So, I have a paypal button with an address for the client to fill. When the client fills non-english characters sending it to
app.post('/paypal',
There the request goes to this post request
https://${config.hostname}/v2/checkout/orders
making it to give to the try catch and error of 400.
Error: Request failed with status code 400
The address is just info the user has to fill, but e.x. he submits it with ö or ä then the user will see on the paypal pop-up only loading. So not able to pay.
The shipping-address with non-english characters comes to my backend and throws an error, so the paypal pop-up keeps loading forever.
Should i use somewhere language for the address to accept non-english letters? E.X DE.
How could i make the order CAPTURE accept other characters? The current solution i have is a regex replacing non-english characters with english ones.
The request code data with the shipping info from paypal CAPTURE:
// if something is non-english character, then this will post to paypal: /v2/checkout/orders` and give 400 error
const customerOrder = {
intent: "CAPTURE"
, purchase_units: [{
amount: { "value": totalAmount.toFixed(2), "currency_code": "EUR" }
, shipping: {
name: { full_name: `${data.address.firstName || 'not set'} ${data.address.lastName || ''}` }
, address: {
address_line_1: data.address.street || 'not set'
, admin_area_2 : data.address.city || 'not set'
// , admin_area_1 : ""
, postal_code : data.address.zipCode || 'not set'
, country_code : data.address.
, phone: data.phone || '1234567'
}
}
}]
, application_context: {
locale: "de-DE"
, return_url: `http://localhost:${PORT}/sucess/`
, cancel_url: `http://localhost:${PORT}/cancel/`
}
};
Thanks. What else should i fill here? Part of error repsonse is:
data: {
name: 'INVALID_REQUEST',
message: 'Request is not well-formed, syntactically incorrect, or violates schema.',
debug_id: '22dde7fbb568e',
details: [Array],
links: [Array]
}
response: {
status: 400,
statusText: 'Bad Request',
headers: {
NOTE: it works when i replace with regex the used characters. E.X.
word.replace(/ä/g, 'ae');
but it is impossible to cover all the cases.