aporat / store-receipt-validator

PHP receipt validator for Apple iTunes, Google Play and Amazon App Store
Apache License 2.0
633 stars 153 forks source link

Trying to validate a Google Play Subscription it return an error: subscriptionInvalidArgument #167

Closed MichSimi closed 1 year ago

MichSimi commented 2 years ago

Validating a subscription in test with validateSubscription() return an error "subscriptionInvalidArgument" with message "Your request is invalid for this subscription purchase".

Scope: https://www.googleapis.com/auth/androidpublisher

$response = $validator->setPackageName($packageName) ->setValidationModePurchase(false) ->setProductId($productId) ->setPurchaseToken($purchaseToken) ->validateSubscription();

The verification of a single purchase (validatePurchase) of the same application is ok

Stafox commented 2 years ago

Usually it means that you're trying to validation non-subscription purchase.

Could you share more details about the product? Maybe a screenshot from Google Play Console of the page with that product?

MichSimi commented 2 years ago

The product that i'm trying to validate is a subscription, i'm sure, i have also some single product purchases in the same application so i know that the productId in the response is a valid subscription. If i try to "acknowledge" the purchase i have an other error: The product purchase is not owned by the user.

MichSimi commented 2 years ago

Any idea? Still having the same error trying to validate a test subscription. In your example you do not use "acknowledge" the subscription, is "validateSubscription" enough or it use internally the acknowledge at some point?

Stafox commented 2 years ago

The product purchase is not owned by the user. It means you're trying to acknowledge subscription that was acknowledged before (maybe on client side).

By default acknowledge functionality does not used in validation process.

MichSimi commented 2 years ago

I was able to validate the subscription by creating a function that uses v2 subscriptions service. There is the code:

public function validateSubscriptionV2() { return new SubscriptionResponse( $this->_androidPublisherService->purchases_subscriptionsv2->get( $this->_package_name, $this->_purchase_token ) ); }

Stafox commented 2 years ago

@MichSimi what version of billing do you use in application? Version 5?

Related to #161