@stripe/stripe-react-native 0.23.0 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +6 -6
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +3 -3
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +5 -4
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +5 -5
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +26 -27
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +71 -71
- package/ios/ApplePayViewController.swift +2 -0
- package/ios/Mappers.swift +2 -0
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentMethod.js.map +1 -1
- package/lib/commonjs/types/SetupIntent.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentMethod.js.map +1 -1
- package/lib/module/types/SetupIntent.js.map +1 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts +1 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts +2 -0
- package/lib/typescript/src/types/PaymentMethod.d.ts +1 -0
- package/lib/typescript/src/types/SetupIntent.d.ts +2 -0
- package/package.json +7 -17
- package/src/components/AddToWalletButton.tsx +1 -1
- package/src/types/PaymentIntent.ts +2 -0
- package/src/types/PaymentMethod.ts +1 -0
- package/src/types/SetupIntent.ts +2 -0
- package/ios/Tests/AddressSheetUtilsTests.swift +0 -273
- package/ios/Tests/ApplePayUtilsTests.swift +0 -213
- package/ios/Tests/PushProvisioningTests.swift +0 -52
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Tests.swift
|
|
3
|
-
// Tests
|
|
4
|
-
//
|
|
5
|
-
// Created by Charles Cruzan on 6/21/22.
|
|
6
|
-
// Copyright © 2022 Facebook. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import XCTest
|
|
10
|
-
@testable import stripe_react_native
|
|
11
|
-
import PassKit
|
|
12
|
-
|
|
13
|
-
@available(iOS 15.0, *)
|
|
14
|
-
class ApplePayUtilsTests: XCTestCase {
|
|
15
|
-
|
|
16
|
-
func test_buildPaymentSheetApplePayConfig_FailsWithoutMerchantIdentifier() throws {
|
|
17
|
-
XCTAssertThrowsError(
|
|
18
|
-
try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: nil, merchantCountryCode: "", paymentSummaryItems: nil)
|
|
19
|
-
) { error in
|
|
20
|
-
XCTAssertEqual(
|
|
21
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.missingMerchantId
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
func test_buildPaymentSheetApplePayConfig_FailsWithoutCountryCode() throws {
|
|
27
|
-
XCTAssertThrowsError(
|
|
28
|
-
try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: nil, paymentSummaryItems: nil)
|
|
29
|
-
) { error in
|
|
30
|
-
XCTAssertEqual(
|
|
31
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.missingCountryCode
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
func test_buildPaymentSheetApplePayConfig_withNilAndEmptyArray_shouldBeEqual() throws {
|
|
37
|
-
let resultWithItemsAsNil = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: nil)
|
|
38
|
-
let resultWithItemsAsEmptyArray = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: [])
|
|
39
|
-
XCTAssertEqual(resultWithItemsAsNil.paymentSummaryItems, resultWithItemsAsEmptyArray.paymentSummaryItems)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
func test_buildPaymentSheetApplePayConfig_withItems_shouldMatchExpected() throws {
|
|
43
|
-
let result = try ApplePayUtils.buildPaymentSheetApplePayConfig(merchantIdentifier: TestFixtures.MERCHANT_ID, merchantCountryCode: TestFixtures.COUNTRY_CODE, paymentSummaryItems: TestFixtures.CART_ITEM_DICTIONARY)
|
|
44
|
-
|
|
45
|
-
let deferredItemResult = PKDeferredPaymentSummaryItem(label: "deferred label", amount: 1.00)
|
|
46
|
-
deferredItemResult.deferredDate = Date(timeIntervalSince1970: 123456789)
|
|
47
|
-
let immediateItemResult = PKPaymentSummaryItem(label: "immediate label", amount: 2.00, type: .pending)
|
|
48
|
-
let recurringResult = PKRecurringPaymentSummaryItem(label: "recurring label", amount: 1.00)
|
|
49
|
-
recurringResult.intervalUnit = .minute
|
|
50
|
-
recurringResult.intervalCount = 2
|
|
51
|
-
recurringResult.startDate = Date(timeIntervalSince1970: 123456789)
|
|
52
|
-
recurringResult.endDate = Date(timeIntervalSince1970: 234567890)
|
|
53
|
-
|
|
54
|
-
XCTAssertEqual(
|
|
55
|
-
result.paymentSummaryItems,
|
|
56
|
-
[deferredItemResult, immediateItemResult, recurringResult]
|
|
57
|
-
)
|
|
58
|
-
XCTAssertEqual(
|
|
59
|
-
result.merchantId,
|
|
60
|
-
TestFixtures.MERCHANT_ID
|
|
61
|
-
)
|
|
62
|
-
XCTAssertEqual(
|
|
63
|
-
result.merchantCountryCode,
|
|
64
|
-
TestFixtures.COUNTRY_CODE
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
func test_createDeferredPaymentSummaryItem() throws {
|
|
69
|
-
let result = try ApplePayUtils.createDeferredPaymentSummaryItem(item: TestFixtures.DEFERRED_CART_ITEM_DICTIONARY)
|
|
70
|
-
|
|
71
|
-
let expectedResult = PKDeferredPaymentSummaryItem(label: "deferred label", amount: 1.00)
|
|
72
|
-
expectedResult.deferredDate = Date(timeIntervalSince1970: 123456789)
|
|
73
|
-
|
|
74
|
-
XCTAssertEqual(
|
|
75
|
-
result,
|
|
76
|
-
expectedResult
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
func test_createRecurringPaymentSummaryItem() throws {
|
|
81
|
-
let result = try ApplePayUtils.createRecurringPaymentSummaryItem(item: TestFixtures.RECURRING_CART_ITEM_DICTIONARY)
|
|
82
|
-
|
|
83
|
-
let expectedResult = PKRecurringPaymentSummaryItem(label: "recurring label", amount: 1.00)
|
|
84
|
-
expectedResult.intervalUnit = .minute
|
|
85
|
-
expectedResult.intervalCount = 2
|
|
86
|
-
expectedResult.startDate = Date(timeIntervalSince1970: 123456789)
|
|
87
|
-
expectedResult.endDate = Date(timeIntervalSince1970: 234567890)
|
|
88
|
-
|
|
89
|
-
XCTAssertEqual(
|
|
90
|
-
result,
|
|
91
|
-
expectedResult
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
func test_createRecurringPaymentSummaryItem_withUnexpectedIntervalUnit_fails() throws {
|
|
96
|
-
XCTAssertThrowsError(
|
|
97
|
-
try ApplePayUtils.createRecurringPaymentSummaryItem(item: [
|
|
98
|
-
"paymentType":"Recurring",
|
|
99
|
-
"intervalUnit": "decade",
|
|
100
|
-
"intervalCount": 1,
|
|
101
|
-
] as [String : Any])
|
|
102
|
-
) { error in
|
|
103
|
-
XCTAssertEqual(
|
|
104
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.invalidTimeInterval("decade")
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
XCTAssertThrowsError(
|
|
109
|
-
try ApplePayUtils.createRecurringPaymentSummaryItem(item: [
|
|
110
|
-
"paymentType":"Recurring",
|
|
111
|
-
"intervalCount": 1,
|
|
112
|
-
] as [String : Any])
|
|
113
|
-
) { error in
|
|
114
|
-
XCTAssertEqual(
|
|
115
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.invalidTimeInterval("null")
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
func test_createImmediatePaymentSummaryItem() throws {
|
|
121
|
-
let result = ApplePayUtils.createImmediatePaymentSummaryItem(item: TestFixtures.IMMEDIATE_CART_ITEM_DICTIONARY_NOT_PENDING)
|
|
122
|
-
|
|
123
|
-
let expectedResult = PKPaymentSummaryItem(label: "immediate label", amount: 2.00, type: .final)
|
|
124
|
-
|
|
125
|
-
XCTAssertEqual(
|
|
126
|
-
result,
|
|
127
|
-
expectedResult
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
func test_buildPaymentSummaryItems() throws {
|
|
132
|
-
let result = try ApplePayUtils.buildPaymentSummaryItems(items: TestFixtures.CART_ITEM_DICTIONARY)
|
|
133
|
-
let deferredItemResult = PKDeferredPaymentSummaryItem(label: "deferred label", amount: 1.00)
|
|
134
|
-
deferredItemResult.deferredDate = Date(timeIntervalSince1970: 123456789)
|
|
135
|
-
let immediateItemResult = PKPaymentSummaryItem(label: "immediate label", amount: 2.00, type: .pending)
|
|
136
|
-
let recurringResult = PKRecurringPaymentSummaryItem(label: "recurring label", amount: 1.00)
|
|
137
|
-
recurringResult.intervalUnit = .minute
|
|
138
|
-
recurringResult.intervalCount = 2
|
|
139
|
-
recurringResult.startDate = Date(timeIntervalSince1970: 123456789)
|
|
140
|
-
recurringResult.endDate = Date(timeIntervalSince1970: 234567890)
|
|
141
|
-
|
|
142
|
-
XCTAssertEqual(
|
|
143
|
-
result,
|
|
144
|
-
[deferredItemResult, immediateItemResult, recurringResult]
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
func test_buildPaymentSummaryItems_unexpectedType_fails() throws {
|
|
149
|
-
XCTAssertThrowsError(
|
|
150
|
-
try ApplePayUtils.buildPaymentSummaryItems(items: [[
|
|
151
|
-
"paymentType":"wrong type",
|
|
152
|
-
]] as [[String : Any]])
|
|
153
|
-
) { error in
|
|
154
|
-
XCTAssertEqual(
|
|
155
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.invalidCartSummaryItemType("wrong type")
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
XCTAssertThrowsError(
|
|
160
|
-
try ApplePayUtils.buildPaymentSummaryItems(items: [[
|
|
161
|
-
"paymentType":"",
|
|
162
|
-
]] as [[String : Any]])
|
|
163
|
-
) { error in
|
|
164
|
-
XCTAssertEqual(
|
|
165
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.invalidCartSummaryItemType("")
|
|
166
|
-
)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
XCTAssertThrowsError(
|
|
170
|
-
try ApplePayUtils.buildPaymentSummaryItems(items: [[
|
|
171
|
-
"label":"my labal",
|
|
172
|
-
]] as [[String : Any]])
|
|
173
|
-
) { error in
|
|
174
|
-
XCTAssertEqual(
|
|
175
|
-
error as! ApplePayUtilsError, ApplePayUtilsError.invalidCartSummaryItemType("null")
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private struct TestFixtures {
|
|
181
|
-
static let MERCHANT_ID = "merchant.com.id"
|
|
182
|
-
static let COUNTRY_CODE = "US"
|
|
183
|
-
static let DEFERRED_CART_ITEM_DICTIONARY = [
|
|
184
|
-
"paymentType":"Deferred",
|
|
185
|
-
"deferredDate": 123456789 as NSNumber,
|
|
186
|
-
"label": "deferred label",
|
|
187
|
-
"amount": "1.00"
|
|
188
|
-
] as [String : Any]
|
|
189
|
-
static let RECURRING_CART_ITEM_DICTIONARY = [
|
|
190
|
-
"paymentType":"Recurring",
|
|
191
|
-
"intervalUnit": "minute",
|
|
192
|
-
"intervalCount": 2,
|
|
193
|
-
"startDate": 123456789 as NSNumber,
|
|
194
|
-
"endDate": 234567890 as NSNumber,
|
|
195
|
-
"label": "recurring label",
|
|
196
|
-
"amount": "1.00"
|
|
197
|
-
] as [String : Any]
|
|
198
|
-
static let IMMEDIATE_CART_ITEM_DICTIONARY = [
|
|
199
|
-
"paymentType":"Immediate",
|
|
200
|
-
"isPending": true,
|
|
201
|
-
"label": "immediate label",
|
|
202
|
-
"amount": "2.00"
|
|
203
|
-
] as [String : Any]
|
|
204
|
-
static let CART_ITEM_DICTIONARY = [
|
|
205
|
-
DEFERRED_CART_ITEM_DICTIONARY, IMMEDIATE_CART_ITEM_DICTIONARY, RECURRING_CART_ITEM_DICTIONARY
|
|
206
|
-
]
|
|
207
|
-
static let IMMEDIATE_CART_ITEM_DICTIONARY_NOT_PENDING = [
|
|
208
|
-
"paymentType":"Immediate",
|
|
209
|
-
"label": "immediate label",
|
|
210
|
-
"amount": "2.00"
|
|
211
|
-
] as [String : Any]
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Tests.swift
|
|
3
|
-
// Tests
|
|
4
|
-
//
|
|
5
|
-
// Created by Charles Cruzan on 6/21/22.
|
|
6
|
-
// Copyright © 2022 Facebook. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import XCTest
|
|
10
|
-
@testable import stripe_react_native
|
|
11
|
-
|
|
12
|
-
class PushProvisioningTests: XCTestCase {
|
|
13
|
-
func testCanAddCardToWalletInTestMode() throws {
|
|
14
|
-
PushProvisioningUtils.canAddCardToWallet(last4: "4242",
|
|
15
|
-
primaryAccountIdentifier: "",
|
|
16
|
-
testEnv: true, hasPairedAppleWatch: false) { canAddCard, status in
|
|
17
|
-
XCTAssertEqual(canAddCard, true)
|
|
18
|
-
XCTAssertEqual(status, nil)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
func testCanAddCardToWalletInLiveMode() throws {
|
|
23
|
-
PushProvisioningUtils.canAddCardToWallet(last4: "4242",
|
|
24
|
-
primaryAccountIdentifier: "",
|
|
25
|
-
testEnv: false,
|
|
26
|
-
hasPairedAppleWatch: false) { canAddCard, status in
|
|
27
|
-
XCTAssertEqual(canAddCard, false)
|
|
28
|
-
XCTAssertEqual(status, PushProvisioningUtils.AddCardToWalletStatus.MISSING_CONFIGURATION)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func testCanAddPaymentPassInTestMode() throws {
|
|
33
|
-
XCTAssertEqual(
|
|
34
|
-
PushProvisioningUtils.canAddPaymentPass(primaryAccountIdentifier: "", isTestMode: true),
|
|
35
|
-
true
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
func testCanAddPaymentPassInLiveMode() throws {
|
|
40
|
-
XCTAssertEqual(
|
|
41
|
-
PushProvisioningUtils.canAddPaymentPass(primaryAccountIdentifier: "", isTestMode: false),
|
|
42
|
-
false
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
func testCheckIfPassExists() throws {
|
|
47
|
-
XCTAssertEqual(
|
|
48
|
-
PushProvisioningUtils.getPassLocation(last4: "4242"),
|
|
49
|
-
nil
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
}
|