internal YShopPayment(ShopPayment payment)
        {
            ShopPayment = payment;

            if (payment.amount != null)
            {
                amount = new YAmount(payment.amount);
            }

            if (payment.authorization_details != null)
            {
                authorizationDetails = new YShopAuthorizationDetails(payment.authorization_details);
            }

            if (payment.confirmation != null)
            {
                confirmation = new YConfirmation(payment.confirmation);
            }

            if (payment.payment_method != null)
            {
                paymentMethod = new YPaymentMethod(payment.payment_method);
            }

            if (payment.cancellation_details != null)
            {
                cancelationDetails = new YCancelationDetails(payment.cancellation_details);
            }

            if (payment.refunded_amount != null)
            {
                refundedAmount = new YAmount(payment.refunded_amount);
            }
        }
Exemple #2
0
 internal static string Serialize(ShopPayment payment, bool withFormat = false)
 {
     return(JsonConvert.SerializeObject(payment
                                        , withFormat? Formatting.Indented : Formatting.None
                                        , new JsonSerializerSettings
     {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Exemple #3
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());
        }
Exemple #4
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());
        }
        public YShopRequestBuilder(decimal sum, Uri returnUri)
        {
            _payObject = new ShopPayment();

            _payObject.amount = new Amount
            {
                value    = decimal.Round(sum, 2).ToString("#0.00", CultureInfo.InvariantCulture),
                currency = "RUB"
            };

            _payObject.confirmation = new Confirmation {
                type       = "redirect",
                return_url = returnUri.ToString()
            };
        }
Exemple #6
0
        private static YShopAnswer CreateAnswer(ShopPayment payment, Exception exception = null)
        {
            var success = exception == null && payment != null && payment.type == null;

            var result = new YShopAnswer
            {
                Success = success,
                Payment = success ? new YShopPayment(payment) : null,
                Error   = success
                    ? null
                    : new YShopError
                {
                    Code        = payment == null ? "execute_error" : payment.code,
                    Description = payment == null
                            ? exception == null ? "" : exception.Message
                            : payment.description
                }
            };

            return(result);
        }
 public string ToString(bool isFormatting)
 {
     return(ShopPayment.ToString(isFormatting));
 }
 public override string ToString()
 {
     return(ShopPayment.ToString());
 }