public async Task CreatePaymentRequest() { using (var cert = Helper.GetX509Certificate2(CertTlsName, CertsPath, CertsPass)) { var clientHandler = new HttpClientHandler(); clientHandler.ClientCertificates.Add(cert); clientHandler.ClientCertificateOptions = ClientCertificateOption.Manual; clientHandler.SslProtocols = SslProtocols.Tls12; var paymentRequest = new PaymentRequest { fixedAmount = new FixedAmount { value = 99.95f, currency = "EUR" }, variableAmount = new VariableAmount { minimumValue = 90, maximumValue = 100, suggestedValue = 99.95f, currency = "EUR" }, validUntil = "2021-3-15T00:00:00.000+01:00", maximumAllowedPayments = 10, maximumReceivableAmount = new FixedAmount { value = 100, currency = "EUR" }, purchaseId = "abcdefg1234567890", description = "Your purchase reference abcdefg1234567890", returnUrl = "https://www.webshop.com/return?purchaseId=abcdefg1234567890" }; using (var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(paymentRequest), Encoding.UTF8, "application/json")) using (var client = new HttpClient(clientHandler)) { var request = new HttpRequestMessage(HttpMethod.Post, $"{HttpHost}/payment-requests"); request.Content = content; request.AddHeadersWithAccessToken(Helper.GetX509Certificate2(CertSignName, CertsPath, CertsPass), await content.DigestValue(), "/payment-requests", KeyId, AccessToken); using (HttpResponseMessage response = await client.SendAsync(request)) { var responseContent = await response.Content.ReadAsStringAsync(); System.Console.WriteLine(responseContent); } } } }
public async Task RegisterMarchant() { using (var cert = Helper.GetX509Certificate2(CertTlsName, CertsPath, CertsPass)) { var clientHandler = new HttpClientHandler(); clientHandler.ClientCertificates.Add(cert); clientHandler.ClientCertificateOptions = ClientCertificateOption.Manual; clientHandler.SslProtocols = SslProtocols.Tls12; var merchant = new Merchant { merchantId = "991234567", merchantSubId = "993456", merchantName = "Repcak sp. z o.o.", merchantIBAN = "NL26INGB0003275331", merchantLogo = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAW0lEQVR42mJgYGDYC8L///9ngLKPAXEgiI+MQQBE/ody/iPhM0jsCnwKYXg7IRNhWB2bwu1AfA+IL+E1Ec3xukiKSxmhDJAkIwMewMRAJCBaIQsQ7yBGIUCAAQDZgFqi05MKyQAAAABJRU5ErkJggg==", dailyReceivableLimit = new DailyReceivableLimit { value = 50000.00F, currency = "EUR" }, allowIngAppPayments = "Y" }; using (var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(merchant), Encoding.UTF8, "application/json")) using (var client = new HttpClient(clientHandler)) { var request = new HttpRequestMessage(HttpMethod.Post, $"{HttpHost}/payment-requests/registrations"); request.Content = content; request.AddHeadersWithAccessToken(Helper.GetX509Certificate2(CertSignName, CertsPath, CertsPass), await content.DigestValue(), "/payment-requests/registrations", KeyId, AccessToken); System.Console.WriteLine($"===========REQUEST========\n{request}"); using (HttpResponseMessage response = await client.SendAsync(request)) { System.Console.WriteLine($"===========RESPONSe========\n{response}"); var responseContent = await response.Content.ReadAsStringAsync(); System.Console.WriteLine(responseContent); } } } }