-
Notifications
You must be signed in to change notification settings - Fork 12
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
Customer Object Added to Restore API #81
Customer Object Added to Restore API #81
Conversation
1. Passing customer_id for restore purchases 2. Handled customer_id in return handler for purchases.
@@ -12,7 +12,7 @@ public class CBPurchase: NSObject { | |||
public static let shared = CBPurchase() | |||
private var productIDs: [String] = [] | |||
public var receiveProductsHandler: ((_ result: Result<[CBProduct], CBPurchaseError>) -> Void)? | |||
public var buyProductHandler: ((Result<(status:Bool, subscriptionId:String?, planId:String?), Error>) -> Void)? | |||
public var buyProductHandler: ((Result<(status:Bool, subscriptionId:String?, planId:String?, customerId:String?), Error>) -> Void)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a breaking change for the SDK. If its not related to this PR, can we revert and take it up separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a breaking change for the SDK. If its not related to this PR, can we revert and take it up separately?
ok Its reverted
self.validateReceipt(product, completion: nil) | ||
if let customer = self.restoreCustomer { | ||
self.validateReceipt(product,customer: customer, completion: nil) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pass the customer
without having to unwrap? The validateReceipt
takes in an optional param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done Updated
CBPurchase.shared.restorePurchases(includeInActiveProducts: true) { result in | ||
//Ex: customer_id is mandatory field for restoring purchases so please pass customer object as shown example below | ||
let customer = CBCustomer(customerID: "Test123",firstName: "CB",lastName: "Test",email: "cbTest@chargebee.com") | ||
CBPurchase.shared.restorePurchases(includeInActiveProducts: true, customer: customer) { result in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the README as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
…separate PR 2. Passing 'restoreCustomer' as optional for validateReceipt() since its expecting a optional parameter
@@ -135,10 +136,11 @@ public extension CBPurchase { | |||
self.purchaseProductHandler(product: product, completion: handler) | |||
} | |||
|
|||
func restorePurchases(includeInActiveProducts:Bool = false ,completion handler: @escaping ((_ result: Result<[InAppSubscription], RestoreError>) -> Void)) { | |||
func restorePurchases(includeInActiveProducts:Bool = false, customer: CBCustomer, completion handler: @escaping ((_ result: Result<[InAppSubscription], RestoreError>) -> Void)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the customer as optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the versions in corresponding places as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the customer as optional?
Now customerId is mandatory know then why it should be optional ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the versions in corresponding places as well.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cb-gadagoju During the purchase flow, the customer object is still optional. And the same goes for validateReceipt as well. Do you think the same can be extended to the restore flow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cb-haripriyan yes we can implement optional as purchase flow but when its optional for restore merchant might consider optional and may skip it know any how he will get success after restore even if they didn't pass customer_id ? is't there any hidden problem which customer will know later again if they miss it ? i think we should highlight to customer for passing customerObject ! what you suggest ?
…dated Version number in all places
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Issues :
Fixes:
1.Introduced new param(CBCustomer object) in restorePurchases API which it helps to pass customer info while restoring the purchases and associate with the same customerId.