Omskriv php til ASP
Hej,Er der nogen af jer, der kan hjælpe med dette? Jeg er desværre gået helt i stå.
string email = "testmail"; ***** Den skal hente mailen ind fra DB ******
string userId = "testid";
string reepayToken = "testtoken";
string url = "https://api.reepay.com/v1/subscription";
string username = "prv_321321321321321321:";
string data = "{
\"plan\": \"plan-37965\",
\"signup_method\": \"card_token\",
\"create_customer\": {
\"email\": \"" + email + "\",
\"handle\": \"" + userId + "\",
},
\"generate_handle\": true,
\"card_token\": \"" + reepayToken + "\"
}";
WebRequest myReq = WebRequest.Create(url);
myReq.Method = "POST";
myReq.ContentLength = data.Length;
myReq.Accept = "application/json";
myReq.ContentType = "application/json";
myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(username)));
UTF8Encoding enc = new UTF8Encoding();
using (Stream ds = myReq.GetRequestStream())
{
ds.Write(enc.GetBytes(data), 0, data.Length);
}
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
Response.Write(content);