cancel
Showing results for 
Search instead for 
Did you mean: 

Error: Request failed with status code 401 in React Native mobile application

Options
vedasai27
New Community Member
Posted on
I am integrating PayPal in react native mobile application i am getting error for android emulatore, kindly help me,
Kindly find request body, header and api request
let currency = '100 USD';
currency.replace(' USD', '');

const dataDetail = {
intent: 'sale',
payer: {
payment_method: 'paypal',
},
transactions: [
{
amount: {
total: 55,
currency: 'THB',
details: {
subtotal: 55,
tax: '0',
shipping: '0',
handling_fee: '0',
shipping_discount: '0',
insurance: '0',
},
},
},
],
redirect_urls: {
return_url: 'https://example.com',
cancel_url: 'https://example.com',
},
};
 
--------------------------------------------------------
const config2 = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.state.accessToken}`,
},
};
-------------------------------------------
axios
.post(
JSON.stringify(dataDetail),
config2,
)
.then(response => {
console.log('Response payment', response);

const {id, links} = response.data;
const approvalUrl = links.find(data => data.rel == 'approval_url');

this.setState({
paymentId: id,
approvalUrl: approvalUrl.href,
});
})
.catch(err => {
console.log('payment error', {...err});
console.log('payment error :', err);
});

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.