public async Task <IActionResult> OnPostAddCardAsync() { base.IdentifyCostumer(); var client = new Yandex.Checkout.V3.Client(shopId: Strings.YandexShopId, secretKey: Strings.YandexAPIKey); var newPayment = new NewPayment { Amount = new Amount { Value = 1.00m, Currency = "RUB" }, SavePaymentMethod = true, Confirmation = new Confirmation { Type = ConfirmationType.Redirect, ReturnUrl = $"https://power-now.ru/costumer" }, PaymentMethodData = new PaymentMethod { Type = PaymentMethodType.BankCard }, Description = "Для привязки карты списываем сумму в 1 рубль, которую сразу же вернем на Вашу карту" }; Payment payment = client.CreatePayment(newPayment); string url = payment.Confirmation.ConfirmationUrl; await Costumer.SetOrderId(_appRepository, payment.Id); await Costumer.SetCardStatus(_appRepository, CardsStatus.Progress); return(Redirect(url)); }
protected void submit_YandexPay_Click(object sender, EventArgs e) { if (sum.Text != null) { // string urlpay = "https://apiyandexkassa.azurewebsites.net/ConfirmPay.aspx"; string urlpay = "https://apiyandexkassa.azurewebsites.net/ycheckout.aspx"; float fsum = float.Parse(sum.Text, CultureInfo.InvariantCulture.NumberFormat); string _url = new Yandex.Checkout.V3.Client("501156", "test_As0OONRn1SsvFr0IVlxULxst5DBIoWi_tyVaezSRTEI") .CreatePayment(fsum, "RUB", urlpay).ConfirmationUrl; Response.Redirect(_url); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "POST" && Request.ContentType == "application/json; charset=UTF-8") { string json; using (var reader = new StreamReader(Request.InputStream)) { json = reader.ReadToEnd(); } var _url = new Yandex.Checkout.V3.Client("501156", "test_As0OONRn1SsvFr0IVlxULxst5DBIoWi_tyVaezSRTEI") .PaymentCapture(json); } }
public async Task <IActionResult> OnPostAsync() { using (var stream = new StreamReader(Request.Body)) { var body = stream.ReadToEnd(); Message message = Client.ParseMessage(Request.Method, Request.ContentType, body); var client = new Yandex.Checkout.V3.Client(shopId: Strings.YandexShopId, secretKey: Strings.YandexAPIKey); if (message.Event == Event.RefundSucceeded) { return(JsonHelper.JsonResponse(Strings.StatusOK, Constants.HttpOkCode)); } if (message.Event == Event.PaymentSucceeded && message.Object.Amount.Value == 1.00m) { try { var refund = client.CreateRefund(new NewRefund { PaymentId = message.Object.Id, Amount = message.Object.Amount }); } catch { } var costumer = await CostumerModel.GetCostumerByOrderId(_appRepository, message.Object.Id); if (costumer == null) { return(JsonHelper.JsonResponse(Strings.StatusError, Constants.HttpClientErrorCode, "Wrong OrderId")); } await costumer.SetCardStatus(_appRepository, CardsStatus.Ok); await costumer.AddBinding(_appRepository, new CardBindingModel { BindingId = message.Object.Id, FirstDigits = message.Object.PaymentMethod.Card.First6, LastDigits = message.Object.PaymentMethod.Card.Last4, PaymentSystemName = message.Object.PaymentMethod.Card.CardType }); } return(JsonHelper.JsonResponse(Strings.StatusOK, Constants.HttpOkCode)); } }