Skip to content

Commit 88872da

Browse files
committed
Merge branch 'develop' into issue/5032-new-push-notification-payload
# Conflicts: # Experiments/Experiments/DefaultFeatureFlagService.swift
2 parents 05238bd + 320d981 commit 88872da

File tree

93 files changed

+3002
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3002
-610
lines changed

.circleci/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ parameters:
1515
default: false
1616

1717
xcode_version: &xcode_version
18-
xcode-version: "12.5.0"
18+
xcode-version: "13.0.0"
1919

2020
iphone_test_device: &iphone_test_device
21-
device: iPhone 11
22-
ios-version: "14.4"
21+
device: iPhone 13
22+
ios-version: "15.0"
2323

2424
ipad_test_device: &ipad_test_device
2525
device: iPad Air (4th generation)
26-
ios-version: "14.4"
26+
ios-version: "15.0"
2727

2828
commands:
2929
fix-image:
@@ -38,7 +38,7 @@ commands:
3838
echo "Manually added `/usr/local/bin` to the $PATH:"
3939
echo $PATH
4040
fi
41-
chruby ruby-2.6.6
41+
chruby ruby-$(cat .ruby-version)
4242
gem install bundler
4343
4444
# Add support for fetching SPM packages from GitHub

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.4
1+
2.7.4

.xcversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.5
1+
13.0

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
2121
return true
2222
case .pushNotificationsForAllStores:
2323
return true
24-
case .quickOrderPrototype:
24+
case .simplePaymentsPrototype:
2525
return buildConfig == .localDeveloper || buildConfig == .alpha
2626
case .orderListFilters:
2727
return buildConfig == .localDeveloper || buildConfig == .alpha
2828
case .filterProductsByCategory:
2929
return buildConfig == .localDeveloper || buildConfig == .alpha
30+
case .jetpackConnectionPackageSupport:
31+
return buildConfig == .localDeveloper || buildConfig == .alpha
3032
default:
3133
return true
3234
}

Experiments/Experiments/FeatureFlag.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public enum FeatureFlag: Int {
4242
///
4343
case pushNotificationsForAllStores
4444

45-
/// Allows to create quick order orders
45+
/// Allows to create simple payments orders
4646
///
47-
case quickOrderPrototype
47+
case simplePaymentsPrototype
4848

4949
/// Display the bar for displaying the filters in the Order List
5050
///
@@ -53,4 +53,8 @@ public enum FeatureFlag: Int {
5353
/// Allows to filter products by a product category, persisting it so the filter can remain after restarting the app
5454
///
5555
case filterProductsByCategory
56+
57+
/// Allows sites with plugins that include Jetpack Connection Package and without Jetpack-the-plugin to connect to the app
58+
///
59+
case jetpackConnectionPackageSupport
5660
}

Fakes/Fakes/Networking.generated.swift

Lines changed: 5 additions & 2 deletions
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
}
@@ -1457,7 +1459,8 @@ extension SystemPlugin {
14571459
url: .fake(),
14581460
authorName: .fake(),
14591461
authorUrl: .fake(),
1460-
networkActivated: .fake()
1462+
networkActivated: .fake(),
1463+
active: .fake()
14611464
)
14621465
}
14631466
}

Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ extension StripeCardReaderService: BluetoothReaderDelegate {
499499

500500
public func reader(_ reader: Reader, didFinishInstallingUpdate update: ReaderSoftwareUpdate?, error: Error?) {
501501
if let error = error {
502-
let underlyingError = UnderlyingError(with: error)
503-
if underlyingError != .commandCancelled {
504-
softwareUpdateSubject.send(.failed(error: error))
505-
}
502+
softwareUpdateSubject.send(.failed(
503+
error: CardReaderServiceError.softwareUpdate(underlyingError: UnderlyingError(with: error),
504+
batteryLevel: reader.batteryLevel?.doubleValue))
505+
)
506506
softwareUpdateSubject.send(.available)
507507
} else {
508508
softwareUpdateSubject.send(.completed)

Hardware/Hardware/Printer/AirPrintReceipt/ReceiptRenderer.swift

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import UIKit
33
/// Renders a receipt in an AirPrint enabled printer.
44
///
55
public final class ReceiptRenderer: UIPrintPageRenderer {
6-
private let lines: [ReceiptLineItem]
7-
private let parameters: CardPresentReceiptParameters
8-
private let cartTotals: [ReceiptTotalLine]
6+
private let content: ReceiptContent
97

108
private let dateFormatter: DateFormatter = {
119
let formatter = DateFormatter()
@@ -17,9 +15,7 @@ public final class ReceiptRenderer: UIPrintPageRenderer {
1715
}()
1816

1917
public init(content: ReceiptContent) {
20-
self.lines = content.lineItems
21-
self.parameters = content.parameters
22-
self.cartTotals = content.cartTotals
18+
self.content = content
2319

2420
super.init()
2521

@@ -49,7 +45,7 @@ public extension ReceiptRenderer {
4945
background-color:#F5F5F5;
5046
width:100%;
5147
color: #707070;
52-
margin: \(Constants.margin / 2)pt 0 0 0;
48+
margin: \(Constants.margin / 2)pt 0;
5349
padding: \(Constants.margin / 2)pt;
5450
}
5551
table td:last-child { width: 30%; text-align: right; }
@@ -77,19 +73,20 @@ public extension ReceiptRenderer {
7773
<h1>\(receiptTitle)</h1>
7874
<h3>\(Localization.amountPaidSectionTitle.uppercased())</h3>
7975
<p>
80-
\(parameters.formattedAmount) \(parameters.currency.uppercased())
76+
\(content.parameters.formattedAmount) \(content.parameters.currency.uppercased())
8177
</p>
8278
<h3>\(Localization.datePaidSectionTitle.uppercased())</h3>
8379
<p>
84-
\(dateFormatter.string(from: parameters.date))
80+
\(dateFormatter.string(from: content.parameters.date))
8581
</p>
8682
<h3>\(Localization.paymentMethodSectionTitle.uppercased())</h3>
8783
<p>
88-
<span class="card-icon \(parameters.cardDetails.brand.iconName)-icon"></span> - \(parameters.cardDetails.last4)
84+
<span class="card-icon \(content.parameters.cardDetails.brand.iconName)-icon"></span> - \(content.parameters.cardDetails.last4)
8985
</p>
9086
</header>
9187
<h3>\(summarySectionTitle.uppercased())</h3>
9288
\(summaryTable())
89+
\(orderNoteSection())
9390
<footer>
9491
<p>
9592
\(requiredItems())
@@ -112,8 +109,8 @@ private extension ReceiptRenderer {
112109

113110
private func summaryTable() -> String {
114111
var summaryContent = "<table>"
115-
for line in lines {
116-
summaryContent += "<tr><td>\(line.title) × \(line.quantity)</td><td>\(line.amount) \(parameters.currency.uppercased())</td></tr>"
112+
for line in content.lineItems {
113+
summaryContent += "<tr><td>\(line.title) × \(line.quantity)</td><td>\(line.amount) \(content.parameters.currency.uppercased())</td></tr>"
117114
}
118115
summaryContent += totalRows()
119116
summaryContent += "</table>"
@@ -123,7 +120,7 @@ private extension ReceiptRenderer {
123120

124121
private func totalRows() -> String {
125122
var rows = ""
126-
for total in cartTotals {
123+
for total in content.cartTotals {
127124
rows += summaryRow(title: total.description, amount: total.amount)
128125
}
129126
return rows
@@ -136,14 +133,24 @@ private extension ReceiptRenderer {
136133
\(title)
137134
</td>
138135
<td>
139-
\(amount) \(parameters.currency.uppercased())
136+
\(amount) \(content.parameters.currency.uppercased())
140137
</td>
141138
</tr>
142139
"""
143140
}
144141

142+
private func orderNoteSection() -> String {
143+
guard let orderNote = content.orderNote else {
144+
return ""
145+
}
146+
return """
147+
<h3>\(Localization.orderNoteSectionTitle.uppercased())</h3>
148+
<p>\(orderNote)</p>
149+
"""
150+
}
151+
145152
private func requiredItems() -> String {
146-
guard let emv = parameters.cardDetails.receipt else {
153+
guard let emv = content.parameters.cardDetails.receipt else {
147154
return "<br/>"
148155
}
149156

@@ -163,15 +170,15 @@ private extension ReceiptRenderer {
163170
}
164171

165172
private var receiptTitle: String {
166-
guard let storeName = parameters.storeName else {
173+
guard let storeName = content.parameters.storeName else {
167174
return Localization.receiptTitle
168175
}
169176

170177
return .localizedStringWithFormat(Localization.receiptFromFormat, storeName)
171178
}
172179

173180
private var summarySectionTitle: String {
174-
guard let orderID = parameters.orderID else {
181+
guard let orderID = content.parameters.orderID else {
175182
return Localization.summarySectionTitle
176183
}
177184
return String(format: Localization.summarySectionTitleWithOrderFormat, String(orderID))
@@ -218,6 +225,10 @@ private extension ReceiptRenderer {
218225
comment: "Title of 'Summary' section in the receipt when the order number is unknown"
219226
)
220227

228+
static let orderNoteSectionTitle = NSLocalizedString(
229+
"Notes",
230+
comment: "Title of order note section in the receipt, commonly used for Quick Orders.")
231+
221232
static let summarySectionTitleWithOrderFormat = NSLocalizedString(
222233
"Summary: Order #%1$@",
223234
comment: "Title of 'Summary' section in the receipt. %1$@ is the order number, e.g. 4920"

Hardware/Hardware/Printer/ReceiptContent.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ public struct ReceiptContent: Codable {
44
public let lineItems: [ReceiptLineItem]
55
public let parameters: CardPresentReceiptParameters
66
public let cartTotals: [ReceiptTotalLine]
7+
public let orderNote: String?
78

8-
public init(parameters: CardPresentReceiptParameters, lineItems: [ReceiptLineItem], cartTotals: [ReceiptTotalLine]) {
9+
public init(parameters: CardPresentReceiptParameters,
10+
lineItems: [ReceiptLineItem],
11+
cartTotals: [ReceiptTotalLine],
12+
orderNote: String?) {
913
self.lineItems = lineItems
1014
self.parameters = parameters
1115
self.cartTotals = cartTotals
16+
self.orderNote = orderNote
1217
}
1318
}
1419

@@ -17,6 +22,7 @@ extension ReceiptContent {
1722
case lineItems = "line_items"
1823
case parameters = "parameters"
1924
case cartTotals = "cart_totals"
25+
case orderNote = "order_note"
2026
}
2127
}
2228

Networking/Networking/Mapper/SystemStatusMapper.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ struct SystemStatusMapper: Mapper {
1919

2020
let systemStatus = try decoder.decode(SystemStatusEnvelope.self, from: response).systemStatus
2121

22-
/// For now, we're going to override the networkActivated Bool in each plugin to convey active or inactive -- in order to
23-
/// avoid a core data change to add a Bool for activated
24-
/// This will be undone in #5269
22+
/// Active and in-active plugins share identical structure, but are stored in separate parts of the remote response
23+
/// (and without an active attribute in the response). So... we use the same decoder for active and in-active plugins
24+
/// and here we apply the correct value for active (or not)
25+
///
2526
let activePlugins = systemStatus.activePlugins.map {
26-
$0.overrideNetworkActivated(isNetworkActivated: true)
27+
$0.copy(active: true)
2728
}
29+
2830
let inactivePlugins = systemStatus.inactivePlugins.map {
29-
$0.overrideNetworkActivated(isNetworkActivated: false)
31+
$0.copy(active: false)
3032
}
3133

3234
return activePlugins + inactivePlugins

0 commit comments

Comments
 (0)