VB.NET UWP/WinRT Stripe: Update a Card

Back to Index

Updates only some card details, like the billing address or expiration date, you can do so without having to re-enter the full card details.

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

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL \
   -d name="Liam Thomas" \
   -X POST

VB.NET UWP/WinRT Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
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)
    Exit Sub
End If


rest.AddQueryParam("name","Liam Thomas")

Dim strResponseBody As String = Await rest.FullRequestFormUrlEncodedAsync("POST","/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL")
If (rest.LastMethodSuccess <> True) Then
    Exit Sub
End If

Dim jsonResponse As New Chilkat.JsonObject

Dim id As String
Dim object As String
Dim address_city As Boolean
Dim address_country As Boolean
Dim address_line1 As Boolean
Dim address_line1_check As Boolean
Dim address_line2 As Boolean
Dim address_state As Boolean
Dim address_zip As Boolean
Dim address_zip_check As Boolean
Dim brand As String
Dim country As String
Dim customer As String
Dim cvc_check As Boolean
Dim dynamic_last4 As Boolean
Dim exp_month As Integer
Dim exp_year As Integer
Dim fingerprint As String
Dim funding As String
Dim last4 As String
Dim name As String
Dim tokenization_method As Boolean

id = jsonResponse.StringOf("id")
object = jsonResponse.StringOf("object")
address_city = jsonResponse.IsNullOf("address_city")
address_country = jsonResponse.IsNullOf("address_country")
address_line1 = jsonResponse.IsNullOf("address_line1")
address_line1_check = jsonResponse.IsNullOf("address_line1_check")
address_line2 = jsonResponse.IsNullOf("address_line2")
address_state = jsonResponse.IsNullOf("address_state")
address_zip = jsonResponse.IsNullOf("address_zip")
address_zip_check = jsonResponse.IsNullOf("address_zip_check")
brand = jsonResponse.StringOf("brand")
country = jsonResponse.StringOf("country")
customer = jsonResponse.StringOf("customer")
cvc_check = jsonResponse.IsNullOf("cvc_check")
dynamic_last4 = jsonResponse.IsNullOf("dynamic_last4")
exp_month = jsonResponse.IntOf("exp_month")
exp_year = jsonResponse.IntOf("exp_year")
fingerprint = jsonResponse.StringOf("fingerprint")
funding = jsonResponse.StringOf("funding")
last4 = jsonResponse.StringOf("last4")
name = jsonResponse.StringOf("name")
tokenization_method = jsonResponse.IsNullOf("tokenization_method")

Sample JSON Response Body

  "id": "card_1BnETKGswQrCoh0Xhu1A6BfL",
  "object": "card",
  "address_city": null,
  "address_country": null,
  "address_line1": null,
  "address_line1_check": null,
  "address_line2": null,
  "address_state": null,
  "address_zip": null,
  "address_zip_check": null,
  "brand": "Visa",
  "country": "US",
  "customer": "cus_CBbg3iRMzWBjoe",
  "cvc_check": null,
  "dynamic_last4": null,
  "exp_month": 8,
  "exp_year": 2019,
  "fingerprint": "F9mANtIt1TaukpRJ",
  "funding": "credit",
  "last4": "4242",
  "metadata": {},
  "name": "Liam Thomas",
  "tokenization_method": null