Asked by:
BillPlz payment gateway...

Question
-
User944339287 posted
hi guys.. i trying to apply BillPlz Payment Gateway in my web application.
I keep getting this error "Access Denied"
May i know what's wrong to my code?
BillPlz API URL:
https://billplz-staging.herokuapp.com/api#create-a-bill24My Code:
Private Sub payment_BillPlz() Dim myPost As New RemotePostBillPlz myPost.Add("", "0cea2674-6eb3-445f-9272-11c33afd1bc5") myPost.Add("collection_id", "pimjnj57") myPost.Add("email", "tonystark@gmail.com") myPost.Add("mobile", "60125588909") myPost.Add("name", "Tony Stark") myPost.Add("amount", "1000")
myPost.Add("descriptoin", "Invoice #S1001") myPost.Add("callback_url", "http://www.stark.com") myPost.Post() End Sub Protected Sub btn_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_submit.Click payment_BillPlz() End SubRemotePostBillPlz.vb
Public Sub New() inputValues = New NameValueCollection() Url = "https://billplz-staging.herokuapp.com/api/v3/bills" Method = "post" FormName = "ePayment" End Sub Public Sub Add(ByVal name As String, ByVal value As String) inputValues.Add(name, value) End Sub Public Sub Post() Dim context = HttpContext.Current context.Response.Clear() context.Response.Write("<html><head>") context.Response.Write(String.Format("</head><body onload=""document.{0}.submit()"">", FormName)) context.Response.Write(String.Format("<form name=""{0}"" method=""{1}"" action=""{2}"" >", FormName, Method, Url)) For i As Integer = 0 To inputValues.Keys.Count - 1 context.Response.Write(String.Format("<input name=""{0}"" type=""hidden"" value=""{1}"">", HttpUtility.HtmlEncode(inputValues.Keys(i)), HttpUtility.HtmlEncode(inputValues(inputValues.Keys(i))))) Next context.Response.Write("</form>") context.Response.Write("</body></html>") context.Response.[End]() End Sub
Monday, February 5, 2018 5:58 AM
All replies
-
User409696431 posted
You linked to a page for V2, with a clear warning at the bottom of that page: "DEPRECATION WARNING: Support for V2 will be dropped after 31/10/2016.". If that's not the issue, I'll leave it to someone else willing to dig into their code.
Monday, February 5, 2018 6:31 AM -
User944339287 posted
Hi,
i getting advise from provider.
You API Key must be sent using Basic Authentication Header and not as part of POST data.
Can advise me how to amend RemotePostBillPlz.vb for this requirement?
Tuesday, February 6, 2018 6:54 AM -
User283571144 posted
Hi kengkit,
i getting advise from provider.
You API Key must be sent using Basic Authentication Header and not as part of POST data.
Can advise me how to amend RemotePostBillPlz.vb for this requirement?According to your description, I suggest you could try to use below codes to achieve your requirement.
Protected Sub btn_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_submit.Click Dim url As String = "https://billplz-staging.herokuapp.com/api/v3/bills" 'Private creds = String.Format("{0}:{1}", _username, _password) 'Private basicAuth = String.Format("Basic {0}", Convert.ToBase64String(Encoding.UTF8.GetBytes(creds))) Dim httpClient = New HttpClient() Dim basicAuth = String.Format("Basic {0}", "0cea2674-6eb3-445f-9272-11c33afd1bc5") httpClient.DefaultRequestHeaders.Add("Authorization", basicAuth) Dim post = httpClient.PostAsync(url, New FormUrlEncodedContent(New Dictionary(Of String, String) From { {"collection_id", "pimjnj57"}, {"email", "tonystark@gmail.com"}, {"mobile", "1000"}, {"description", "60125588909"}, {"email", "tonystark@gmail.com"}, {"name", "tony stark"}, {"descriptoin", "Invoice #S1001"}, {"callback_url", "http://www.stark.com"}})) post.Wait() End Sub
Best Regards,
Brando
Wednesday, February 7, 2018 7:32 AM