VB.NET UWP/WinRT Stripe: Update a Customer

Back to Index

Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Documentation: https://stripe.com/docs/api/curl#update_customer

CURL Command

curl -X POST https://api.stripe.com/v1/customers/cus_CBbgVLJqv487Oq \
   -u STRIPE_SECRET_KEY: \
   -d description="Customer for isabella.williams@example.com"

VB.NET UWP/WinRT Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://api.stripe.com/v1/customers/cus_CBbgVLJqv487Oq
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = Await rest.ConnectAsync("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


rest.SetAuthBasic("STRIPE_SECRET_KEY","")

rest.AddQueryParam("description","Customer for isabella.williams@example.com")


Dim strResponseBody As String = Await rest.FullRequestFormUrlEncodedAsync("POST","/v1/customers/cus_CBbgVLJqv487Oq")
If (rest.LastMethodSuccess <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.Load(strResponseBody)

Dim id As String
Dim object As String
Dim account_balance As Integer
Dim created As Integer
Dim currency As String
Dim default_source As Boolean
Dim delinquent As Boolean
Dim description As String
Dim discount As Boolean
Dim email As Boolean
Dim livemode As Boolean
Dim shipping As Boolean
Dim sourcesObject As String
Dim sourcesHas_more As Boolean
Dim sourcesTotal_count As Integer
Dim sourcesUrl As String
Dim subscriptionsObject As String
Dim subscriptionsHas_more As Boolean
Dim subscriptionsTotal_count As Integer
Dim subscriptionsUrl As String
Dim i As Integer
Dim count_i As Integer

id = jsonResponse.StringOf("id")
object = jsonResponse.StringOf("object")
account_balance = jsonResponse.IntOf("account_balance")
created = jsonResponse.IntOf("created")
currency = jsonResponse.StringOf("currency")
default_source = jsonResponse.IsNullOf("default_source")
delinquent = jsonResponse.BoolOf("delinquent")
description = jsonResponse.StringOf("description")
discount = jsonResponse.IsNullOf("discount")
email = jsonResponse.IsNullOf("email")
livemode = jsonResponse.BoolOf("livemode")
shipping = jsonResponse.IsNullOf("shipping")
sourcesObject = jsonResponse.StringOf("sources.object")
sourcesHas_more = jsonResponse.BoolOf("sources.has_more")
sourcesTotal_count = jsonResponse.IntOf("sources.total_count")
sourcesUrl = jsonResponse.StringOf("sources.url")
subscriptionsObject = jsonResponse.StringOf("subscriptions.object")
subscriptionsHas_more = jsonResponse.BoolOf("subscriptions.has_more")
subscriptionsTotal_count = jsonResponse.IntOf("subscriptions.total_count")
subscriptionsUrl = jsonResponse.StringOf("subscriptions.url")
i = 0
count_i = jsonResponse.SizeOfArray("sources.data")
While i < count_i
    jsonResponse.I = i
    i = i + 1
End While
i = 0
count_i = jsonResponse.SizeOfArray("subscriptions.data")
While i < count_i
    jsonResponse.I = i
    i = i + 1
End While

Sample JSON Response Body

{
  "id": "cus_CBbgVLJqv487Oq",
  "object": "customer",
  "account_balance": 0,
  "created": 1516662781,
  "currency": "usd",
  "default_source": null,
  "delinquent": false,
  "description": "Customer for isabella.williams@example.com",
  "discount": null,
  "email": null,
  "livemode": false,
  "metadata": {},
  "shipping": null,
  "sources": {
    "object": "list",
    "data": [
    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_CBbgVLJqv487Oq/sources"
  },
  "subscriptions": {
    "object": "list",
    "data": [
    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/customers/cus_CBbgVLJqv487Oq/subscriptions"
  }
}