コード例 #1
0
        private OrderRequest CreateOrderRequest(AppZeroAPI.Entities.CustomerOrder order)
        {
            var request = new OrderRequest
            {
                ApplicationContext    = m_ApplicationContext,
                CheckoutPaymentIntent = "CAPTURE"
            };
            var purchaseUnitRequest = new PurchaseUnitRequest
            {
                InvoiceId           = order.rec_id.ToString(),
                AmountWithBreakdown = new AmountWithBreakdown
                {
                    Value           = order.order_total.ToString("f2", CultureInfo.InvariantCulture),
                    CurrencyCode    = "EUR",
                    AmountBreakdown = new AmountBreakdown
                    {
                        ItemTotal = new Money
                        {
                            Value        = order.order_total.ToString("f2", CultureInfo.InvariantCulture),
                            CurrencyCode = "EUR"
                        }
                    }
                }
            };

            request.PurchaseUnits = new List <PurchaseUnitRequest>()
            {
                purchaseUnitRequest
            };
            return(request);
        }
コード例 #2
0
        private async Task <ActionResult> PayWithStripeElements([FromBody]  AppZeroAPI.Entities.CustomerOrder order)
        {
            // Read Stripe API key from config
            StripeConfiguration.ApiKey = StripeOptions.SecretKey;

            var paymentIntentCreateOptions = new PaymentIntentCreateOptions
            {
                Customer           = StripeCustomer(order).Id,
                Amount             = Convert.ToInt32(order.total_payable),
                Currency           = "usd",
                PaymentMethodTypes = new List <string> {
                    "card"
                },
                Description         = "Bestilling fra Losvik kommune",
                ReceiptEmail        = order.customer.email,
                StatementDescriptor = "Losvik kommune",
                Metadata            = new Dictionary <String, String>()
                {
                    { "OrderId", order.order_id.ToString() }
                }
            };

            var service = new PaymentIntentService();
            var intent  = await service.CreateAsync(paymentIntentCreateOptions);

            return(Ok(intent));
        }
コード例 #3
0
        //public void PaypalService()
        //{

        //    string SiteUrl = "http://www.appzero.com/api/payments/";
        //    var environment = new LiveEnvironment(ClientId, ClientSecret);
        //    m_PayPalHttpClient = new PayPalHttpClient(environment);
        //    m_ApplicationContext = new ApplicationContext
        //    {
        //        BrandName = "Naobiz",
        //        ReturnUrl =  SiteUrl + "comporder",
        //        CancelUrl =  SiteUrl + "canorder"
        //    };
        //    m_TaxRate = 5.5M ;
        //}

        public async Task <string> CreateOrder(AppZeroAPI.Entities.CustomerOrder order)
        {
            var request = new OrdersCreateRequest();

            request.Prefer("return=representation");
            request.RequestBody(CreateOrderRequest(order));
            var response = await m_PayPalHttpClient.Execute(request);

            var order2 = response.Result <PayPalCheckoutSdk.Orders.Order>();

            order.paypal_token = order2.Id;
            var link = order2.Links.Single(link => link.Rel == "approve");

            return(link.Href);
        }
コード例 #4
0
        private Stripe.Customer StripeCustomer([FromBody]  AppZeroAPI.Entities.CustomerOrder order)
        {
            var options = new CustomerCreateOptions
            {
                Name             = order.customer.first_name + " " + order.customer.last_name,
                Email            = order.customer.email,
                Phone            = order.customer.contact_mobile,
                PreferredLocales = new List <string> {
                    "nb", "en"
                }
            };

            var service  = new CustomerService();
            var customer = service.Create(options);

            return(customer);
        }
コード例 #5
0
 private Task <ActionResult> PayWithStripeBilling(AppZeroAPI.Entities.CustomerOrder order)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
        private Task <ActionResult> PayWithVipps([FromBody]  AppZeroAPI.Entities.CustomerOrder order)
        {
            throw new NotImplementedException();

            // return BadRequest();
        }