Visual Basic 6.0 Stripe: Update a Source

Back to Index

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

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

CURL Command

curl https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP \
   -u STRIPE_SECRET_KEY: \
   -d metadata[order_id]=6735 \
   -X POST

Visual Basic 6.0 Example

Dim rest As New ChilkatRest
Dim success As Long

'  URL: https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print rest.LastErrorText
    Exit Sub
End If

success = rest.SetAuthBasic("STRIPE_SECRET_KEY","")

success = rest.AddQueryParam("metadata[order_id]","6735")

Dim strResponseBody As String
strResponseBody = rest.FullRequestFormUrlEncoded("POST","/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP")
If (rest.LastMethodSuccess <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim jsonResponse As New ChilkatJsonObject
success = jsonResponse.Load(strResponseBody)

Dim id As String
Dim object As String
Dim amount As Long
Dim client_secret As String
Dim created As Long
Dim currency As String
Dim flow As String
Dim livemode As Long
Dim metadataOrder_id As String
Dim ownerAddress As Long
Dim ownerEmail As String
Dim ownerName As Long
Dim ownerPhone As Long
Dim ownerVerified_address As Long
Dim ownerVerified_email As Long
Dim ownerVerified_name As Long
Dim ownerVerified_phone As Long
Dim receiverAddress As String
Dim receiverAmount_charged As Long
Dim receiverAmount_received As Long
Dim receiverAmount_returned As Long
Dim receiverRefund_attributes_method As String
Dim receiverRefund_attributes_status As String
Dim statement_descriptor As Long
Dim status As String
Dim type As String
Dim usage As String
Dim bitcoinAddress As String
Dim bitcoinAmount As Long
Dim bitcoinAmount_charged As Long
Dim bitcoinAmount_received As Long
Dim bitcoinAmount_returned As Long
Dim bitcoinUri As String

id = jsonResponse.StringOf("id")
object = jsonResponse.StringOf("object")
amount = jsonResponse.IntOf("amount")
client_secret = jsonResponse.StringOf("client_secret")
created = jsonResponse.IntOf("created")
currency = jsonResponse.StringOf("currency")
flow = jsonResponse.StringOf("flow")
livemode = jsonResponse.BoolOf("livemode")
metadataOrder_id = jsonResponse.StringOf("metadata.order_id")
ownerAddress = jsonResponse.IsNullOf("owner.address")
ownerEmail = jsonResponse.StringOf("owner.email")
ownerName = jsonResponse.IsNullOf("owner.name")
ownerPhone = jsonResponse.IsNullOf("owner.phone")
ownerVerified_address = jsonResponse.IsNullOf("owner.verified_address")
ownerVerified_email = jsonResponse.IsNullOf("owner.verified_email")
ownerVerified_name = jsonResponse.IsNullOf("owner.verified_name")
ownerVerified_phone = jsonResponse.IsNullOf("owner.verified_phone")
receiverAddress = jsonResponse.StringOf("receiver.address")
receiverAmount_charged = jsonResponse.IntOf("receiver.amount_charged")
receiverAmount_received = jsonResponse.IntOf("receiver.amount_received")
receiverAmount_returned = jsonResponse.IntOf("receiver.amount_returned")
receiverRefund_attributes_method = jsonResponse.StringOf("receiver.refund_attributes_method")
receiverRefund_attributes_status = jsonResponse.StringOf("receiver.refund_attributes_status")
statement_descriptor = jsonResponse.IsNullOf("statement_descriptor")
status = jsonResponse.StringOf("status")
type = jsonResponse.StringOf("type")
usage = jsonResponse.StringOf("usage")
bitcoinAddress = jsonResponse.StringOf("bitcoin.address")
bitcoinAmount = jsonResponse.IntOf("bitcoin.amount")
bitcoinAmount_charged = jsonResponse.IntOf("bitcoin.amount_charged")
bitcoinAmount_received = jsonResponse.IntOf("bitcoin.amount_received")
bitcoinAmount_returned = jsonResponse.IntOf("bitcoin.amount_returned")
bitcoinUri = jsonResponse.StringOf("bitcoin.uri")

Sample JSON Response Body

{
  "id": "src_1BnETLGswQrCoh0X5KOorXEP",
  "object": "source",
  "amount": 1000,
  "client_secret": "src_client_secret_CBbgdvc1AflN5jN0wQevA2jA",
  "created": 1516662783,
  "currency": "usd",
  "flow": "receiver",
  "livemode": false,
  "metadata": {
    "order_id": "6735"
  },
  "owner": {
    "address": null,
    "email": "jenny.rosen@example.com",
    "name": null,
    "phone": null,
    "verified_address": null,
    "verified_email": null,
    "verified_name": null,
    "verified_phone": null
  },
  "receiver": {
    "address": "test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N",
    "amount_charged": 0,
    "amount_received": 0,
    "amount_returned": 0,
    "refund_attributes_method": "email",
    "refund_attributes_status": "missing"
  },
  "statement_descriptor": null,
  "status": "pending",
  "type": "bitcoin",
  "usage": "single_use",
  "bitcoin": {
    "address": "test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N",
    "amount": 2371000,
    "amount_charged": 0,
    "amount_received": 0,
    "amount_returned": 0,
    "uri": "bitcoin:test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N?amount=0.02371000"
  }
}