This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
PaymentRequest.cs
61 lines (48 loc) · 1.66 KB
/
PaymentRequest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;
using System.Net;
namespace MovieWeb
{
class PaymentRequest
{
public PaymentRequest() {
}
public static string sendPaymentRequest(string endpoint, string postJsonString)
{
try
{
HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(endpoint);
var postData = postJsonString;
var data = Encoding.UTF8.GetBytes(postData);
httpWReq.ProtocolVersion = HttpVersion.Version11;
httpWReq.Method = "POST";
httpWReq.ContentType = "application/json";
httpWReq.ContentLength = data.Length;
httpWReq.ReadWriteTimeout = 30000;
httpWReq.Timeout = 15000;
Stream stream = httpWReq.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
string jsonresponse = "";
using (var reader = new StreamReader(response.GetResponseStream()))
{
string temp = null;
while ((temp = reader.ReadLine()) != null)
{
jsonresponse += temp;
}
}
//todo parse it
return jsonresponse;
//return new MomoResponse(mtid, jsonresponse);
}
catch (WebException e)
{
return e.Message;
}
}
}
}