private TransactionInfo paytrailRegisterCall() { try { showLoader(); var client = new HttpClient(); client.BaseAddress = new Uri(merchantBaseUrlTest); string paytrailRequest = "{\"amount\":{\"currencyCode\":\"EUR\",\"totalAmount\":1000,\"vatAmount\":0},\"customerAddress1\":\"Testaddress\",\"customerCountry\":\"FI\",\"customerEmail\":\"[email protected]\",\"customerFirstName\":\"Bill\",\"customerId\":\"000012\",\"customerLastName\":\"Buyer\",\"customerPostCode\":\"00510\",\"customerTown\":\"Helsinki\",\"method\":{\"id\":\"PaytrailNordea\"},\"storeCard\":false,\"orderNumber\":" + getPaytrailOrderNumber() + "}"; var content = new StringContent(paytrailRequest, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(merchantIdTest + "/register", content).Result; if (response.IsSuccessStatusCode) { string result = response.Content.ReadAsStringAsync().Result; if (result != null) { PaymentRegisterResponse paymentRegisterResponse = JsonConvert.DeserializeObject <PaymentRegisterResponse>(result); cancelLoader(); return(new TransactionInfo(paymentRegisterResponse.transactionId, paymentRegisterResponse.redirectOK)); } cancelLoader(); return(null); } cancelLoader(); return(null); } catch (Java.Lang.Exception ex) { cancelLoader(); return(null); } }
TransactionInfo IRegisterPaymentHandler.DoRegisterPaymentRequest(bool p0) { try { var client = new HttpClient(); client.BaseAddress = new Uri(baseUrl); string jsonData; if (payMode.Equals(PaymentMode.NEW_CARD.ToString())) { jsonData = "{\"storeCard\":true,\"orderNumber\":\"PiaSDK-Android\",\"customerId\":\"000003\",\"amount\":{\"currencyCode\":\"EUR\",\"totalAmount\":\"100\",\"vatAmount\":0}}"; } else if (payMode.Equals(PaymentMode.SAVED_CARD.ToString())) { jsonData = "{\"customerId\":\"000012\",\"orderNumber\":\"PiaSDK-Android\",\"amount\":{\"currencyCode\":\"EUR\",\"vatAmount\":0,\"totalAmount\":\"1000\"},\"method\":{\"id\":\"EasyPayment\",\"displayName\":\"\",\"fee\":\"\"},\"cardId\":\"492500******0004\",\"storeCard\":true,\"merchantId\":\"\",\"token\":\"\",\"serviceTyp\":\"\",\"paymentMethodActionList\":\"\",\"phoneNumber\":\"\",\"currencyCode\":\"\",\"redirectUrl\":\"\",\"language\":\"\"}"; } else if (payMode.Equals(PaymentMode.SAVED_CARD_SKIP.ToString())) { jsonData = "{\"amount\":{\"currencyCode\":\"SEK\",\"totalAmount\":1000,\"vatAmount\":0},\"cardId\":\"492500******0004\",\"customerId\":\"000012\",\"method\":{\"id\":\"EasyPayment\"},\"orderNumber\":\"PiaSDK-Android\",\"storeCard\":false}"; } else if (payMode.Equals(PaymentMode.VIPPS.ToString())) { jsonData = "{\"amount\":{\"currencyCode\":\"NOK\",\"totalAmount\":1000,\"vatAmount\":0},\"customerId\":\"000013\",\"method\":{\"id\":\"Vipps\"},\"orderNumber\":\"PiaSDK-Android\",\"paymentMethodActionList\":\"[{PaymentMethod:Vipps}]\",\"phoneNumber\":\"+4748059560\",\"redirectUrl\":\"PiaSampleXamarin.PiaSampleXamarin://piasdk\",\"storeCard\":false}"; } else if (payMode.Equals(PaymentMode.PAYPAL.ToString())) { jsonData = "{\"amount\":{\"currencyCode\":\"EUR\",\"totalAmount\":1000,\"vatAmount\":0},\"customerId\":\"000012\",\"method\":{\"id\":\"PayPal\"},\"orderNumber\":\"PiaSDK-Android\",\"storeCard\":false}"; } else { jsonData = "{\"storeCard\":true,\"orderNumber\":\"PiaSDK-Android\",\"customerId\":\"000003\",\"amount\":{\"currencyCode\":\"EUR\",\"totalAmount\":\"100\",\"vatAmount\":0}}"; } var content = new StringContent(jsonData, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(merchantId + "/register", content).Result; if (response.IsSuccessStatusCode) { string result = response.Content.ReadAsStringAsync().Result; if (result != null) { PaymentRegisterResponse paymentRegisterResponse = JsonConvert.DeserializeObject <PaymentRegisterResponse>(result); if (payMode.Equals(PaymentMode.VIPPS.ToString()) || payMode.Equals(PaymentMode.SWISH.ToString())) { return(new TransactionInfo(paymentRegisterResponse.walletUrl)); } else { return(new TransactionInfo(paymentRegisterResponse.transactionId, paymentRegisterResponse.redirectOK)); } } return(null); } return(null); } catch (Java.Lang.Exception ex) { return(null); } }
public void RegisterPayment(IWalletURLCallback callback) { Task.Run(async() => { string mobileWalletRequest = "{\"amount\":{\"currencyCode\":\"EUR\",\"totalAmount\":1000,\"vatAmount\":0},\"customerId\":\"000012\",\"method\":{\"id\":\"MobilePay\"},\"orderNumber\":\"PiaSDK-Android\",\"paymentMethodActionList\":\"[{PaymentMethod:MobilePay}]\",\"redirectUrl\":\"PiaSampleXamarin.PiaSampleXamarin://piasdk_mobilepay\",\"storeCard\":false}"; HttpResponseMessage response = makeHttpCall(mobileWalletRequest, merchantIdTest, merchantBaseUrlTest); if (response.IsSuccessStatusCode) { string result = response.Content.ReadAsStringAsync().Result; if (result != null) { PaymentRegisterResponse paymentRegisterResponse = JsonConvert.DeserializeObject <PaymentRegisterResponse>(result); if (paymentRegisterResponse != null && paymentRegisterResponse.walletUrl != null) { Android.Net.Uri uri = Android.Net.Uri.Parse(paymentRegisterResponse.walletUrl); callback.SuccessWithWalletURL(uri); } else { callback.FailureWithError(null); } } } }); }