Getting 400 Cannot read property 'indexOf' of undefined after changing to production.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. I'm trying to integrate Payal payments with an Angular SPA using checkout.js. Everything was working on sanbox enviroment, but when I tried to change to production the payments stopped working.
First I was getting an 401 error so I guessed my credentials where wrong. Now I've updated the credentials but started getting a 400 error even when I change back to sandbox that was working correctly.
The error I'm getting is:
TypeError: Cannot read property 'indexOf' of undefined
at determineUrlFromToken (https://www.paypalobjects.com/api/checkout.js:12449:22)
at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js:12102:60)
at _loop2 (https://www.paypalobjects.com/api/checkout.js:1077:62)
at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:1107:29)
at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js:1125:18)
at Component.buildUrl (https://www.paypalobjects.com/api/checkout.js:12101:40)
at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js:8679:57)
at _loop2 (https://www.paypalobjects.com/api/checkout.js:1077:62)
at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js:1107:29)
at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js:1125:18)
I have the following code inside an Angular directive:
function renderPaypalButton() { var orderId; Payments.getPaypalInfo().then(function (response) { paypal.Button.render({ env: response.data.enviroment, client: { sandbox: response.data.paypalSandboxId, production: response.data.paypalId }, locale: $scope.locale, style: { size: 'medium', color: 'gold', shape: 'rect' }, payment: function () { var env = this.props.env; var client = this.props.client; return $scope.placeOrderAsync().then(function (response) { orderId = response.data.orderId; return paypal.rest.payment.create(env, client, { transactions: [ { amount: { total: $scope.getTotal(), currency: 'EUR' } } ] }); }).catch(function (error) { return Main.showError(error, 'ERROR.CREATING_ORDER'); }); }, commit: true, onAuthorize: function (data, actions) { return actions.payment.execute().then(function (response) { console.log('Authorized'); }); }, onCancel: function (data, actions) { return Users.cancelOrder(orderId, $scope.language.id).then(function () { }).catch(function (error) { Main.showError(error, 'ERROR'); }); }, onError: function (error) { if (orderId) { return Users.cancelOrder(orderId, $scope.language.id); } return Main.showError(error, 'ERROR.CREATING_ORDER'); } }, '#paypal-button'); }).catch(function (error) { Main.showError(error, 'ERROR'); }); }
Since what was working is now broken maybe I was somehow blacklisted? Can you please help me resolving this issue?
Thank you,

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Sandbox app error "We're sorry. We can't complete your purchase at this time" with no code change. in About Payments
- Donate button in Selling on your website
- How to change recurring price of current product for new sign ups, in Adding and updating info
- New error with PayPal Button in About Business
- Change from Products to services in About Settings