Created
December 20, 2016 07:57
-
-
Save jgfrancisco/eca4d4f20f506c5889879c1996db0bdb to your computer and use it in GitHub Desktop.
Checkout creation using VB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("{ | |
""totalAmount"": { | |
""currency"": ""PHP"", | |
""value"": ""3210.99"" | |
}, | |
""buyer"": { | |
""firstName"": ""Visual"", | |
""lastName"": ""Basic"" | |
}, | |
""items"": [ | |
{ | |
""name"": ""Test Product Name"", | |
""quantity"": ""3"", | |
""totalAmount"": { | |
""value"": ""1070.33"" | |
} | |
} | |
], | |
""requestReferenceNumber"": ""000141386713"" | |
}") | |
Dim request = TryCast(System.Net.WebRequest.Create("https://pg-sandbox.paymaya.com/checkout/v1/checkouts"), System.Net.HttpWebRequest) | |
request.Method = "POST" | |
request.ContentType = "application/json" | |
request.Headers.Add("Authorization", "Basic cGstOHJPejRNUUtSeGQ1T0xLQlBjUjZGSVV4NEtheTcxa0IzVXJCRkRhSDE3Mjo=") | |
'FOR HTTPS | |
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | |
request.ContentLength = byteArray.Length | |
Dim writer = request.GetRequestStream() | |
writer.Write(byteArray, 0, byteArray.Length) | |
writer.Close() | |
Dim responseContent As String | |
Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse) | |
Using reader = New System.IO.StreamReader(response.GetResponseStream()) | |
'"{ | |
' ""checkoutId"":""<checkout id>"", | |
' ""redirectUrl"":""https://sandbox-checkout-v2.paymaya.com/checkout?id=<checkout id>"" | |
'}" | |
responseContent = reader.ReadToEnd() | |
Console.Write(responseContent) | |
End Using | |
End Using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment