-
Notifications
You must be signed in to change notification settings - Fork 6
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
Omnisub 5499 - Upgrade/downgrade subscription #98
Open
cb-aravindradhakrishnan
wants to merge
27
commits into
master
Choose a base branch
from
OMNISUB-5499
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
79acc6c
feat: Added Change Product method in CBPurchase
cb-aravindradhakrishnan 08d0006
feat: Added Change Product option
cb-aravindradhakrishnan 942e453
feat: Created ChangeProduct params classwith oldProductId and prorati…
cb-aravindradhakrishnan 94f2f6f
feat: Code refactored
cb-aravindradhakrishnan 203dc88
feat: Return Valid errors
cb-aravindradhakrishnan e8cd2e6
feat: Added Code comments
cb-aravindradhakrishnan c6b1758
feat: Modified logs
cb-aravindradhakrishnan 83b7702
feat: Replace empty string with empty optional
cb-aravindradhakrishnan e66769f
feat: Remove OTP callback on error
cb-aravindradhakrishnan 08616b0
feat: Remove prorationMode from ChangeProductParams and set supported…
cb-aravindradhakrishnan 484d8b9
Feat: Error handling
cb-aravindradhakrishnan 27c85e6
feat: Rename changeProductParams props
cb-aravindradhakrishnan 7b706ca
feat: Rename changeProductParams props
cb-aravindradhakrishnan 56593af
feat: Proper error message
cb-aravindradhakrishnan 62c3248
feat: Updated readme
cb-aravindradhakrishnan 803326f
feat: Proper error message
cb-aravindradhakrishnan 159809a
feat: Rename changeProductParams props
cb-aravindradhakrishnan 7e0d6da
feat: Proper error message
cb-aravindradhakrishnan ecb90c4
feat: Reset currentProductId
cb-aravindradhakrishnan 90f39e3
feat: Handled within subscription case
cb-aravindradhakrishnan 2c98f6a
feat: Revert OTP callback on error
cb-aravindradhakrishnan 86676e1
feat: Revert OTP callback on error
cb-aravindradhakrishnan f8b63b0
feat: Updated readme
cb-aravindradhakrishnan ba2d1a7
feat: Function name change
cb-aravindradhakrishnan e9c5422
feat: Updated readme
cb-aravindradhakrishnan 418c231
feat: Add relevant error messages
cb-aravindradhakrishnan fb2ae76
feat: Update readme
cb-aravindradhakrishnan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,29 @@ CBPurchase.purchaseProduct(purchaseProductParams = purchaseProductParams, custom | |
``` | ||
The above function will handle the purchase against Google Play Store and send the IAP token for server-side token verification to your Chargebee account. Use the Subscription ID returned by the above function, to check for Subscription status on Chargebee and confirm the access - granted or denied. | ||
|
||
### Upgrade or Downgrade Product | ||
Pass the `ChangeProductParams` and `CBCustomer` to the following function when the user chooses the product to purchase. | ||
|
||
`CBCustomer` - **Optional object**. Although this is an optional object, we recommend passing the necessary customer details, such as `customerId`, `firstName`, `lastName`, and `email`. This ensures that the customer details in your database match the customer details in Chargebee. If the `customerId` is not passed in the customer's details, then the value of `customerId` will be the same as the `SubscriptionId` created in Chargebee. | ||
|
||
**Note**: The `customer` parameter in the below code snippet is an instance of `CBCustomer` class that contains the details of the customer who wants to subscribe or buy the product. | ||
|
||
```kotlin | ||
val changeProductParams = ChangeProductParams(newProductParams, "currentProductId") | ||
val cbCustomer = CBCustomer("customerId","firstName","lastName","email") | ||
CBPurchase.changeProduct(changeProductParams = changeProductParams, customer = cbCustomer, object : CBCallback.PurchaseCallback<String>{ | ||
override fun onSuccess(result: ReceiptDetail, status:Boolean) { | ||
Log.i(TAG, "$status") | ||
Log.i(TAG, "${result.subscription_id}") | ||
Log.i(TAG, "${result.plan_id}") | ||
} | ||
override fun onError(error: CBException) { | ||
Log.e(TAG, "Error: ${error.message}") | ||
} | ||
}) | ||
``` | ||
The above function is designed to manage subscription upgrades or downgrades between base plans within a single subscription or across different subscriptions. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be |
||
### Invoke Manage Subscriptions in your App | ||
The `showManageSubscriptionsSettings()` function is designed to invoke the Manage Subscriptions in your app using Chargebee's Android SDKs. `Chargebee.showManageSubscriptionsSettings()`, opens the Play Store App subscriptions settings page. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="300dp" | ||
android:layout_height="300dp" | ||
tools:context=".MainActivity"> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/planIdInputLayout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="96dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textView"> | ||
|
||
<EditText | ||
android:id="@+id/productIdInput" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:ems="13" | ||
android:inputType="textPersonName" /> | ||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/currentPlanIdInputLayout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.497" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textView"> | ||
|
||
<EditText | ||
android:id="@+id/currentProductIdInput" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:ems="13" | ||
android:inputType="textPersonName" /> | ||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
android:text="Chargebee" | ||
android:textSize="24sp" | ||
android:textStyle="bold" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/btn_ok" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="34dp" | ||
android:text="Submit" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/planIdInputLayout" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 mention the function name rather than only saying "to the following function..."? It will make the sentence more clear.
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.
Pass the
ChangeProductParams
andCBCustomer
to the followingChangeProduct
function when the user chooses the product to purchase.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-sabuj Done