vbscript Demo.vb
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript Demo.vb相关的知识,希望对你有一定的参考价值。
Imports Newtonsoft.Json;
Public Class Application
Dim webClient As New WebClient()
Dim resString As String
Dim reqString() As Byte
Const AccessToken = "ACCESS_TOKEN"
Public Shared Sub Main()
PartialRefund("111111")
GeneratePaymentOrder()
GetPaymentOrder()
RemovePaymentOrder()
End Sub
Public Function PartialRefund(id as String)
webClient.Headers("content-type") = "application/json"
urlToPost = "https://api.mercadopago.com/v1/payments/" + id + "/refunds?access_token=" + AccessToken
Dim dictData As New Dictionary(Of String, Object)
dictData.Add("amount", 10.5)
reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dictData, Formatting.Indented))
resByte = webClient.UploadData(urlToPost, "post", reqString)
resString = Encoding.Default.GetString(resByte)
' Do something with response (resString)
End Function
Public Function GeneratePaymentOrder()
webClient.Headers("content-type") = "application/json"
urlToPost = "https://mobile.mercadopago.com/point/services/integrations/v1?access_token=" + AccessToken
Dim dictData As New Dictionary(Of String, Object)
dictData.Add("amount", 5)
dictData.Add("description", "Test Point")
dictData.Add("external_reference", "Factura_001")
dictData.Add("cc_type", "credit_card")
dictData.Add("disable_back_button", true)
dictData.Add("device_name", "device_name")
reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dictData, Formatting.Indented))
resByte = webClient.UploadData(urlToPost, "post", reqString)
resString = Encoding.Default.GetString(resByte)
' Do something with response (resString)
End Function
Public Function GetPaymentOrder(id as String)
webClient.Headers("content-type") = "application/json"
urlToPost = "https://mobile.mercadopago.com/point/services/integrations/v1/" + id + "?access_token=" + AccessToken
reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dictData, Formatting.Indented))
resByte = webClient.UploadData(urlToPost, "get", reqString)
resString = Encoding.Default.GetString(resByte)
' Do something with response (resString)
End Function
Public Function RemovePaymentOrder(id as String)
webClient.Headers("content-type") = "application/json"
urlToPost = "https://mobile.mercadopago.com/point/services/integrations/v1/" + id + "?access_token=" + AccessToken
reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dictData, Formatting.Indented))
resByte = webClient.UploadData(urlToPost, "get", reqString)
resString = Encoding.Default.GetString(resByte)
' Do something with response (resString)
End Function
End Class
以上是关于vbscript Demo.vb的主要内容,如果未能解决你的问题,请参考以下文章