From 525c2a24f60eca064d2a39e5c5b31106acf2e746 Mon Sep 17 00:00:00 2001 From: charliecruzan-stripe <97612659+charliecruzan-stripe@users.noreply.github.com> Date: Tue, 6 Dec 2022 19:49:00 -0500 Subject: [PATCH] [financial connections] enable native flow (#1227) --- CHANGELOG.md | 9 +++ example/ios/Podfile.lock | 102 ++++++++++++------------- example/src/screens/ApplePayScreen.tsx | 8 +- ios/Mappers.swift | 33 ++++++-- stripe-react-native.podspec | 2 +- 5 files changed, 94 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75c0fb892..de0500560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## Unreleased +### Breaking changes + +### New features + +## Fixes + +- Fixed the `ShippingMethod` type to contain the `isPending` field instead of a `type` field (which previously was never correct). This reflects the inputs accepted. [#1227](https://github.com/stripe/stripe-react-native/pull/1227) +- Fixed the `ShippingMethod` type to contain the `startDate` and `endDate` keys, if applicable. [#1227](https://github.com/stripe/stripe-react-native/pull/1227) + ## 0.22.0 - 2022-12-02 ### Breaking changes diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7f918fa36..e0d78ecbd 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -368,50 +368,50 @@ PODS: - React-Core - React-RCTImage - SocketRocket (0.6.0) - - Stripe (23.2.0): - - StripeApplePay (= 23.2.0) - - StripeCore (= 23.2.0) - - StripePayments (= 23.2.0) - - StripePaymentsUI (= 23.2.0) - - StripeUICore (= 23.2.0) - - stripe-react-native (0.21.0): + - Stripe (23.3.0): + - StripeApplePay (= 23.3.0) + - StripeCore (= 23.3.0) + - StripePayments (= 23.3.0) + - StripePaymentsUI (= 23.3.0) + - StripeUICore (= 23.3.0) + - stripe-react-native (0.22.0): - React-Core - - Stripe (~> 23.2.0) - - StripeApplePay (~> 23.2.0) - - StripeFinancialConnections (~> 23.2.0) - - StripePayments (~> 23.2.0) - - StripePaymentSheet (~> 23.2.0) - - StripePaymentsUI (~> 23.2.0) - - stripe-react-native/Tests (0.21.0): + - Stripe (~> 23.3.0) + - StripeApplePay (~> 23.3.0) + - StripeFinancialConnections (~> 23.3.0) + - StripePayments (~> 23.3.0) + - StripePaymentSheet (~> 23.3.0) + - StripePaymentsUI (~> 23.3.0) + - stripe-react-native/Tests (0.22.0): - React-Core - - Stripe (~> 23.2.0) - - StripeApplePay (~> 23.2.0) - - StripeFinancialConnections (~> 23.2.0) - - StripePayments (~> 23.2.0) - - StripePaymentSheet (~> 23.2.0) - - StripePaymentsUI (~> 23.2.0) - - StripeApplePay (23.2.0): - - StripeCore (= 23.2.0) - - StripeCore (23.2.0) - - StripeFinancialConnections (23.2.0): - - StripeCore (= 23.2.0) - - StripeUICore (= 23.2.0) - - StripePayments (23.2.0): - - StripeCore (= 23.2.0) - - StripePayments/Stripe3DS2 (= 23.2.0) - - StripePayments/Stripe3DS2 (23.2.0): - - StripeCore (= 23.2.0) - - StripePaymentSheet (23.2.0): - - StripeApplePay (= 23.2.0) - - StripeCore (= 23.2.0) - - StripePayments (= 23.2.0) - - StripePaymentsUI (= 23.2.0) - - StripePaymentsUI (23.2.0): - - StripeCore (= 23.2.0) - - StripePayments (= 23.2.0) - - StripeUICore (= 23.2.0) - - StripeUICore (23.2.0): - - StripeCore (= 23.2.0) + - Stripe (~> 23.3.0) + - StripeApplePay (~> 23.3.0) + - StripeFinancialConnections (~> 23.3.0) + - StripePayments (~> 23.3.0) + - StripePaymentSheet (~> 23.3.0) + - StripePaymentsUI (~> 23.3.0) + - StripeApplePay (23.3.0): + - StripeCore (= 23.3.0) + - StripeCore (23.3.0) + - StripeFinancialConnections (23.3.0): + - StripeCore (= 23.3.0) + - StripeUICore (= 23.3.0) + - StripePayments (23.3.0): + - StripeCore (= 23.3.0) + - StripePayments/Stripe3DS2 (= 23.3.0) + - StripePayments/Stripe3DS2 (23.3.0): + - StripeCore (= 23.3.0) + - StripePaymentSheet (23.3.0): + - StripeApplePay (= 23.3.0) + - StripeCore (= 23.3.0) + - StripePayments (= 23.3.0) + - StripePaymentsUI (= 23.3.0) + - StripePaymentsUI (23.3.0): + - StripeCore (= 23.3.0) + - StripePayments (= 23.3.0) + - StripeUICore (= 23.3.0) + - StripeUICore (23.3.0): + - StripeCore (= 23.3.0) - Yoga (1.14.0) - YogaKit (1.18.1): - Yoga (~> 1.14) @@ -636,15 +636,15 @@ SPEC CHECKSUMS: RNCPicker: abc646b53a3d28ccfa3232c927a0ca52e0cf024d RNScreens: 4a1af06327774490d97342c00aee0c2bafb497b7 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Stripe: cc895392856dc7f401119a612e31f020b97cb8d1 - stripe-react-native: febc743cbd836030519cb3a0e53b858e06225f44 - StripeApplePay: 7e43d6b4b9f18e922ba683e549f199a4f6db6fde - StripeCore: 6da916796f87ab91f3dae1d78a93602465964cbc - StripeFinancialConnections: 312fbe670871c7a3227dce0e092d7d5bf209f75e - StripePayments: 7651a56a2a7fe320e5e8b1cb0c2e881536b75021 - StripePaymentSheet: 8803a9debac99541649fc18df4f4f9bdb72354c5 - StripePaymentsUI: 50270053a2e348308d13ba4bc5082df789cb9b64 - StripeUICore: 7727bbfd146f5c4a8dca7f9be241e2d0cdb70310 + Stripe: 8a2e7c77fc28bff1d0961a129fac0cb2ed91ddcb + stripe-react-native: 1b59a802845636bb815d2977404b9ed6b69a01d9 + StripeApplePay: 7b7a5e10891d2ea428cf1a3a737a07fe874f7e7d + StripeCore: 8122b0ffc76922ef0d3f3af3ecffd70c3bfabfc0 + StripeFinancialConnections: 84eba7226fb5fde44287c537dbc0b265ac90e2c4 + StripePayments: f263be25fd96ad8532399ecce4ac72447bcdd419 + StripePaymentSheet: d6838cf23dc2c0bc596634201771ceec63714d60 + StripePaymentsUI: 9b2e5059133fc2ee0e08c58e30a94045cd825b34 + StripeUICore: 484172573bdc2f02d4607a550551be45a090c137 Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d YogaKit: f782866e155069a2cca2517aafea43200b01fd5a diff --git a/example/src/screens/ApplePayScreen.tsx b/example/src/screens/ApplePayScreen.tsx index 092989b17..1bc355f56 100644 --- a/example/src/screens/ApplePayScreen.tsx +++ b/example/src/screens/ApplePayScreen.tsx @@ -140,6 +140,8 @@ export default function ApplePayScreen() { detail: 'Arrives by June 29', label: 'Standard Shipping', amount: '3.21', + startDate: 1670554064, + endDate: 1670726864, }, { identifier: 'express', @@ -152,7 +154,11 @@ export default function ApplePayScreen() { { label: 'Subtotal', amount: '12.75', - paymentType: PlatformPay.PaymentType.Immediate, + paymentType: PlatformPay.PaymentType.Recurring, + startDate: 1670554064, + endDate: 1670726864, + intervalUnit: PlatformPay.IntervalUnit.Day, + intervalCount: 3, }, { label: 'Shipping', diff --git a/ios/Mappers.swift b/ios/Mappers.swift index d9eeeaf4b..5c102fb83 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -146,7 +146,7 @@ class Mappers { let tokenMap: NSDictionary = [ "id": token.tokenId, "bankAccount": mapFromBankAccount(token.bankAccount) ?? NSNull(), - "created": convertDateToUnixTimestamp(date: token.created) ?? NSNull(), + "created": convertDateToUnixTimestampMilliseconds(date: token.created) ?? NSNull(), "card": mapFromCard(token.card) ?? NSNull(), "livemode": token.livemode, "type": mapFromTokenType(token.type) ?? NSNull(), @@ -180,13 +180,24 @@ class Mappers { } class func mapFromShippingMethod(shippingMethod: PKShippingMethod) -> NSDictionary { - let method: NSDictionary = [ + let method: NSMutableDictionary = [ "detail": shippingMethod.detail ?? "", "identifier": shippingMethod.identifier ?? "", "amount": shippingMethod.amount.stringValue, - "type": shippingMethod.type, + "isPending": shippingMethod.type == .pending, "label": shippingMethod.label ] + + if #available(iOS 15.0, *) { + if let dateComponentsRange = shippingMethod.dateComponentsRange { + method.setObject( + convertDateToUnixTimestampSeconds(date: dateComponentsRange.startDateComponents.date) ?? NSNull(), + forKey: "startDate" as NSCopying) + method.setObject( + convertDateToUnixTimestampSeconds(date: dateComponentsRange.endDateComponents.date) ?? NSNull(), + forKey: "endDate" as NSCopying) + } + } return method } @@ -372,7 +383,7 @@ class Mappers { "paymentMethodId": paymentIntent.paymentMethodId ?? NSNull(), "captureMethod": mapCaptureMethod(paymentIntent.captureMethod), "confirmationMethod": mapConfirmationMethod(paymentIntent.confirmationMethod), - "created": convertDateToUnixTimestamp(date: paymentIntent.created) ?? NSNull(), + "created": convertDateToUnixTimestampMilliseconds(date: paymentIntent.created) ?? NSNull(), "amount": paymentIntent.amount, "lastPaymentError": NSNull(), "shipping": NSNull(), @@ -397,7 +408,7 @@ class Mappers { } if let canceledAt = paymentIntent.canceledAt { - intent.setValue(convertDateToUnixTimestamp(date: canceledAt), forKey: "canceledAt") + intent.setValue(convertDateToUnixTimestampMilliseconds(date: canceledAt), forKey: "canceledAt") } return intent; @@ -718,7 +729,7 @@ class Mappers { } intent.setValue(types, forKey: "paymentMethodTypes") - intent.setValue(convertDateToUnixTimestamp(date: setupIntent.created), forKey: "created") + intent.setValue(convertDateToUnixTimestampMilliseconds(date: setupIntent.created), forKey: "created") if let lastSetupError = setupIntent.lastSetupError { let setupError: NSMutableDictionary = [ @@ -928,13 +939,21 @@ class Mappers { return uiCustomization } - class func convertDateToUnixTimestamp(date: Date?) -> String? { + class func convertDateToUnixTimestampMilliseconds(date: Date?) -> String? { if let date = date { let value = date.timeIntervalSince1970 * 1000.0 return String(format: "%.0f", value) } return nil } + + class func convertDateToUnixTimestampSeconds(date: Date?) -> String? { + if let date = date { + let value = date.timeIntervalSince1970 + return String(format: "%.0f", value) + } + return nil + } class func mapFromCardValidationState(state: STPCardValidationState?) -> String { if let state = state { diff --git a/stripe-react-native.podspec b/stripe-react-native.podspec index baa6263f3..1142e1525 100644 --- a/stripe-react-native.podspec +++ b/stripe-react-native.podspec @@ -1,7 +1,7 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) -stripe_version = '~> 23.2.0' +stripe_version = '~> 23.3.0' Pod::Spec.new do |s| s.name = 'stripe-react-native'