Skip to content

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

Closed
@srgbsv

Description

@srgbsv

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions