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

Issue 272. Added ability to include developer payload in updateSubscription() methods #273

Merged
merged 1 commit into from
Jun 3, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,28 @@ public boolean isSubscriptionUpdateSupported()
* is not supported.
*/
public boolean updateSubscription(Activity activity, String oldProductId, String productId)
{
return updateSubscription(activity, oldProductId, productId, null);
}

/**
* Change subscription i.e. upgrade or downgrade
*
* @param activity the activity calling this method
* @param oldProductId passing null or empty string will act the same as {@link #subscribe(Activity, String)}
* @param productId the new subscription id
* @param developerPayload the developer payload
* @return {@code false} if {@code oldProductId} is not {@code null} AND change subscription
* is not supported.
*/
public boolean updateSubscription(Activity activity, String oldProductId, String productId, String developerPayload)
{
List<String> oldProductIds = null;
if (!TextUtils.isEmpty(oldProductId))
{
oldProductIds = Collections.singletonList(oldProductId);
}
return updateSubscription(activity, oldProductIds, productId);
return updateSubscription(activity, oldProductIds, productId, developerPayload);
}

/**
Expand All @@ -394,12 +409,28 @@ public boolean updateSubscription(Activity activity, String oldProductId, String
*/
public boolean updateSubscription(Activity activity, List<String> oldProductIds,
String productId)
{
return updateSubscription(activity, oldProductIds, productId, null);
}

/**
* Change subscription i.e. upgrade or downgrade
*
* @param activity the activity calling this method
* @param oldProductIds passing null will act the same as {@link #subscribe(Activity, String)}
* @param productId the new subscription id
* @param developerPayload the developer payload
* @return {@code false} if {@code oldProductIds} is not {@code null} AND change subscription
* is not supported.
*/
public boolean updateSubscription(Activity activity, List<String> oldProductIds,
String productId, String developerPayload)
{
if (oldProductIds != null && !isSubscriptionUpdateSupported())
{
return false;
}
return purchase(activity, oldProductIds, productId, Constants.PRODUCT_TYPE_SUBSCRIPTION, null);
return purchase(activity, oldProductIds, productId, Constants.PRODUCT_TYPE_SUBSCRIPTION, developerPayload);
}

private boolean purchase(Activity activity, String productId, String purchaseType,
Expand Down