How do I add multiple items using google wallet di

2019-08-31 08:54发布

问题:

I am trying to add multiple items using google digital goods, what I want is for my users to be able to checkout with multiple items that are in their cart. Here is the code(not full code) with one item. How can I add multiple?

$payload = array(
    "iss" => $row['seller_identifier'], "aud" => "Google",
    "typ" => "google/payments/inapp/item/v1", "exp" => time() + 3600,
    "iat" => time(),
     "request" => array(
        "name"       => $_SESSION["itemname"],
        "price"      => $_SESSION["itemprice"], "currencyCode" => "USD",
        "sellerData" => "user_id:" . $this->userid
    )
);

回答1:

Multiple digital content items are not supported by design in the Google Wallet for digital goods API.

Depending on your use case, you can either sell the items individually (e.g. something like a "Buy Now" button) or calculate the total cost and place one bundle transaction.