Skip to content

Commit

Permalink
Merge pull request #25 from cashapp/release-0.6.1
Browse files Browse the repository at this point in the history
Release 0.6.1
  • Loading branch information
mmroz authored May 14, 2024
2 parents b2ff27d + f899fff commit 8e9b575
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 42 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Select Xcode Version (14.2.0)
run: sudo xcode-select --switch /Applications/Xcode_14.2.0.app/Contents/Developer
- name: Select Xcode Version (15.1.0)
run: sudo xcode-select --switch /Applications/Xcode_15.1.0.app/Contents/Developer
- name: Build
run: swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios14.0-simulator"
run: xcodebuild build -scheme PayKit -sdk "`xcrun --sdk iphonesimulator --show-sdk-path`"
2 changes: 1 addition & 1 deletion CashAppPayKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CashAppPayKit'
s.version = '0.6.0'
s.version = '0.6.1'
s.summary = 'PayKit iOS SDK'
s.homepage = 'https://github.com/cashapp/cash-app-pay-ios-sdk'
s.license = 'Apache License, Version 2.0'
Expand Down
2 changes: 1 addition & 1 deletion CashAppPayKitUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CashAppPayKitUI'
s.version = "0.6.0"
s.version = "0.6.1"
s.summary = 'UI components for the PayKit iOS SDK'
s.homepage = 'https://github.com/cashapp/cash-app-pay-ios-sdk'
s.license = 'Apache License, Version 2.0'
Expand Down
10 changes: 10 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## PayKit 0.6.1 Release Notes

Pay Kit 0.6.1 supports iOS and requires Xcode 11 or later. The minimum supported Base SDK is 12.0.

Pay Kit 0.6.1 includes the following new features and enhancements.

- **Objective-C Improvements**

Fixed a crash in the Objective-C wrapper where calls to `retrieveCustomerRequest` would crash if an error was encountered.

## PayKit 0.6.0 Release Notes

Pay Kit 0.6.0 supports iOS and requires Xcode 11 or later. The minimum supported Base SDK is 12.0.
Expand Down
2 changes: 1 addition & 1 deletion Sources/PayKit/CashAppPay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import UIKit

public class CashAppPay {

public static let version = "0.6.0"
public static let version = "0.6.1"

public static let RedirectNotification: Notification.Name = Notification.Name("CashAppPayRedirect")

Expand Down
36 changes: 33 additions & 3 deletions Sources/PayKit/ObjcWrapper/Errors+ObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import Foundation

// MARK: - APIError

public let CAPErrorDomain = "com.squareup.cashapppay.error"

@objcMembers public final class CAPApiError: NSError {

// MARK: - Properties
Expand Down Expand Up @@ -115,7 +117,7 @@ extension APIError.ErrorCode {

init(integrationError: IntegrationError) {
self.integrationError = integrationError
super.init()
super.init(domain: CAPErrorDomain, code: 1)
}

@available(*, unavailable)
Expand Down Expand Up @@ -258,7 +260,7 @@ extension IntegrationError.ErrorCode {

init(unexpectedError: UnexpectedError) {
self.unexpectedError = unexpectedError
super.init()
super.init(domain: CAPErrorDomain, code: 1)
}

@available(*, unavailable)
Expand All @@ -276,7 +278,7 @@ extension IntegrationError.ErrorCode {

init(response: HTTPURLResponse) {
self.response = response
super.init(domain: "Missing response body", code: NSURLErrorCannotParseResponse)
super.init(domain: CAPErrorDomain, code: NSURLErrorCannotParseResponse)
}

@available(*, unavailable)
Expand All @@ -298,3 +300,31 @@ extension IntegrationError.ErrorCode {
fatalError("init(coder:) has not been implemented")
}
}

// MARK: - Error Extensions

extension Error {
var cashAppPayObjCError: NSError? {
switch self {
case let apiError as APIError:
return CAPApiError(apiError: apiError)
case let integrationError as IntegrationError:
return CAPIntegrationError(integrationError: integrationError)
case let unexpectedError as UnexpectedError:
return CAPUnexpectedError(unexpectedError: unexpectedError)
case let networkError as NetworkError:
switch networkError {
case .noResponse:
return CAPNetworkErrorNoResponse()
case .nilData(let response):
return CAPNetworkErrorNilData(response: response)
case .invalidJSON(let json):
return CAPNetworkErrorInvalidJSON(data: json)
case .systemError(let error):
return error
}
default:
return nil
}
}
}
36 changes: 3 additions & 33 deletions Sources/PayKit/ObjcWrapper/ObjCWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ public final class ObjCWrapper: NSObject {

@objc public func retrieveCustomerRequest(
id: String,
completion: @escaping (CAPCustomerRequest?, Error?) -> Void
completion: @escaping (CAPCustomerRequest?, NSError?) -> Void
) {
cashAppPay.retrieveCustomerRequest(id: id) { [weak self] result in
guard let self else { return }
cashAppPay.retrieveCustomerRequest(id: id) { result in
switch result {
case .success(let customerRequest):
let capCustomerRequest = CAPCustomerRequest(customerRequest: customerRequest)
completion(capCustomerRequest, nil)
case .failure(let error):
let objcError = self.mapErrorToObjC(error)
completion(nil, objcError)
completion(nil, error.cashAppPayObjCError)
}
}
}
Expand Down Expand Up @@ -91,34 +89,6 @@ public final class ObjCWrapper: NSObject {
}
}

// MARK: - Errors

extension ObjCWrapper {
func mapErrorToObjC(_ error: Error) -> Error {
switch error {
case let apiError as APIError:
return CAPApiError(apiError: apiError)
case let integrationError as IntegrationError:
return CAPIntegrationError(integrationError: integrationError)
case let unexpectedError as UnexpectedError:
return CAPUnexpectedError(unexpectedError: unexpectedError)
case let networkError as NetworkError:
switch networkError {
case .noResponse:
return CAPNetworkErrorNoResponse()
case .nilData(let response):
return CAPNetworkErrorNilData(response: response)
case .invalidJSON(let json):
return CAPNetworkErrorInvalidJSON(data: json)
case .systemError(let error):
return error
}
default:
return error
}
}
}

// MARK: - Observations

extension ObjCWrapper {
Expand Down

0 comments on commit 8e9b575

Please sign in to comment.