naoufal / react-native-payments

Accept Payments with Apple Pay and Android Pay using the Payment Request API.
https://www.npmjs.com/package/react-native-payments
1.59k stars 413 forks source link

iOS - Apple Pay - Shipping Address get truncated #112

Open olivierlesnicki opened 6 years ago

olivierlesnicki commented 6 years ago

In Apple Pay, I've entered the following shipping address:

2 Westmead
Windsor
England
SL4 3NN
United Kingdom

Yet, when I print PaymentResponse.shippingAddress I get:

{ 
  region: 'England',
  dependentLocality: null,
  city: 'Windsor',
  country: 'GB',
  sortingCode: null,
  postalCode: 'SL4 ',
  organization: null,
  recipient: null,
  phone: null,
  languageCode: null,
  addressLine: null 
}

Is it normal? The postalCode is truncated and the addressLine is empty.

And what should I do to obtain the full shipping address?

olivierlesnicki commented 6 years ago

OK, so I've identified the root of the issue.

Apple Pay obfuscate some of the shipping address information to keep the data anonymous until the actual payment acceptance. It then provides the complete shipping address against the PaymentResponse.

react-native-payments on iOS provides the obfuscated shipping address in the PaymentResponse - it doesn't update it with the full one.

dancalifornia commented 6 years ago

@olivierlesnicki I'm having the same issue. Were you able to get the shipping address? I'm using stripe as my gateway

olivierlesnicki commented 6 years ago

@dancalifornia I'm now using https://github.com/tipsi/tipsi-stripe which works out of the box

dancalifornia commented 6 years ago

@olivierlesnicki thanks, i just ran across this earlier today and was going to try it out.

wkoutre commented 6 years ago

Saved me some time, here @olivierlesnicki ! Thank you.

wkoutre commented 6 years ago

Though... for me, it's still truncating the information/returning null values for fields (notably addressLine) per the OP here even after the payment acceptance. Simulator and physical device, alike.

Anyone else experiencing this issue?

preko96 commented 5 years ago

Anyone found a solution for this?

wkoutre commented 5 years ago

@preko96 I'm successfully using a fork:

https://github.com/wkoutre/react-native-payments

ZyphiraZircon commented 4 years ago

@wkoutre I dunno if you're still active or not, but I'm having this exact issue, and I've tried using your fork to no avail. Is there something specific you modified?

wkoutre commented 4 years ago

@Zyphxion I'm active!

Well to first note, I took out the Stripe capability, as it wasn't implemented properly to be used in tandem with Braintree, and I didn't need Stripe, only Braintree.

Other than that, briefly sifting through my fork's commit history, I can't recall exactly what I did. in the app I currently maintain, though, I do know I pass these options in:

{
  requestShipping: true,
  requestPayerEmail: true,
  requestPayerPhone: true,
  requestPayerName: true,
  requestBilling: true,
}

as the third argument to PaymentRequest like:

new PaymentRequest(methodData, detailsData, PAYMENT_OPTIONS)

Edit: Also, to reiterate, it's expected that the full address details are hidden until after the user accepts the Apple Pay UI (using FaceID, TouchID, PIN). So, before verifying, zip/postal, city, state are the only accessible data.

ZyphiraZircon commented 4 years ago

@wkoutre thanks for the fast response. I tried adding those additional parameters but they didn't seem to change the resulting data. I'm aware of the restriction on the full address details, but am I right to assume that they should be available in the paymentResponse object as a result from

paymentRequest.show().then((paymentResponse) => { // address details should be available here })

Because my payment response object still contains the truncated address data, with just the City/State/ZIP available

Any further light you could shed would be amazing, thanks

wkoutre commented 4 years ago

@Zyphxion Sure thing, and thanks for clarifying. I'm also assuming you're trying this on a physical device, and not a simulator.

Given that assumption, yes, it should be accessible via:

const { shippingContact, billingContact } = paymentResponse.details;

Happy to help out, but at this point, I would need code + a small runnable sample project to get into the weeds of what you're facing.