Classic ASP Requires Chilkat v11.7.0+
Classic ASP
Stripe: Preview a plan or seat change
See more Stripe Examples
Preview a seat or plan change and display its proration lines, total, and the timestamp to retain with the quote.
Stripe documentation and cURL example
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Requires an unlocked Chilkat bundle. See Global Unlock Sample.
' Supply a restricted sandbox key from merchant-controlled configuration.
apiKey = "YOUR_STRIPE_TEST_KEY"
set curl = Server.CreateObject("Chilkat.HttpCurl")
set cmd = Server.CreateObject("Chilkat.StringBuilder")
set json = Server.CreateObject("Chilkat.JsonObject")
subscriptionId = "sub_FROM_ACCOUNT"
itemId = "si_SELECTED_ITEM"
priceId = "price_FROM_CATALOG"
set now = Server.CreateObject("Chilkat.CkDateTime")
success = now.SetFromCurrentSystemTime()
prorationDate = now.GetAsUnixTimeStr(0)
' curl -X POST "https://api.stripe.com/v1/invoices/create_preview" \
' -u "$STRIPE_API_KEY:" \
' -H "Stripe-Version: 2026-10-28.endive" \
' -d "subscription={subscriptionId}" \
' -d "subscription_details[items][0][id]={itemId}" \
' -d "subscription_details[items][0][price]={priceId}" \
' -d "subscription_details[items][0][quantity]=5" \
' -d "subscription_details[proration_behavior]=create_prorations" \
' -d "subscription_details[proration_date]={prorationDate}"
success = cmd.SetString("curl -X POST ""https://api.stripe.com/v1/invoices/create_preview""")
success = cmd.Append(" -u ""@KEY@:""")
success = cmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
success = cmd.Append(" -d ""subscription=@SUB@""")
success = cmd.Append(" -d ""subscription_details[items][0][id]=@ITEM@""")
success = cmd.Append(" -d ""subscription_details[items][0][price]=@PRICE@""")
success = cmd.Append(" -d ""subscription_details[items][0][quantity]=5""")
success = cmd.Append(" -d ""subscription_details[proration_behavior]=create_prorations""")
success = cmd.Append(" -d ""subscription_details[proration_date]=@DATE@""")
replaced = cmd.Replace("@SUB@",subscriptionId)
replaced = cmd.Replace("@ITEM@",itemId)
replaced = cmd.Replace("@PRICE@",priceId)
replaced = cmd.Replace("@DATE@",prorationDate)
replaced = cmd.Replace("@KEY@",apiKey)
success = curl.DoYourThing(cmd.GetAsString())
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Chilkat failure code: " & curl.FailReason) & "</pre>"
Response.End
End If
success = curl.GetResponseJson(json)
If ((curl.StatusCode <> 200) Or (success <> 1)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Stripe HTTP " & curl.StatusCode & " Request-Id: " & curl.GetResponseHeaderField("Request-Id")) & "</pre>"
If (success = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( json.StringOf("error.message")) & "</pre>"
End If
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "total = " & json.StringOf("total")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "currency = " & json.StringOf("currency")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Save this preview time with the selected changes: " & prorationDate) & "</pre>"
i = 0
Do While (i < json.SizeOfArray("lines.data"))
json.I = i
If (json.BoolOf("lines.data[i].parent.subscription_item_details.proration") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( json.StringOf("lines.data[i].description") & " " & json.StringOf("lines.data[i].amount")) & "</pre>"
End If
i = i + 1
Loop
If (json.BoolOf("lines.has_more") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Only the first page of preview lines is shown. The total covers all lines.") & "</pre>"
End If
%>
</body>
</html>