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

Can't get a purchase state for multy product order. #2483

Closed
srgbsv opened this issue Aug 8, 2023 · 2 comments
Closed

Can't get a purchase state for multy product order. #2483

srgbsv opened this issue Aug 8, 2023 · 2 comments

Comments

@srgbsv
Copy link

srgbsv commented Aug 8, 2023

Hello

I made purchase, which included several inapp products. Then when I try to get a purchase state using API
purchase.products.get, I retrieve correct answer only for first productId from my order. For another products from order I get error:

{
  "error": {
    "code": 400,
    "message": "The purchase token does not match the product ID.",
    "errors": [
     {
       "message": "The purchase token does not match the product ID.",
        "domain": "androidpublisher",
        "reason": "purchaseTokenDoesNotMatchProductId",
        "location": "token",
        "locationType": "parameter"
      }
    ]
  }
}

Steps to reproduce:

  1. Make purchase
List<BillingFlowParams.ProductDetailsParams> params = new ArrayList<>();
// One product
params.add(BillingFlowParams.ProductDetailsParams
                    .newBuilder()
                    .setProductDetails(<ProducetDetails1>)
                    .setOfferToken(<OfferToken>)
                    .build()
);
// Another product
params.add(BillingFlowParams.ProductDetailsParams
                    .newBuilder()
                    .setProductDetails(<ProducetDetails2>)
                    .setOfferToken(<OfferToken>)
                    .build()
);

BillingFlowParams.Builder flowParams = BillingFlowParams.newBuilder()
                    .setProductDetailsParamsList(params);
billingClient.launchBillingFlow(activity, flowParams.build());     
  1. Try to get info about about purchase by token and productId
$androidpublisherService = new \Google_Service_AndroidPublisher($this->client);
$optParams = [];

$products = $androidpublisherService->purchases_products;
$data = $products->get(<bundleId>, <productId>, <token>, $optParams);

On this step for first product in order you will get some sing like this:

Google\Service\AndroidPublisher\ProductPurchase Object
(
    [acknowledgementState] => 1
    [consumptionState] => 1
    [developerPayload] => 
    [kind] => androidpublisher#productPurchase
    [obfuscatedExternalAccountId] => ced18ce3c8becf155b2d9b0093ce92c8
    [obfuscatedExternalProfileId] => 
    [orderId] => GPA.3378-4458-8632-41646
    [productId] => 
    [purchaseState] => 0
    [purchaseTimeMillis] => 1690814498887
    [purchaseToken] => 
    [purchaseType] => 0
    [quantity] => 
    [regionCode] => RU
    [internal_gapi_mappings:protected] => Array
        (
        )

    [modelData:protected] => Array
        (
        )

    [processed:protected] => Array
        (
        )
)

for another you will get the error

Thanks a lot in advance!

Environment details

  • OS: ubuntu 22.04
  • PHP version: 7.4
  • Package name and version: "google/apiclient": "2.14"
@bshaffer
Copy link
Contributor

I would try to make the call using the APIs Explorer. If you see the same issue there, then the problem is with the productId and token you're provided. If not, then the issue is with this library.

@bshaffer
Copy link
Contributor

Closing due to inactivity. Please reopen or file a new issue if you have additional questions or concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants