Пример #1
0
        static public async Task <FormerPaymentOrderDTO> RequestPaymentOrderData(IPayable payable)
        {
            FormerPaymentOrderDTO paymentOrderData = payable.TryGetFormerPaymentOrderData();

            if (paymentOrderData != null)
            {
                return(paymentOrderData);
            }

            IPaymentOrderProvider provider = ExternalProviders.GetPaymentOrderProvider();

            paymentOrderData = await provider.GeneratePaymentOrder(payable)
                               .ConfigureAwait(false);

            payable.SetFormerPaymentOrderData(paymentOrderData);

            return(paymentOrderData);
        }
Пример #2
0
        static public async Task <FormerPaymentOrderDTO> RefreshPaymentOrder(IPayable payable)
        {
            FormerPaymentOrderDTO paymentOrderData = payable.TryGetFormerPaymentOrderData();

            Assertion.AssertObject(paymentOrderData,
                                   $"Transaction {payable.UID} doesn't have a registered payment order.");

            if (paymentOrderData.IsCompleted)
            {
                return(paymentOrderData);
            }

            IPaymentOrderProvider provider = ExternalProviders.GetPaymentOrderProvider();

            paymentOrderData = await provider.RefreshPaymentOrder(paymentOrderData)
                               .ConfigureAwait(false);

            if (paymentOrderData.IsCompleted)
            {
                payable.SetFormerPaymentOrderData(paymentOrderData);
            }

            return(paymentOrderData);
        }