Move a store product to another product

Moves the mapping to another product of the project, keeping its id: the purchases, subscriptions and revenue recorded under the store product move with it, so reports by product change and totals do not.

Its buyers get the target product's perks instead of the current product's. The target sells the store product unless it already sells another one of this provider, in which case the moved one is not offered to new buyers; the current product, if it sold this one, then sells its most recently mapped remaining store product. Moving it to the product it already belongs to changes nothing, so a retried move succeeds. explain-move shows the impact first.

Guide: Map store products

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

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_....

mappingId*string

The mapping's id, pp_prod_....

Request body

application/json

TypeScript definitions

Use the request body type in TypeScript.

productId*string

The product to move the store product to: another product of the project, of the same type and, for a subscription, renewing over the same period.

Examples

curl -X POST "https://api.voidhash.com/api/v1/projects/proj_tz4a98xxat96iws9zmbrgj3a/payment-providers/pp_conf_k2v8d4m1x7c9b3n6q0w5e2r8/products/pp_prod_q4w8e2r6t1y5u9i3o7p0a2s6/move" \  -H "Authorization: Bearer vh_sk_..." \  -H "Content-Type: application/json" \  -d '{    "productId": "prod_m3c7v1b5n9q2w6e0r4t8y2u6"  }'
{  "id": "pp_prod_q4w8e2r6t1y5u9i3o7p0a2s6",  "paymentProviderId": "pp_conf_k2v8d4m1x7c9b3n6q0w5e2r8",  "productId": "prod_m3c7v1b5n9q2w6e0r4t8y2u6",  "providerProductKey": "com.example.pro_monthly",  "isActive": true,  "isSold": true,  "environment": "all",  "configuration": {    "productId": "com.example.pro_monthly",    "offers": []  }}

{  "error": {    "type": "invalid_request",    "code": "product_type_mismatch",    "message": "Product lifetime is not the same type of product as pro-monthly; a store product can only move to a product of the same type.",    "param": "productId"  }}

{  "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": "product_mapping_not_found",    "message": "This payment provider has no store product mapping pp_prod_q4w8e2r6t1y5u9i3o7p0a2s6.",    "param": "mappingId"  }}

{  "error": {    "type": "conflict",    "code": "store_product_already_mapped",    "message": "Provider product key com.example.pro_monthly is already mapped to another product"  }}

{  "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

application/json

Errors

StatustypecodeWhen
400invalid_requestproduct_type_mismatchFor a product of another type or renewal period.
400invalid_requestproduct_duration_mismatchFor a product of another type or renewal period.
404not_foundproduct_mapping_not_found—
404not_foundproduct_not_found—
409conflictstore_product_already_mappedWhen the target already has an active mapping of the store product.
409conflicttarget_mapping_has_purchasesWhen it has an earlier one with purchases recorded under it.
409conflictrevenue_history_not_readyFor a project whose revenue history has to be prepared before store products can move.

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.