private static string GeneratePartialCaptureDataString(YShopPayment payment, decimal?captureSumValue) { var result = new ShopPayment { amount = new Amount { value = decimal.Round(captureSumValue ?? payment.YAmount.Value, 2) .ToString(CultureInfo.InvariantCulture), currency = payment.YAmount.Currency } }; return(result.ToString()); }
private static string GenerateRefundDataString(YShopPayment payment, decimal?refundSum) { var result = new ShopPayment { amount = new Amount { value = decimal.Round(refundSum ?? payment.YAmount.Value, 2) .ToString(CultureInfo.InvariantCulture), currency = payment.YAmount.Currency }, payment_id = payment.Id.ToString() }; return(result.ToString()); }
public YShopAnswer CancelPayment(YShopPayment payment) { if (payment == null || payment.Status != YPaymentStatus.waiting_for_capture) { return(new YShopAnswer { Success = true, Error = null, Payment = payment }); } var url = string.Format((RequestUrl + CancelUrlPart), payment.Id.ToString().ToLower()); var result = Execute(url, null); return(result); }
public YShopAnswer CapturePayment(YShopPayment payment, decimal?captureSum = null) { if (payment == null || payment.Status != YPaymentStatus.waiting_for_capture) { return(new YShopAnswer { Success = true, Error = null, Payment = payment }); } var url = string.Format((RequestUrl + ConfirmUrlPart), payment.Id.ToString().ToLower()); var data = GeneratePartialCaptureDataString(payment, captureSum); var result = Execute(url, data); return(result); }
public Task <YShopAnswer> CapturePaymentAsync(YShopPayment payment, decimal?captureSum = null) { return(Task.Run(() => CapturePayment(payment, captureSum))); }
public Task <YShopAnswer> CancelPaymentAsync(YShopPayment payment) { return(Task.Run(() => CancelPayment(payment))); }