Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PaymentProvider.swift #83

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## Fixed
- sk1 purchase failed, but return success
- Fixed in Pull Request [#83](https://github.com/space-code/flare/pull/83)

## Updated
- Update `CHANGELOG.md`
- Updated in Pull Request [#74](https://github.com/space-code/flare/pull/74).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,20 @@ extension PaymentProvider: SKPaymentTransactionObserver {
forKey: transaction.payment.productIdentifier
), !handlers.isEmpty {
self.dispatchQueueFactory.main().async {
handlers.forEach { $0(queue, .success(transaction)) }
if let error = transaction.error {
Copy link
Member

Choose a reason for hiding this comment

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

This is only true if the transaction state is set to .failed. A user can manually check the error and transactionState properties of PaymentTransaction, which should have these values.

I'm not sure we need to throw an error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sometimes it is necessary to collect error information to improve the payment experience.

Copy link
Member

Choose a reason for hiding this comment

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

@zy19890102, why can't you collect the error information using PaymentTransaction? Could you please provide a minimal example where these changes are necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When users cancel payments, we will ask them for the reason behind the cancellation, whether it is due to the pricing of the product being too high or the subscription service not meeting their needs, in order to adjust our pricing strategy and subscription benefits.

Copy link
Member

Choose a reason for hiding this comment

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

@zy19890102 I see, thank you. But I don't get why you can't use the error property from the transaction.

There is a merge conflict. Please rebase, and could you also run the make fmt command in your terminal to format the codebase according to the project’s code style?

handlers.forEach { $0(queue, .failure(IAPError(error: error))) }
} else {
handlers.forEach { $0(queue, .success(transaction)) }
}
}
} else {
let handler = self.fallbackHandler
self.dispatchQueueFactory.main().async {
handler?(queue, .success(transaction))
if let error = transaction.error {
handler?(queue, .failure(IAPError(error: error)))
} else {
handler?(queue, .success(transaction))
}
}
}
}
Expand Down
Loading