Skip to content

Commit 47a845c

Browse files
committed
Merge branch 'trunk' into issue/6018-fields-alignment-in-address-form
2 parents 889967e + b882be2 commit 47a845c

File tree

124 files changed

+5178
-2253
lines changed

Some content is hidden

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

124 files changed

+5178
-2253
lines changed

Hardware/Hardware.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
55CD4BB4273E617C007686D3 /* ReceiptRendererTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55CD4BB3273E617C007686D3 /* ReceiptRendererTest.swift */; };
2222
5A747BE9FA06EC8752A35752 /* Pods_HardwareTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B1DC5B6141B8184FAC29B0A4 /* Pods_HardwareTests.framework */; };
2323
8FFAA245E257B9EB98E2FCBD /* Pods_SampleReceiptPrinter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2AFA997D6786C67B0A061854 /* Pods_SampleReceiptPrinter.framework */; };
24+
B9C4AB2327FDE133007008B8 /* Email.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9C4AB2227FDE133007008B8 /* Email.swift */; };
2425
C5D2CB7D21CEE28FEBF18BF6 /* Pods_Hardware.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9F0AC202B287C1221EA2C99 /* Pods_Hardware.framework */; platformFilter = ios; };
2526
D80409A625FBE42B006F9BDA /* PaymentIntentParameters+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80409A525FBE42B006F9BDA /* PaymentIntentParameters+Stripe.swift */; };
2627
D80B4652260E19590092EDC0 /* PaymentIntentParametersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80B4651260E19590092EDC0 /* PaymentIntentParametersTests.swift */; };
@@ -156,6 +157,7 @@
156157
9726331F55A9621F2F887E13 /* Pods-Hardware.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Hardware.release.xcconfig"; path = "Target Support Files/Pods-Hardware/Pods-Hardware.release.xcconfig"; sourceTree = "<group>"; };
157158
AE60F16D43C20AD4523A61A5 /* Pods-SampleReceiptPrinter.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleReceiptPrinter.debug.xcconfig"; path = "Target Support Files/Pods-SampleReceiptPrinter/Pods-SampleReceiptPrinter.debug.xcconfig"; sourceTree = "<group>"; };
158159
B1DC5B6141B8184FAC29B0A4 /* Pods_HardwareTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HardwareTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
160+
B9C4AB2227FDE133007008B8 /* Email.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Email.swift; sourceTree = "<group>"; };
159161
C61D1642BE09D1A1AD6AA9FA /* Pods-HardwareTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HardwareTests.release.xcconfig"; path = "Target Support Files/Pods-HardwareTests/Pods-HardwareTests.release.xcconfig"; sourceTree = "<group>"; };
160162
C810BBAD03E7D4ECFD29D7AC /* Pods-SampleReceiptPrinter.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SampleReceiptPrinter.release-alpha.xcconfig"; path = "Target Support Files/Pods-SampleReceiptPrinter/Pods-SampleReceiptPrinter.release-alpha.xcconfig"; sourceTree = "<group>"; };
161163
D80409A525FBE42B006F9BDA /* PaymentIntentParameters+Stripe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PaymentIntentParameters+Stripe.swift"; sourceTree = "<group>"; };
@@ -426,6 +428,7 @@
426428
D845BDC1262D98C400A3E40F /* CardBrand.swift */,
427429
D845BDD9262DAADB00A3E40F /* PaymentMethod.swift */,
428430
317975BF274EB1F9004357B1 /* DeclineReason.swift */,
431+
B9C4AB2227FDE133007008B8 /* Email.swift */,
429432
);
430433
path = CardReader;
431434
sourceTree = "<group>";
@@ -768,6 +771,7 @@
768771
isa = PBXSourcesBuildPhase;
769772
buildActionMask = 2147483647;
770773
files = (
774+
B9C4AB2327FDE133007008B8 /* Email.swift in Sources */,
771775
D845BE59262ED84000A3E40F /* AirPrintReceiptPrinterService.swift in Sources */,
772776
317975C2274EBC1F004357B1 /* DeclineReason+Stripe.swift in Sources */,
773777
D845BDB8262D97B300A3E40F /* ReceiptDetails.swift in Sources */,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// A property wrapper to validate that a property is a valid email
2+
/// Property Wrappers can not throw, so
3+
/// what this wrapper does is return a nil when trying to set an invalid
4+
/// email address as a value of a property of type String.
5+
/// The reason to do this is add an extra layer of validation before passing
6+
/// an instance of PaymentIntentParameters to the Stripe Terminal SDK
7+
/// https://emailregex.com
8+
@propertyWrapper
9+
public struct Email<Value: StringProtocol> {
10+
var value: Value?
11+
12+
public init(wrappedValue value: Value?) {
13+
self.value = value
14+
}
15+
16+
public var wrappedValue: Value? {
17+
get {
18+
return validate(email: value) ? value : nil
19+
}
20+
set {
21+
value = newValue
22+
}
23+
}
24+
private func validate(email: Value?) -> Bool {
25+
guard let email = email else { return false }
26+
// https://emailregex.com
27+
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
28+
let emailPred = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
29+
return emailPred.evaluate(with: email)
30+
}
31+
}

Hardware/Hardware/CardReader/PaymentIntentParameters.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public struct PaymentIntentParameters {
2424
@StatementDescriptor
2525
public private(set) var statementDescription: String?
2626

27+
/// Email address that the receipt for the resulting payment will be sent to.
28+
@Email
29+
public private(set) var receiptEmail: String?
30+
2731
/// Set of key-value pairs that you can attach to an object.
2832
/// This can be useful for storing additional information about the object in a structured format.
2933
public let metadata: [AnyHashable: Any]?
@@ -38,12 +42,14 @@ public struct PaymentIntentParameters {
3842
currency: String,
3943
receiptDescription: String? = nil,
4044
statementDescription: String? = nil,
45+
receiptEmail: String? = nil,
4146
paymentMethodTypes: [String] = [],
4247
metadata: [AnyHashable: Any]? = nil) {
4348
self.amount = amount
4449
self.currency = currency
4550
self.receiptDescription = receiptDescription
4651
self.statementDescription = statementDescription
52+
self.receiptEmail = receiptEmail
4753
self.paymentMethodTypes = paymentMethodTypes
4854
self.metadata = metadata
4955
}

Hardware/Hardware/CardReader/StripeCardReader/PaymentIntentParameters+Stripe.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extension Hardware.PaymentIntentParameters {
3232
returnValue.statementDescriptor = descriptor
3333
}
3434

35+
returnValue.receiptEmail = receiptEmail
3536
returnValue.metadata = metadata
3637

3738
return returnValue

Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,7 @@ private extension StripeCardReaderService {
481481
// MARK: - Refunds
482482
extension StripeCardReaderService {
483483
public func refundPayment(parameters: RefundParameters) -> AnyPublisher<String, Error> {
484-
if isChipCardInserted {
485-
sendReaderEvent(CardReaderEvent.make(displayMessage: .removeCard))
486-
}
487-
return waitForInsertedCardToBeRemoved()
488-
.flatMap {
489-
self.createRefundParameters(parameters: parameters)
490-
}
484+
return createRefundParameters(parameters: parameters)
491485
.flatMap { refundParameters in
492486
self.refund(refundParameters)
493487
}
@@ -563,7 +557,7 @@ extension StripeCardReaderService {
563557
}
564558
promise(.success(()))
565559
})
566-
//TODO: handle timeout?
560+
//TODO: 5983 - handle timeout when called from retry after refund failure
567561
}.eraseToAnyPublisher()
568562
}
569563
}

Hardware/HardwareTests/PaymentIntentParametersTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import XCTest
22
@testable import Hardware
33

44
final class PaymentIntentParametersTests: XCTestCase {
5+
func test_validEmail_is_saved() {
6+
let params = PaymentIntentParameters(amount: 100, currency: "usd", receiptEmail: "[email protected]", paymentMethodTypes: ["card_present"])
7+
8+
XCTAssertNotNil(params.receiptEmail)
9+
}
10+
11+
func test_not_validEmail_is_ignored() {
12+
let params = PaymentIntentParameters(amount: 100, currency: "usd", receiptEmail: "woocommerce", paymentMethodTypes: ["card_present"])
13+
14+
XCTAssertNil(params.receiptEmail)
15+
}
16+
517
func test_currency_is_lowercased() {
618
let params = PaymentIntentParameters(amount: 100, currency: "USD", paymentMethodTypes: ["card_present"])
719

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
2665032E261F4FBF0079A159 /* ProductAddOnOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2665032D261F4FBF0079A159 /* ProductAddOnOption.swift */; };
143143
26650332261FFA1A0079A159 /* ProductAddOnEnvelope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26650331261FFA1A0079A159 /* ProductAddOnEnvelope.swift */; };
144144
266C7F9225AD3C88006ED243 /* attribute-term.json in Resources */ = {isa = PBXBuildFile; fileRef = 266C7F9125AD3C87006ED243 /* attribute-term.json */; };
145-
267066092774BF3B008E1F68 /* settings-advanced.json in Resources */ = {isa = PBXBuildFile; fileRef = 267066082774BF3B008E1F68 /* settings-advanced.json */; };
146145
2670C3FC270F4E06002FE931 /* SiteListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2670C3FB270F4E06002FE931 /* SiteListMapperTests.swift */; };
147146
2670C3FE270F4E6A002FE931 /* sites-malformed.json in Resources */ = {isa = PBXBuildFile; fileRef = 2670C3FD270F4E6A002FE931 /* sites-malformed.json */; };
148147
267313312559CC930026F7EF /* PaymentGateway.swift in Sources */ = {isa = PBXBuildFile; fileRef = 267313302559CC930026F7EF /* PaymentGateway.swift */; };
@@ -812,7 +811,6 @@
812811
2665032D261F4FBF0079A159 /* ProductAddOnOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductAddOnOption.swift; sourceTree = "<group>"; };
813812
26650331261FFA1A0079A159 /* ProductAddOnEnvelope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductAddOnEnvelope.swift; sourceTree = "<group>"; };
814813
266C7F9125AD3C87006ED243 /* attribute-term.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "attribute-term.json"; sourceTree = "<group>"; };
815-
267066082774BF3B008E1F68 /* settings-advanced.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "settings-advanced.json"; sourceTree = "<group>"; };
816814
2670C3FB270F4E06002FE931 /* SiteListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteListMapperTests.swift; sourceTree = "<group>"; };
817815
2670C3FD270F4E6A002FE931 /* sites-malformed.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "sites-malformed.json"; sourceTree = "<group>"; };
818816
267313302559CC930026F7EF /* PaymentGateway.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentGateway.swift; sourceTree = "<group>"; };
@@ -1942,7 +1940,6 @@
19421940
D88D5A40230BC5DA007B6E01 /* reviews-all.json */,
19431941
57BE08D72409B63700F6DCED /* reviews-missing-avatar-urls.json */,
19441942
D88D5A42230BC668007B6E01 /* reviews-single.json */,
1945-
267066082774BF3B008E1F68 /* settings-advanced.json */,
19461943
DE74F29B27E0A1D00002FE59 /* setting-coupon.json */,
19471944
DE74F29F27E3137F0002FE59 /* setting-analytics.json */,
19481945
74046E20217A73D0007DD7BF /* settings-general.json */,
@@ -2519,7 +2516,6 @@
25192516
CC0786C7267BB10700BA9AC1 /* shipping-label-status-success.json in Resources */,
25202517
D88D5A41230BC5DA007B6E01 /* reviews-all.json in Resources */,
25212518
74C947862193A6C70024CB60 /* comment-moderate-unapproved.json in Resources */,
2522-
267066092774BF3B008E1F68 /* settings-advanced.json in Resources */,
25232519
3105472C262E303400C5C02B /* wcpay-payment-intent-unknown-status.json in Resources */,
25242520
B559EBAA20A0B5CD00836CD4 /* orders-load-all.json in Resources */,
25252521
3158A4A12729F40F00C3CFA8 /* wcpay-account-live-test.json in Resources */,

