1

I'm trying to change subscription prices programmatically and found two relevant API methods:

Create price change

List price points

The first method requires ID of price point that can be retrieved by the second one. The second method returns price points in the following format:

{
    "type" : "appPricePoints",
    "id" : "eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ",
    "attributes" : {
      "customerPrice" : "3.99",
      "proceeds" : "2.8"
    },
    "relationships" : {
      "equalizations" : {
        "links" : {
          "self" : "https://api.appstoreconnect.apple.com/v3/appPricePoints/eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ/relationships/equalizations",
          "related" : "https://api.appstoreconnect.apple.com/v3/appPricePoints/eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ/equalizations"
        }
      }
    },
    "links" : {
      "self" : "https://api.appstoreconnect.apple.com/v3/appPricePoints/eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ"
    }
  }

where ID of price point is a base64-encoded JSON with three fields: s, t, and p.

UPD

Thanks to @inkerdusk, I got that Price Changes are pre-created by Apple and I should use them instead of creating my own ones.

So, I tried to send the following request where use base64 itself or every of three values of JSON that is represented as this base64.

{
        "data": {
            "attributes": {
            },
            "relationships": {
                "subscription": {
                    "data": {
                        "id": "subscription-id",
                        "type": "subscriptions"
                    }
                },
                "subscriptionPricePoint": {
                    "data": {
                        "id": <HERE_TRIED_TO_SPECIFY_BASE64_ITSELF_OR_ANY_OF_THREE_VALUES_OF_DECODED_JSON>,
                        "type": "subscriptionPricePoints"
                    }
                }
            },
            "type": "subscriptionPrices"
        }
    }

But every time I get the error:

{
  "errors" : [ {
    "id" : "466aa984-1491-4da3-8e5d-9b26dc9e844f",
    "status" : "422",
    "code" : "ENTITY_UNPROCESSABLE",
    "title" : "The request entity is not a valid request document object",
    "detail" : "Unexpected or invalid value at 'data.relationships.subscriptionPricePoint.data.id'.",
    "meta" : {
      "position" : {
        "row" : -1,
        "column" : -1
      }
    }
  } ]
}

How do I create a new Price Change?

Vassily
  • 5,263
  • 4
  • 33
  • 63
  • 1
    is this somewhat helpful ? https://developer.apple.com/help/app-store-connect/manage-app-pricing/set-a-price – inkredusk Apr 03 '23 at 05:38
  • 2
    Thanks! It helped to understand that price points are predefined by Apple but I still didn't managed to create price change with API. Updated the question. – Vassily Apr 03 '23 at 07:34

2 Answers2

0

Don't know if you managed to solve this, but by looking at the post request sent from the appstore connect website, updating the price of an in app purchase will look something like this:

{
"data": {
    "type": "inAppPurchasePriceSchedules",
    "attributes": {},
    "relationships": {
        "inAppPurchase": {
            "data": {
                "type": "inAppPurchases",
                "id": "6449182851"
            }
        },
        "manualPrices": {
            "data": [
                {
                    "type": "inAppPurchasePrices",
                    "id": "${newprice-0}"
                }
            ]
        },
        "baseTerritory": {
            "data": {
                "type": "territories",
                "id": "USA"
            }
        }
    }
},
"included": [
    {
        "id": "${newprice-0}",
        "relationships": {
            "inAppPurchasePricePoint": {
                "data": {
                    "type": "inAppPurchasePricePoints",
                    "id": "eyJzIjoiNjQ0OTE4Mjg1MSIsInQiOiJVU0EiLCJwIjoiMTAwMTAifQ"
                }
            }
        },
        "type": "inAppPurchasePrices",
        "attributes": {
            "startDate": null
        }
    }
]

}

Aske
  • 1
-1

Not sure but it seems like the issue is with the id field in the data.relationships.subscriptionPricePoint.data object, you should ensure that you have the correct subscription-id.

I think that to resolve the issue with the id field in data.relationships.subscriptionPricePoint.data, you need to use the correct decoded price point id from the response of the List price points API.

Try this python code to decode the encoded id and obtain the s value:

import base64
import json

encoded_id = "eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ"
decoded_json_string = base64.b64decode(encoded_id).decode("utf-8")
decoded_json = json.loads(decoded_json_string)

price_point_id = decoded_json["s"]

After obtaining the correct price_point_id, you can now use it in your request payload:

{
  "data": {
    "attributes": {},
    "relationships": {
      "subscription": {
        "data": {
          "id": "subscription-id",
          "type": "subscriptions"
        }
      },
      "subscriptionPricePoint": {
        "data": {
          "id": "price_point_id",
          "type": "subscriptionPricePoints"
        }
      }
    },
    "type": "subscriptionPrices"
  }
}

Make sure to replace "price_point_id" with the actual price_point_id value obtained from the previous step

NGDeveloper
  • 160
  • 10
  • As I mentioned in a question I've tried each of values from JSON. So, whereas JSON is `{'s': '1561611569', 't': 'AFG', 'p': '10000'}`, I've tried to specify JSON itself and separately `1561611569`, `AFG`, and `10000` – Vassily Apr 13 '23 at 04:59