Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[financial connections] enable native flow #1227

Merged
merged 4 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
102 changes: 51 additions & 51 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion example/src/screens/ApplePayScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
33 changes: 26 additions & 7 deletions ios/Mappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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(),
Expand All @@ -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;
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion stripe-react-native.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down