Skip to content

Exposed PurchasesReceiptParser and AppleReceipt#2153

Merged
NachoSoto merged 1 commit into
mainfrom
receipt-parser-public
Dec 22, 2022
Merged

Exposed PurchasesReceiptParser and AppleReceipt#2153
NachoSoto merged 1 commit into
mainfrom
receipt-parser-public

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Dec 14, 2022

Copy link
Copy Markdown
Contributor

Initial step for CSDK-17. Fixes CSDK-523.

Changes:

  • Renamed ReceiptParser to PurchasesReceiptParser to avoid name collision with future SPM ReceiptParser
  • Exposed ReceiptParser, AppleReceipt, PurchasesReceiptParser.Error
  • Added new types to SwiftAPITester
  • Added docs to these types
  • Moved LoggerType to be available to ReceiptParser
  • Moved DateFormatter+Extensions to be available to ReceiptParser
  • Moved Codable+Extensions to be available to ReceiptParser
  • Created ReceiptParserLogger for ReceiptParser

@NachoSoto NachoSoto added the pr:feat A new feature label Dec 14, 2022
@NachoSoto NachoSoto requested a review from a team December 14, 2022 21:08
@NachoSoto NachoSoto force-pushed the receipt-parser-public branch 3 times, most recently from a9ae4cd to d356639 Compare December 14, 2022 21:46

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't do this on purpose, I created a new file with the same contents.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't do this on purpose, I created a new file with the same contents.

@NachoSoto NachoSoto force-pushed the receipt-parser-public branch 2 times, most recently from 0ff0269 to 1b9e77a Compare December 20, 2022 18:08

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good but I will hold off approval until #2155 is also ready, to avoid adding new APIs and removing them later.


var prettyPrintedData: Data {
get throws {
return try JSONEncoder.prettyPrinted.encode(self)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was like this before but this assumes that all Encodable can be encoded as JSON or throw right? Not sure if that's true, but since this isn't a real change and doesn't seem to have caused issues, we can leave for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, that’s what Codable ensures in Swift.

// Only checking on integration tests.
// Unit tests might run on the main thread when testing this class directly.
if ProcessInfo.isRunningIntegrationTests {
if ProcessInfo.processInfo.environment["RCRunningIntegrationTests"] == "1" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if there is a way in iOS to know if it's running tests generically so it's done automatically even for other people using this as a library... This should be ok for now though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is, but we decided to use a separate variable: #2100 (comment)


import Foundation

final class ReceiptParserLogger: LoggerType {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I believe this is currently unused?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm maybe, I split this PR in 2, so it’s possible this will be used by #2155


### Parsing Receipts
- ``PurchasesReceiptParser``
- ``AppleReceipt``

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are planning to move these to the SPM library later right? I'm concerned about making this part of the SDK public API here and then moving them to a library later on since that would mean it would be a breaking change unless we can somehow make it a transitive dependency... Should we hold on merging this to main until the SPM library part is also ready? (I haven't checked #2155 yet)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment, we’ll be exposing this as part of the SDK too for users who already use the main Framework.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh ok makes sense!

@NachoSoto

Copy link
Copy Markdown
Contributor Author

It looks good but I will hold off approval until #2155 is also ready, to avoid adding new APIs and removing them later.

They’re not going to be removed. You’ll be able to use this either from the main Framework or using the new one only.

@NachoSoto

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I know this one was a big PR.

@NachoSoto

Copy link
Copy Markdown
Contributor Author

I'll hold on merging this for today's hotfix so we get all those bugfixes first before creating a minor release with the new API.

Initial step for [CSDK-17].

- Renamed `ReceiptParser` to `PurchasesReceiptParser` to avoid name collision with future SPM `ReceiptParser`
- Exposed `ReceiptParser`, `AppleReceipt`, `PurchasesReceiptParser.Error`
- Added new types to `SwiftAPITester`
- Added docs to these types
- Moved `LoggerType` to be available to `ReceiptParser`
- Moved `DateFormatter+Extensions` to be available to `ReceiptParser`
- Moved `Codable+Extensions` to be available to `ReceiptParser`
- Created `ReceiptParserLogger` for `ReceiptParser`
@NachoSoto NachoSoto force-pushed the receipt-parser-public branch from 1b9e77a to 05d4883 Compare December 22, 2022 17:59
@NachoSoto NachoSoto enabled auto-merge (squash) December 22, 2022 18:00
@NachoSoto NachoSoto merged commit b3875a9 into main Dec 22, 2022
@NachoSoto NachoSoto deleted the receipt-parser-public branch December 22, 2022 18:09
NachoSoto added a commit that referenced this pull request Dec 22, 2022
Finishes [CSDK-17].
Follow up to #2153. Extracted from #2096.

### Changes:
- Created target in `Package.swift`. It can be built separately: `swift
build --target ReceiptParser`
![Screenshot 2022-11-29 at 09 29
10](https://user-images.githubusercontent.com/685609/204600321-9c99958c-a683-4b59-8334-df1cf1235d1d.png)
- Created `ReceiptParser` target in project:
![Screenshot 2022-12-14 at 13 56
38](https://user-images.githubusercontent.com/685609/207723593-40535089-1436-4b62-81cc-d098d589f83a.png)
- Added `ReceiptParser` scheme to allow building the target from Xcode:
![Screenshot 2022-12-14 at 13 57
02](https://user-images.githubusercontent.com/685609/207723665-dace0aa1-4ae7-4382-895f-908f356043b4.png)
- Added CI `spm-receipt-parser` job
- Added CI `installation-tests-receipt-parser` job
- Added `ReceiptParserAPITester` to test API for `ReceiptParser`'s
target
- Compile `ReceiptParserAPITester` when running `RevenueCat` tests so
these are validated as well. -

[CSDK-17]:
https://revenuecats.atlassian.net/browse/CSDK-17?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
NachoSoto pushed a commit that referenced this pull request Dec 27, 2022
**This is an automatic release.**

### New Features
* Created `ReceiptParser` SPM (#2155) via NachoSoto (@NachoSoto)
* Exposed `PurchasesReceiptParser` and `AppleReceipt` (#2153) via
NachoSoto (@NachoSoto)
### Bugfixes
* `Restore purchases`: post product data when posting receipts (#2178)
via NachoSoto (@NachoSoto)
### Other Changes
* Added `Dictionary.merge` (#2190) via NachoSoto (@NachoSoto)
* `CircleCI`: use Xcode 14.2.0 (#2187) via NachoSoto (@NachoSoto)
* `ReceiptParser`: a few documentation improvements (#2189) via
NachoSoto (@NachoSoto)
* `Purchase Tester`: fixed `TestFlight` deployment (#2188) via NachoSoto
(@NachoSoto)
* `Purchase Tester`: display specific `IntroEligibilityStatus` (#2184)
via NachoSoto (@NachoSoto)
* `Purchase Tester`: fixed `SubscriptionPeriod` (#2185) via NachoSoto
(@NachoSoto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants