Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
Stripe: Apply the selected plan or seat change
See more Stripe Examples
Apply an accepted subscription change to the original item and retrieve that item to verify the new price and quantity.
Stripe documentation and cURL example
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL lcApiKey
LOCAL lcOperationId
LOCAL loCurl
LOCAL loCmd
LOCAL loJson
LOCAL lnReplaced
LOCAL lcSubscriptionId
LOCAL lcItemId
LOCAL lcPriceId
LOCAL lcProrationDate
lnSuccess = 0
* Requires an unlocked Chilkat bundle. See Global Unlock Sample.
* Supply a restricted sandbox key from merchant-controlled configuration.
lcApiKey = "YOUR_STRIPE_TEST_KEY"
* Load the saved UUID for this operation. Reuse it only for a retry with identical inputs.
lcOperationId = "YOUR_SAVED_OPERATION_UUID"
loCurl = CreateObject('Chilkat.HttpCurl')
loCmd = CreateObject('Chilkat.StringBuilder')
loJson = CreateObject('Chilkat.JsonObject')
lcSubscriptionId = "sub_FROM_ACCOUNT"
lcItemId = "si_SELECTED_ITEM"
lcPriceId = "price_FROM_CATALOG"
lcProrationDate = "UNIX_SECONDS_FROM_PREVIEW"
* Use the item, quantity, price, and UTC timestamp accepted by the operator.
* curl -X POST "https://api.stripe.com/v1/subscriptions/{subscriptionId}" \
* -u "$STRIPE_API_KEY:" \
* -H "Stripe-Version: 2026-10-28.endive" \
* -H "Idempotency-Key: {operationId}-plan-change" \
* -d "items[0][id]={itemId}" \
* -d "items[0][price]={priceId}" \
* -d "items[0][quantity]=5" \
* -d "proration_behavior=create_prorations" \
* -d "proration_date={prorationDate}"
loCmd.SetString('curl -X POST "https://api.stripe.com/v1/subscriptions/@SUB@"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
loCmd.Append(' -H "Idempotency-Key: @OP@-plan-change"')
loCmd.Append(' -d "items[0][id]=@ITEM@"')
loCmd.Append(' -d "items[0][price]=@PRICE@"')
loCmd.Append(' -d "items[0][quantity]=5"')
loCmd.Append(' -d "proration_behavior=create_prorations"')
loCmd.Append(' -d "proration_date=@DATE@"')
lnReplaced = loCmd.Replace("@SUB@",lcSubscriptionId)
lnReplaced = loCmd.Replace("@ITEM@",lcItemId)
lnReplaced = loCmd.Replace("@PRICE@",lcPriceId)
lnReplaced = loCmd.Replace("@DATE@",lcProrationDate)
lnReplaced = loCmd.Replace("@OP@",lcOperationId)
lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
IF (lnSuccess <> 1) THEN
? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
CANCEL
ENDIF
lnSuccess = loCurl.GetResponseJson(loJson)
IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
? "Stripe HTTP " + STR(loCurl.StatusCode) + " Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
IF (lnSuccess = 1) THEN
? loJson.StringOf("error.message")
ENDIF
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
CANCEL
ENDIF
? "id = " + loJson.StringOf("id")
? "status = " + loJson.StringOf("status")
* curl -X GET "https://api.stripe.com/v1/subscription_items/{itemId}" \
* -u "$STRIPE_API_KEY:" \
* -H "Stripe-Version: 2026-10-28.endive"
loCmd.SetString('curl -X GET "https://api.stripe.com/v1/subscription_items/@ITEM@"')
loCmd.Append(' -u "@KEY@:"')
loCmd.Append(' -H "Stripe-Version: 2026-10-28.endive"')
lnReplaced = loCmd.Replace("@ITEM@",lcItemId)
lnReplaced = loCmd.Replace("@KEY@",lcApiKey)
lnSuccess = loCurl.DoYourThing(loCmd.GetAsString())
IF (lnSuccess <> 1) THEN
? "No HTTP response. Chilkat failure code: " + STR(loCurl.FailReason)
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
CANCEL
ENDIF
lnSuccess = loCurl.GetResponseJson(loJson)
IF ((loCurl.StatusCode <> 200) OR (lnSuccess <> 1)) THEN
? "Stripe HTTP " + STR(loCurl.StatusCode) + " Request-Id: " + loCurl.GetResponseHeaderField("Request-Id")
IF (lnSuccess = 1) THEN
? loJson.StringOf("error.message")
ENDIF
RELEASE loCurl
RELEASE loCmd
RELEASE loJson
CANCEL
ENDIF
? "id = " + loJson.StringOf("id")
? "id = " + loJson.StringOf("price.id")
? "quantity = " + loJson.StringOf("quantity")
RELEASE loCurl
RELEASE loCmd
RELEASE loJson