Пример #1
0
        public static Payment BasePaymentDto2RestApiPayment(this BasePaymentDTO dto,
                                                            BillingEnums.ePaymentAction action,
                                                            BillingEnums.ePaymentMethods method,
                                                            bool keepDecimal,
                                                            RedirectUrls urls        = null,
                                                            Courses entity           = null,
                                                            CRS_Bundles bundleEntity = null,
                                                            Payer payer = null)

        {
            var payment = new Payment
            {
                intent = action.EnumToLowerString(),
                payer  = new Payer
                {
                    payment_method = method.EnumToLowerString()
                },
                transactions = new List <Transaction>
                {
                    dto.PaymentDto2TransactionToken(keepDecimal)
                }
            };

            if (urls != null)
            {
                payment.redirect_urls = urls;
            }

            if (entity != null)
            {
                payment.transactions[0].item_list = new ItemList
                {
                    items = new List <Item>
                    {
                        entity.CourseEntity2PaypalRestApiItem(dto, keepDecimal)
                    }
                };
            }
            else if (bundleEntity != null)
            {
                payment.transactions[0].item_list = new ItemList
                {
                    items = new List <Item>
                    {
                        bundleEntity.BundleEntity2PaypalRestApiItem(dto, keepDecimal)
                    }
                };
            }


            if (payer != null)
            {
                payment.payer = payer;
            }

            return(payment);
        }