Map a store product

Maps a store product, named by configuration as the provider's catalog entry shows, to a product.

The mapping is active at once, and purchases of the store product, including ones that waited for a mapping, grant the product's perks. A product sells one store product per provider: the first one mapped, until sell chooses another. Its other store products there are not offered to new buyers; people who bought them keep their access and their purchases still count for the product. A store product linked to another product needs isReassignment: true, which moves its mapping to this product with everything recorded under it, as move does; reassigning a store product already mapped to this product updates that mapping.

Guide: Map store products

POST
/api/v1/projects/{projectId}/payment-providers/{paymentProviderId}/products

Authorization

AuthorizationBearer <token>

A project secret key: vh_sk_... for production, vh_sk_test_... for test. Keep it on your servers.

In: header

Path parameters

projectId*string

The project's id, proj_.... A secret key works only in the project it belongs to.

paymentProviderId*string

The id of the project's payment provider connection, pp_conf_....

Request body

application/json

TypeScript definitions

Use the request body type in TypeScript.

productId*string

The product to map the store product to.

configuration*

Names the store product, as the configuration of its catalog entry does, with any store-specific settings such as offers.

environment?|

For a payment source whose test system names products differently, production or test; defaults to all. Stripe's is read from the price and App Store and Google Play mappings are always all, so leave it out for them, or give the value they get.

isReassignment?|

true moves a store product linked to another product to this one, with the purchases and subscriptions recorded under it, as the move action does; otherwise mapping it is refused. Defaults to false.

Examples

curl -X POST "https://api.voidhash.com/api/v1/projects/proj_tz4a98xxat96iws9zmbrgj3a/payment-providers/pp_conf_k2v8d4m1x7c9b3n6q0w5e2r8/products" \  -H "Authorization: Bearer vh_sk_..." \  -H "Content-Type: application/json" \  -d '{    "productId": "prod_x8k2m5q9v3n7c1z4w6e0r2t5",    "configuration": {      "productId": "com.example.pro_monthly"    }  }'
{  "id": "pp_prod_q4w8e2r6t1y5u9i3o7p0a2s6",  "paymentProviderId": "pp_conf_k2v8d4m1x7c9b3n6q0w5e2r8",  "productId": "prod_x8k2m5q9v3n7c1z4w6e0r2t5",  "providerProductKey": "com.example.pro_monthly",  "isActive": true,  "isSold": true,  "environment": "all",  "configuration": {    "productId": "com.example.pro_monthly",    "offers": []  }}
{  "error": {    "type": "invalid_request",    "code": "invalid_product_mapping",    "message": "Price price_1PqR8sT2uV3wX4yZ belongs to Stripe product prod_Qa1Bc2De3Fg4Hi, not prod_Qz9Yx8Wv7Ut6Sr",    "param": "configuration"  }}
{  "error": {    "type": "unauthenticated",    "code": "invalid_api_key",    "message": "This secret key is not valid."  }}
{  "error": {    "type": "permission_denied",    "code": "permission_denied",    "message": "Insufficient permissions."  }}

{  "error": {    "type": "not_found",    "code": "payment_provider_not_found",    "message": "This project has no payment provider pp_conf_k2v8d4m1x7c9b3n6q0w5e2r8.",    "param": "paymentProviderId"  }}

{  "error": {    "type": "internal",    "code": "internal_error",    "message": "Something went wrong on our side. Try again, and contact support with the Request-Id header if it keeps failing."  }}

Response body

application/json

application/json

application/json

application/json

application/json

application/json

Errors

StatustypecodeWhen
400invalid_requestinvalid_product_mappingFor a store product linked to another product without isReassignment, or one that cannot move to this product.
404not_foundpayment_provider_not_found—
404not_foundproduct_not_found—

It can also fail with the errors every operation shares, such as unauthenticated; see Errors.

More in Payment provider products

Something wrong or missing on this page? Tell us by email or on Discord.