コード例 #1
0
        public MerchantOrder.Builder GetOrder(int orderId)
        {
            CustomerInformation customerInformation = new CustomerInformation.Builder()
                                                      .WithTelephoneNumber("0204971111")
                                                      .WithInitials("J.D.")
                                                      .WithGender(Gender.M)
                                                      .WithEmailAddress("*****@*****.**")
                                                      .WithDateOfBirth("20-03-1987")
                                                      .Build();

            Address shippingDetails = new Address.Builder()
                                      .WithFirstName("John")
                                      .WithLastName("Doe")
                                      .WithStreet("Street")
                                      .WithHouseNumber("5")
                                      .WithHouseNumberAddition("a")
                                      .WithPostalCode("1234AB")
                                      .WithCity("Haarlem")
                                      .WithCountryCode(CountryCode.NL)
                                      .Build();

            Address billingDetails = new Address.Builder()
                                     .WithFirstName("John")
                                     .WithLastName("Doe")
                                     .WithStreet("Factuurstraat")
                                     .WithHouseNumber("5")
                                     .WithHouseNumberAddition("a")
                                     .WithPostalCode("1234AB")
                                     .WithCity("Haarlem")
                                     .WithCountryCode(CountryCode.NL)
                                     .Build();

            MerchantOrder.Builder order = new MerchantOrder.Builder()
                                          .WithMerchantOrderId(Convert.ToString(orderId))
                                          .WithDescription("An example description")
                                          .WithCustomerInformation(customerInformation)
                                          .WithShippingDetail(shippingDetails)
                                          .WithBillingDetail(billingDetails)
                                          .WithLanguage(Language.NL)
                                          .WithMerchantReturnURL(RETURN_URL)
                                          .WithInitiatingParty("LIGHTSPEED");

            return(order);
        }
コード例 #2
0
        public MerchantOrder GetOrder()
        {
            Money itemAmount = Money.FromDecimal(Currency.EUR, 99.99m);
            Money itemTax    = Money.FromDecimal(Currency.EUR, 4.99m);

            OrderItem orderItem = new OrderItem.Builder()
                                  .WithId("1")
                                  .WithQuantity(1)
                                  .WithName("Test product")
                                  .WithDescription("Description")
                                  .WithAmount(Money.FromDecimal(Currency.EUR, 10m))
                                  .WithTax(Money.FromDecimal(Currency.EUR, 1m))
                                  .WithItemCategory(ItemCategory.PHYSICAL)
                                  .WithVatCategory(VatCategory.LOW)
                                  .Build();

            CustomerInformation customerInformation = new CustomerInformation.Builder()
                                                      .WithTelephoneNumber("0204971111")
                                                      .WithInitials("J.D.")
                                                      .WithGender(Gender.M)
                                                      .WithEmailAddress("*****@*****.**")
                                                      .WithDateOfBirth("20-03-1987")
                                                      .Build();

            Address shippingDetails = new Address.Builder()
                                      .WithFirstName("John")
                                      .WithLastName("Doe")
                                      .WithStreet("Street")
                                      .WithHouseNumber("5")
                                      .WithHouseNumberAddition("a")
                                      .WithPostalCode("1234AB")
                                      .WithCity("Haarlem")
                                      .WithCountryCode(CountryCode.NL)
                                      .Build();

            Address billingDetails = new Address.Builder()
                                     .WithFirstName("John")
                                     .WithLastName("Doe")
                                     .WithStreet("Factuurstraat")
                                     .WithHouseNumber("5")
                                     .WithHouseNumberAddition("a")
                                     .WithPostalCode("1234AB")
                                     .WithCity("Haarlem")
                                     .WithCountryCode(CountryCode.NL)
                                     .Build();

            MerchantOrder order = new MerchantOrder.Builder()
                                  .WithMerchantOrderId("ORDID123")
                                  .WithDescription("An example description")
                                  .WithOrderItems(new List <OrderItem>(new OrderItem[] { orderItem }))
                                  .WithAmount(Money.FromDecimal(Currency.EUR, 99.99m))
                                  .WithCustomerInformation(customerInformation)
                                  .WithShippingDetail(shippingDetails)
                                  .WithBillingDetail(billingDetails)
                                  .WithLanguage(Language.NL)
                                  .WithMerchantReturnURL(RETURN_URL)
                                  .WithPaymentBrand(PaymentBrand.IDEAL)
                                  .WithPaymentBrandForce(PaymentBrandForce.FORCE_ONCE)
                                  .WithInitiatingParty("LIGHTSPEED")
                                  .Build();

            return(order);
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var order    = postProcessPaymentRequest.Order;
            var customer = order.Customer;


            var rokOrderItems = new List <OmniKassa.Model.Order.OrderItem>();

            foreach (var orderItem in order.OrderItems)
            {
                decimal amount = Decimal.Round(orderItem.UnitPriceInclTax, 2);
                decimal tax    = Decimal.Round(orderItem.UnitPriceInclTax - orderItem.UnitPriceExclTax, 2);

                var rokOrderItem = new OmniKassa.Model.Order.OrderItem.Builder()
                                   .WithId(orderItem.OrderItemGuid.ToString())
                                   .WithQuantity(orderItem.Quantity)
                                   .WithName(orderItem.Product.Name)
                                   .WithDescription(orderItem.Product.ShortDescription)
                                   .WithAmount(Money.FromDecimal(OmniKassa.Model.Enums.Currency.EUR, amount))
                                   .WithTax(Money.FromDecimal(OmniKassa.Model.Enums.Currency.EUR, tax))
                                   .WithItemCategory(ItemCategory.PHYSICAL)
                                   .WithVatCategory(VatCategory.LOW)
                                   .Build();

                rokOrderItems.Add(rokOrderItem);
            }

            CustomerInformation rokCustomerInformation = new CustomerInformation.Builder()
                                                         .WithTelephoneNumber(customer.BillingAddress.PhoneNumber)
                                                         .WithEmailAddress(customer.Email)
                                                         .Build();

            Address rokShippingDetails = new Address.Builder()
                                         .WithFirstName(customer.ShippingAddress.FirstName)
                                         .WithLastName(customer.ShippingAddress.LastName)
                                         .WithStreet(customer.ShippingAddress.Address1)
                                         .WithHouseNumber(customer.ShippingAddress.Address2)
                                         .WithPostalCode(customer.ShippingAddress.ZipPostalCode)
                                         .WithCity(customer.ShippingAddress.City)
                                         .WithCountryCode(CountryCode.NL)
                                         .Build();

            Address rokBillingDetails = new Address.Builder()
                                        .WithFirstName(customer.BillingAddress.FirstName)
                                        .WithLastName(customer.BillingAddress.LastName)
                                        .WithStreet(customer.BillingAddress.Address1)
                                        .WithHouseNumber(customer.BillingAddress.Address2)
                                        .WithPostalCode(customer.BillingAddress.ZipPostalCode)
                                        .WithCity(customer.BillingAddress.City)
                                        .WithCountryCode(CountryCode.NL)
                                        .Build();

            var rokOrder = new MerchantOrder.Builder()
                           .WithMerchantOrderId(order.CustomOrderNumber)
                           .WithDescription(order.CustomOrderNumber)
                           .WithOrderItems(rokOrderItems)
                           .WithAmount(Money.FromDecimal(OmniKassa.Model.Enums.Currency.EUR, Decimal.Round(order.OrderTotal, 2)))
                           .WithCustomerInformation(rokCustomerInformation)
                           .WithShippingDetail(rokShippingDetails)
                           .WithBillingDetail(rokBillingDetails)
                           .WithLanguage(Language.NL)
                           .WithMerchantReturnURL(GetReturnUrl())
                           .Build();

            String redirectUrl = _raboOmniKassaPaymentManager.AnnounceMerchantOrder(rokOrder);

            Debug.WriteLine(redirectUrl);

            _httpContextAccessor.HttpContext.Response.Redirect(redirectUrl);
        }