Skip to content

Commit

Permalink
chore: split apple pay address by new line (#548)
Browse files Browse the repository at this point in the history
Co-authored-by: Arkadiusz Kubaczkowski <arek.kubaczkowski@callstak.com>
  • Loading branch information
arekkubaczkowski and Arkadiusz Kubaczkowski committed Sep 1, 2021
1 parent a5bd72d commit e8cb517
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/StripeSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi

func applePayContext(_ context: STPApplePayContext, didCreatePaymentMethod paymentMethod: STPPaymentMethod, paymentInformation: PKPayment, completion: @escaping STPIntentClientSecretCompletionBlock) {
self.applePayCompletionCallback = completion

let address = paymentMethod.billingDetails?.address?.line1?.split(whereSeparator: \.isNewline)
if (address?.indices.contains(0) == true) {
paymentMethod.billingDetails?.address?.line1 = String(address?[0] ?? "")
}
if (address?.indices.contains(1) == true) {
paymentMethod.billingDetails?.address?.line2 = String(address?[1] ?? "")
}

let method = Mappers.mapFromPaymentMethod(paymentMethod)
self.applePayRequestResolver?(Mappers.createResult("paymentMethod", method))
self.applePayRequestRejecter = nil
Expand Down

0 comments on commit e8cb517

Please sign in to comment.