Skip to content

Commit 06c8162

Browse files
committed
Add isLive, isInTestMode to PaymentGatewayAccount model; rake generate
1 parent 737aacf commit 06c8162

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ extension PaymentGatewayAccount {
489489
defaultCurrency: .fake(),
490490
supportedCurrencies: .fake(),
491491
country: .fake(),
492-
isCardPresentEligible: .fake()
492+
isCardPresentEligible: .fake(),
493+
isLive: .fake(),
494+
isInTestMode: .fake()
493495
)
494496
}
495497
}

Networking/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ extension PaymentGatewayAccount {
286286
defaultCurrency: CopiableProp<String> = .copy,
287287
supportedCurrencies: CopiableProp<[String]> = .copy,
288288
country: CopiableProp<String> = .copy,
289-
isCardPresentEligible: CopiableProp<Bool> = .copy
289+
isCardPresentEligible: CopiableProp<Bool> = .copy,
290+
isLive: CopiableProp<Bool> = .copy,
291+
isInTestMode: CopiableProp<Bool> = .copy
290292
) -> PaymentGatewayAccount {
291293
let siteID = siteID ?? self.siteID
292294
let gatewayID = gatewayID ?? self.gatewayID
@@ -299,6 +301,8 @@ extension PaymentGatewayAccount {
299301
let supportedCurrencies = supportedCurrencies ?? self.supportedCurrencies
300302
let country = country ?? self.country
301303
let isCardPresentEligible = isCardPresentEligible ?? self.isCardPresentEligible
304+
let isLive = isLive ?? self.isLive
305+
let isInTestMode = isInTestMode ?? self.isInTestMode
302306

303307
return PaymentGatewayAccount(
304308
siteID: siteID,
@@ -311,7 +315,9 @@ extension PaymentGatewayAccount {
311315
defaultCurrency: defaultCurrency,
312316
supportedCurrencies: supportedCurrencies,
313317
country: country,
314-
isCardPresentEligible: isCardPresentEligible
318+
isCardPresentEligible: isCardPresentEligible,
319+
isLive: isLive,
320+
isInTestMode: isInTestMode
315321
)
316322
}
317323
}

Networking/Networking/Model/PaymentGatewayAccount.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ public struct PaymentGatewayAccount: GeneratedCopiable, GeneratedFakeable {
3030
/// A boolean flag indicating if this Account is eligible for card present payments
3131
public let isCardPresentEligible: Bool
3232

33+
/// Indicates if the account is live (i.e. can accept actual payments)
34+
public let isLive: Bool
35+
36+
/// Indicates if the gateway is set for test mode. This is NOT the same as
37+
/// whether the account is live or not. You can have a live account set for
38+
/// test mode, although we cannot accept in-person payments in that situation.
39+
public let isInTestMode: Bool
40+
3341
/// Struct initializer
3442
///
3543
public init(siteID: Int64,
@@ -42,7 +50,9 @@ public struct PaymentGatewayAccount: GeneratedCopiable, GeneratedFakeable {
4250
defaultCurrency: String,
4351
supportedCurrencies: [String],
4452
country: String,
45-
isCardPresentEligible: Bool
53+
isCardPresentEligible: Bool,
54+
isLive: Bool,
55+
isInTestMode: Bool
4656
) {
4757
self.siteID = siteID
4858
self.gatewayID = gatewayID
@@ -55,5 +65,7 @@ public struct PaymentGatewayAccount: GeneratedCopiable, GeneratedFakeable {
5565
self.supportedCurrencies = supportedCurrencies
5666
self.country = country
5767
self.isCardPresentEligible = isCardPresentEligible
68+
self.isLive = isLive
69+
self.isInTestMode = isInTestMode
5870
}
5971
}

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
223223
}
224224

225225
func isWCPayInTestModeWithLiveStripeAccount(account: PaymentGatewayAccount) -> Bool {
226-
// TODO: not implemented yet
227-
return false
226+
account.isLive && account.isInTestMode
228227
}
229228

230229
func isStripeAccountUnderReview(account: PaymentGatewayAccount) -> Bool {

Yosemite/Yosemite/Model/Payments/WCPayAccount+PaymentGatewayAccount.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public extension WCPayAccount {
1515
defaultCurrency: defaultCurrency,
1616
supportedCurrencies: supportedCurrencies,
1717
country: country,
18-
isCardPresentEligible: isCardPresentEligible
18+
isCardPresentEligible: isCardPresentEligible,
19+
isLive: isLiveAccount,
20+
isInTestMode: isInTestMode
1921
)
2022
}
2123
}

Yosemite/Yosemite/Model/Storage/PaymentGatewayAccount+ReadOnlyConvertible.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ extension Storage.PaymentGatewayAccount: ReadOnlyConvertible {
3636
defaultCurrency: defaultCurrency,
3737
supportedCurrencies: supportedCurrencies,
3838
country: country,
39-
isCardPresentEligible: isCardPresentEligible)
39+
isCardPresentEligible: isCardPresentEligible,
40+
isLive: isLive,
41+
isInTestMode: isInTestMode)
4042
}
4143
}

0 commit comments

Comments
 (0)