Skip to content

Commit

Permalink
[SK2] send unsynced attributes when syncing purchases (#4245)
Browse files Browse the repository at this point in the history
<!-- Thank you for contributing to Purchases! Before pressing the
"Create Pull Request" button, please provide the following: -->

### Checklist
- [x] If applicable, unit tests
- [ ] If applicable, create follow-up issues for `purchases-android` and
hybrids

### Motivation
When calling syncPurchases with StoreKit 2, we aren't including any
unsynced subscriber attributes.

### Description
This PR modifies the StoreKit 2 syncPurchases network request to include
unsynced subscriber attributes, the storefront, and a nil
`presentedOfferingContext`.

---------

Co-authored-by: Will Taylor <wtaylor151@gmail.com>
  • Loading branch information
2 people authored and nyeu committed Oct 1, 2024
1 parent 45229b5 commit 7cf799f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Sources/Purchasing/Purchases/PurchasesOrchestrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1139,11 +1139,19 @@ private extension PurchasesOrchestrator {
return
}

let transactionData: PurchasedTransactionData = .init(
appUserID: currentAppUserID,
presentedOfferingContext: nil,
unsyncedAttributes: unsyncedAttributes,
source: .init(
isRestore: isRestore,
initiationSource: initiationSource
)
)

self.backend.post(receipt: .empty,
productData: nil,
transactionData: .init(appUserID: currentAppUserID,
source: .init(isRestore: isRestore,
initiationSource: initiationSource)),
transactionData: transactionData,
observerMode: self.observerMode,
appTransaction: appTransactionJWS) { result in

Expand Down
2 changes: 2 additions & 0 deletions Tests/StoreKitUnitTests/PurchasesOrchestratorSK2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ class PurchasesOrchestratorSK2Tests: BasePurchasesOrchestratorTests, PurchasesOr

expect(self.backend.invokedPostReceiptData).to(beTrue())
expect(self.backend.invokedPostReceiptDataParameters?.data) == .jws(transaction.jwsRepresentation!)
expect(self.backend.invokedPostReceiptDataParameters?.transactionData.unsyncedAttributes).toNot(beNil())
expect(self.backend.invokedPostReceiptDataParameters?.transactionData.presentedOfferingContext).to(beNil())
expect(customerInfo) == mockCustomerInfo
}

Expand Down

0 comments on commit 7cf799f

Please sign in to comment.