Search code examples
in-app-purchaseapp-store-connect

Set a price for IAP Consumable in AppStore Connect API


I'm trying to use AppStore Connect API to create and configure a simple pricing for In App Purchase.

What I want

  • I successfully created the IAP using POST v2/inAppPurchases

  • Now I want to simulate setting the price based in CZK currency as base. Basically I want to replicate these actions in UI

    • STEP 1 IN UI - click on Add Pricing in detail of the IAP
    • STEP 2 IN UI - Base country: Czech Republic (CZK), Price: Kč 99.00
    • STEP 3 in UI - I click Next and then Confirm. I'm perfectly fine with the currency conversions to other currencies so I don't want to change anything.
  • This is how the final result looks in UI Final price schedule

What I tried

So I followed the official AppStore Connect docs.

  • I create the IAP first using POST v2/inAppPurchases. I remember the returned IAP ID.
  • Now I find the price point using GET /v2/inAppPurchases/{id}/pricePoints and get its ID.
  • Now I call POST /v1/inAppPurchasePriceSchedules, I'm following the documentation preciesly but it's not working. The response is complaining about startDate and endDate and some timelines but I have no idea what these fields should contain. I tried setting it to an empty values or some dates but this is not what the API is expecting.

My request

{
    "data": {
        "type": "inAppPurchasePriceSchedules",
        "relationships": {
            "baseTerritory": {
                "data": {
                    "id": "CZE",
                    "type": "territories"
                }
            },
            "inAppPurchase": {
                "data": {
                    "id": "6477355320",
                    "type": "inAppPurchases"
                }
            },
            "manualPrices": {
                "data": [
                    {
                        "id": "eyJzIjoiNjQ3NzM1NTMyMCIsInQiOiJDWkUiLCJwIjoiMTAwNTEifQ",
                        "type": "inAppPurchasePrices"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "id": "eyJzIjoiNjQ3NzM1NTMyMCIsInQiOiJDWkUiLCJwIjoiMTAwNTEifQ",
            "type": "inAppPurchasePrices",
            "attributes": {
                "startDate": "2024-02-04",
                "endDate": "2024-02-05"
            },
            "relationships": {
                "inAppPurchasePricePoint": {
                    "data": {
                        "id": "eyJzIjoiNjQ3NzM1NTMyMCIsInQiOiJDWkUiLCJwIjoiMTAwNTEifQ",
                        "type": "inAppPurchasePricePoints"
                    }
                },
                "inAppPurchaseV2": {
                    "data": {
                        "id": "6477355320",
                        "type": "inAppPurchases"
                    }
                }
            }
        }
    ]
}

Response

HTTP 409
{
  "errors" : [ {
    "id" : "b42142d7-d656-45c6-ad3a-8a7f19ce6974",
    "status" : "409",
    "code" : "ENTITY_ERROR.INVALID_END_DATE",
    "title" : "There is a problem with the request entity",
    "detail" : "Entire timeline must be covered for CZE. Rightmost interval must not have an end date: [2024-02-04T00:00 - 2024-02-05T00:00]",
    "source" : {
      "pointer" : "/data/relationships/manualPrices/data/0/attributes/endDate"
    }
  } ]
}

Solution

  • Okay so that was stupid.

    I simply set startDate and endDate to null. Which for some reason I did not try up until now. And it works as I expected.