Networking/Networking/Remote/OrdersRemote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public extension OrdersRemote {
294294
private static let commonOrderFieldValues = [
295295
"id", "parent_id", "number", "status", "currency", "customer_id", "customer_note", "date_created_gmt", "date_modified_gmt", "date_paid_gmt",
296296
"discount_total", "discount_tax", "shipping_total", "shipping_tax", "total", "total_tax", "payment_method", "payment_method_title",
297-
"billing", "coupon_lines", "shipping_lines", "refunds", "fee_lines", "order_key", "tax_lines", "meta_data"
297+
"payment_url", "billing", "coupon_lines", "shipping_lines", "refunds", "fee_lines", "order_key", "tax_lines", "meta_data"
298298
]
299299
// Use with caution. Any fields in here will be overwritten with empty values by
300300
// `Order+ReadOnlyConvertible.swift: Order.update(with:)` when the list of orders is fetched.

Networking/Networking/Remote/SiteSettingsRemote.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ public class SiteSettingsRemote: Remote {
3333
enqueue(request, mapper: mapper, completion: completion)
3434
}
3535

36-
/// Retrieves all of the advanced `SiteSetting`s for a given site.
37-
///
38-
/// - Parameters:
39-
/// - siteID: Site for which we'll fetch the advanced settings.
40-
/// - completion: Closure to be executed upon completion.
41-
///
42-
public func loadAdvancedSettings(for siteID: Int64, completion: @escaping (Result<[SiteSetting], Error>) -> Void) {
43-
let path = Constants.siteSettingsPath + Constants.advancedSettingsGroup
44-
let request = JetpackRequest(wooApiVersion: .mark3, method: .get, siteID: siteID, path: path, parameters: nil)
45-
let mapper = SiteSettingsMapper(siteID: siteID, settingsGroup: SiteSettingGroup.advanced)
46-
47-
enqueue(request, mapper: mapper, completion: completion)
48-
}
49-
5036
/// Retrieve detail for a single setting for a given site
5137
///
5238
/// - Parameters:

Networking/NetworkingTests/Remote/SiteSettingsRemoteTests.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,6 @@ final class SiteSettingsRemoteTests: XCTestCase {
8787
wait(for: [expectation], timeout: Constants.expectationTimeout)
8888
}
8989

90-
// MARK: - Load advanced settings tests
91-
92-
func test_load_advanced_settings_properly_returns_parsed_settings() throws {
93-
// Given
94-
network.simulateResponse(requestUrlSuffix: "settings/advanced", filename: "settings-advanced")
95-
let remote = SiteSettingsRemote(network: network)
96-
97-
// When
98-
let result: Result<[Networking.SiteSetting], Error> = waitFor { promise in
99-
remote.loadAdvancedSettings(for: self.sampleSiteID) { result in
100-
promise(result)
101-
}
102-
}
103-
104-
// Then
105-
let settings = try result.get()
106-
XCTAssertEqual(settings.count, 2)
107-
}
108-
10990
// MARK: - Load single setting tests
11091
func test_loadSetting_properly_returns_parsed_settings() throws {
11192
// Given

0 commit comments

Comments
 (0)