Has anyone been able to get the Paypal plugin to supply the shipping address?
I’ve tried to do it but it seems to cause bugs and errors. It complains that the property should be a string but I am sure it should be an object according to the documentation. Any help, would be much appreciated. Thanks!
My code:
payPaypal(){
PayPal.init({
"PayPalEnvironmentProduction": "",
"PayPalEnvironmentSandbox": ""
}).then(() => {
// Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
PayPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
// Only needed if you get an "Internal Service Error" after PayPal login!
payPalShippingAddressOption: 1 // PayPalShippingAddressOptionPayPal
})).then(() => {
let userAddress = new PayPalShippingAddress(
'Ben',
'Address 1',
'',
'City',
'County',
'YO11 8NP',
'UK'
);
let orderAmount = this.orderTotal.toString();
let payment = new PayPalPayment(
orderAmount,
'GBP',
'Mobile App Order',
'sale'
)
payment.shippingAddress = userAddress;
PayPal.renderSinglePaymentUI(payment).then((val) => {
// Successfully paid
console.log(JSON.stringify(val));
// Example sandbox response
//
// {
// "client": {
// "environment": "sandbox",
// "product_name": "PayPal iOS SDK",
// "paypal_sdk_version": "2.16.0",
// "platform": "iOS"
// },
// "response_type": "payment",
// "response": {
// "id": "PAY-1AB23456CD789012EF34GHIJ",
// "state": "approved",
// "create_time": "2016-10-03T13:33:33Z",
// "intent": "sale"
// }
// }
}, () => {
// Error or render dialog closed without being successful
});
}, () => {
// Error in configuration
});
}, () => {
// Error in initialization, maybe PayPal isn't supported or something else
});
}