Skip to content

Commit

Permalink
Issue 272. Added ability to include developer payload in updateSubscr…
Browse files Browse the repository at this point in the history
…iption() methods. (anjlab#273)
  • Loading branch information
autonomousapps authored and serggl committed Jun 3, 2017
1 parent d78d2f8 commit d9ca820
Showing 1 changed file with 33 additions and 2 deletions.
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

0 comments on commit d9ca820

Please sign in to comment.