Skip to content

Commit

Permalink
Fixed SK2 promo purchases
Browse files Browse the repository at this point in the history
Fixes [SDKONCALL-160].
  • Loading branch information
NachoSoto committed Dec 9, 2022
1 parent 78fabc4 commit 09c1d91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Sources/Purchasing/StoreKitAbstractions/PromotionalOffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,20 @@ extension PromotionalOffer.SignedData {

@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
var sk2PurchaseOption: Product.PurchaseOption {
let signature: Data

if let decoded = Data(base64Encoded: self.signature) {
signature = decoded
} else {
// TODO: log warning
signature = .init()
}

return .promotionalOffer(
offerID: self.identifier,
keyID: self.keyIdentifier,
nonce: self.nonce,
signature: self.signature.asData,
signature: signature,
timestamp: self.timestamp
)
}
Expand Down
2 changes: 0 additions & 2 deletions Tests/BackendIntegrationTests/StoreKitIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@ class StoreKit1IntegrationTests: BaseBackendIntegrationTests {
@available(iOS 15.2, tvOS 15.2, macOS 12.1, watchOS 8.3, *)
func testPurchaseWithPromotionalOffer() async throws {
try AvailabilityChecks.iOS15APIAvailableOrSkipTest()
try XCTSkipIf(Self.storeKit2Setting == .enabledForCompatibleDevices,
"This test is not currently passing on SK2")

let user = UUID().uuidString

Expand Down

0 comments on commit 09c1d91

Please sign in to comment.