Beispiel #1
0
        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());
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public Task <YShopAnswer> CapturePaymentAsync(YShopPayment payment, decimal?captureSum = null)
 {
     return(Task.Run(() => CapturePayment(payment, captureSum)));
 }
Beispiel #6
0
 public Task <YShopAnswer> CancelPaymentAsync(YShopPayment payment)
 {
     return(Task.Run(() => CancelPayment(payment)));
 }