Exemplo n.º 1
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client client = new Client(connector);
                IOrder order  = client.NewOrder(orderId);

                UpdateMerchantReferences updateMerchantReferences = new UpdateMerchantReferences()
                {
                    MerchantReference1 = "15632423",
                    MerchantReference2 = "special order"
                };

                try
                {
                    order.UpdateMerchantReferences(updateMerchantReferences);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 2
0
        private PostProcessPaymentResult NewRegisterKlarnaOrder(PostProcessPaymentEvaluationContext context)
        {
            var retVal = new PostProcessPaymentResult();

            var connector = ConnectorFactory.Create(
                AppKey,
                AppSecret,
                Client.TestBaseUrl);

            Client    client    = new Client(connector);
            var       order     = client.NewOrder(context.OuterId);
            OrderData orderData = order.Fetch();

            if (orderData.Status != "CAPTURED")
            {
                var capture = client.NewCapture(order.Location);

                CaptureData captureData = new CaptureData()
                {
                    CapturedAmount = orderData.OrderAmount,
                    Description    = "All order items is shipped",
                    OrderLines     = orderData.OrderLines
                };

                capture.Create(captureData);
                orderData = order.Fetch();
            }

            retVal.IsSuccess        = orderData.Status == "CAPTURED";
            retVal.NewPaymentStatus = retVal.IsSuccess ? PaymentStatus.Paid : PaymentStatus.Pending;
            retVal.OrderId          = context.Order.Id;

            return(retVal);
        }
Exemplo n.º 3
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderID      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client = new Client(connector);
                ICheckoutOrder order  = client.NewCheckoutOrder(orderID);

                try
                {
                    CheckoutOrderData orderData = order.Fetch();
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 4
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";
                string       captureId    = "34567";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client   client  = new Client(connector);
                IOrder   order   = client.NewOrder(orderId);
                ICapture capture = client.NewCapture(order.Location, captureId);

                try
                {
                    capture.TriggerSendOut();
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 5
0
        public void SetUp()
        {
            this.httpWebRequest = (HttpWebRequest)WebRequest.Create(this.baseUrl);
            this.requestMock    = MockRepository.GenerateStub <IRequestFactory>();

            this.connector = ConnectorFactory.Create(this.requestMock, this.merchantId, this.secret, this.userAgent, this.baseUrl);
            this.capture   = new Klarna.Rest.OrderManagement.Capture(this.connector, this.orderUrl, "1002");
        }
Exemplo n.º 6
0
        public void SetUp()
        {
            this.httpWebRequest = (HttpWebRequest)WebRequest.Create(this.baseUrl);
            this.requestMock    = MockRepository.GenerateStub <IRequestFactory>();

            this.connector     = ConnectorFactory.Create(this.requestMock, this.merchantId, this.secret, this.userAgent, this.baseUrl);
            this.checkoutOrder = new Klarna.Rest.Checkout.CheckoutOrder(this.connector, null);
        }
        public void Transport_ConnectorFactory_CreateAdvanced()
        {
            RequestFactory requests  = new RequestFactory();
            IConnector     connector = ConnectorFactory.Create(requests, "id", "secret", UserAgent.WithDefaultFields(), Client.EuTestBaseUrl);

            Assert.NotNull(connector);
            Assert.AreEqual(connector.UserAgent.ToString(), UserAgent.WithDefaultFields().ToString());
        }
Exemplo n.º 8
0
        public PostMessageResponse Post(PostMessageRequest request)
        {
            this.ValidatePostMessageRequest(request);
            IConnector facebookConnector = ConnectorFactory.Create(ConnectorType.Facebook);

            facebookConnector.Post <PostMessageRequest, PostMessageResponse>(string.Empty, request);
            return(new PostMessageResponse());
        }
Exemplo n.º 9
0
 public void SetUp()
 {
     this.requestMock = MockRepository.GenerateStub <IRequestFactory>();
     this.merchantId  = "merchantId";
     this.secret      = "secret";
     this.userAgent   = UserAgent.WithDefaultFields();
     this.baseUrl     = new Uri("https://dummytesturi.test");
     this.connector   = ConnectorFactory.Create(this.requestMock, this.merchantId, this.secret, this.userAgent, this.baseUrl);
 }
Exemplo n.º 10
0
        private async Task Connect()
        {
            ConnectorFactory connectorFactory = new ConnectorFactory();

            connectorFactory.Encrypt = true;
            Connector connector = connectorFactory.Create();

            using Transporter transporter = await connector.Execute(cancellationTokenSource.Token);

            await transporter.Write(this, cancellationTokenSource.Token);
        }
Exemplo n.º 11
0
        public Client GetClient(IMarket market)
        {
            if (PaymentMethodDto != null)
            {
                var connectionConfiguration = GetCheckoutConfiguration(market);
                var connector = ConnectorFactory.Create(connectionConfiguration.Username, connectionConfiguration.Password, new Uri(connectionConfiguration.ApiUrl));
                connector.UserAgent.AddField("Platform", "EPiServer", typeof(EPiServer.Core.IContent).Assembly.GetName().Version.ToString(), new string[0]);
                connector.UserAgent.AddField("Module", "Klarna.Checkout", typeof(Klarna.Checkout.KlarnaCheckoutService).Assembly.GetName().Version.ToString(), new string[0]);

                _client = new Client(connector);
            }
            return(_client);
        }
Exemplo n.º 12
0
        internal static IOrganizationService ConnectionCrm()
        {
            ConnectorFactory connector  = new ConnectorFactory();
            ConnectionData   connection = new ConnectionData
            {
                Login    = AppSettings.CrmLogin,
                Password = AppSettings.CrmPassword,
                Url      = AppSettings.CrmUrlAuth
            };
            IOrganizationService orgSvc = connector.Create(connection, ConnectorFactory.Developer.Metrium);

            return(orgSvc);
        }
Exemplo n.º 13
0
        private async Task Connect()
        {
            ConnectorFactory connectorFactory = new ConnectorFactory();

            connectorFactory.Uri = new Uri(webSockets ? "ws://localhost:5001/" : "tcp://127.0.0.1:7000");
            for (int i = 0; i < Connections; i++)
            {
                DataPacket  dataPacket  = dataPackets[0][i];
                Connector   connector   = connectorFactory.Create();
                Transporter transporter = await connector.Execute(cancellationTokenSource.Token);

                tasks.Add(transporter, Send(transporter, dataPacket));
            }
        }
Exemplo n.º 14
0
        protected virtual void Initialize()
        {
            if (this.Verbose)
            {
                this.LoggingService.WriteLine("\nOpening Source Database Connection...");
            }

            this.SourceDatabase = ConnectorFactory.Create(this.Configuration.SourceDatabase.DatabaseType);
            this.SourceDatabase.Initialize(this.Configuration.SourceDatabase.ConnectionString);

            if (this.Verbose)
            {
                this.LoggingService.WriteLine("Source Database Connection openend.");
            }
        }
Exemplo n.º 15
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client client = new Client(connector);
                IOrder order  = client.NewOrder(orderId);

                List <OrderLine> lines = new List <OrderLine>();

                lines.Add(new OrderLine()
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 5,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 3000,
                    TotalTaxAmount = 600
                });

                Refund refund = new Refund()
                {
                    RefundedAmount = 3000,
                    Description    = "Refunding half the tomatoes",
                    OrderLines     = lines
                };

                try
                {
                    order.Refund(refund);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 16
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client client = new Client(connector);
                IOrder order  = client.NewOrder(orderId);

                List <OrderLine> lines = new List <OrderLine>();

                lines.Add(new OrderLine()
                {
                    Type           = "physical",
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                });

                UpdateAuthorization updateAuthorization = new UpdateAuthorization()
                {
                    OrderAmount = 6000,
                    Description = "Removed bad bananas",
                    OrderLines  = lines
                };

                try
                {
                    order.UpdateAuthorization(updateAuthorization);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 17
0
        private async Task Connect()
        {
            ConnectorFactory connectorFactory = new ConnectorFactory();

            connectorFactory.Uri = new Uri(webSockets ? "ws://localhost:5001/" : "tcp://127.0.0.1:7000");
            for (int i = 0; i < Connections; i++)
            {
                Connector   connector   = connectorFactory.Create();
                Transporter transporter = await connector.Execute(cancellationTokenSource.Token);

                PingPacket pingPacket = new PingPacket(Bytes, Iterations);
                tasks.Add(ExecuteRead(transporter, pingPacket));
                tasks.Add(ExecuteWrite(transporter, pingPacket));
                transporters.Add(transporter);
            }
        }
Exemplo n.º 18
0
        private ProcessPaymentResult NewCreateKlarnaOrder(KlarnaLocalization localization, ProcessPaymentEvaluationContext context)
        {
            var retVal = new ProcessPaymentResult();

            var orderLineItems = GetOrderLineItems(context.Order);

            MerchantUrls merchantUrls = new MerchantUrls
            {
                Terms = new System.Uri(
                    string.Format("{0}/{1}", context.Store.Url, TermsUrl)),
                Checkout = new System.Uri(
                    string.Format("{0}/{1}", context.Store.Url, CheckoutUrl)),
                Confirmation = new System.Uri(
                    string.Format("{0}/{1}?sid=123&orderId={2}&", context.Store.Url, ConfirmationUrl, context.Order.Id) + "klarna_order={checkout.order.uri}"),
                Push = new System.Uri(
                    string.Format("{0}/{1}?sid=123&orderId={2}&", context.Store.Url, "admin/api/paymentcallback", context.Order.Id) + "klarna_order={checkout.order.uri}")
            };

            CheckoutOrderData orderData = new CheckoutOrderData()
            {
                PurchaseCountry  = localization.CountryName,
                PurchaseCurrency = localization.Currency,
                Locale           = localization.Locale,
                OrderAmount      = (int)(context.Order.Sum * 100),
                OrderTaxAmount   = (int)(context.Order.Tax * 100),
                OrderLines       = orderLineItems,
                MerchantUrls     = merchantUrls
            };

            var connector = ConnectorFactory.Create(
                AppKey,
                AppSecret,
                Client.TestBaseUrl);
            Client client = new Client(connector);

            var checkout = client.NewCheckoutOrder();

            checkout.Create(orderData);

            orderData               = checkout.Fetch();
            retVal.IsSuccess        = true;
            retVal.NewPaymentStatus = PaymentStatus.Pending;
            retVal.OuterId          = orderData.OrderId;
            retVal.HtmlForm         = string.Format("<div>{0}</div>", orderData.HtmlSnippet);

            return(retVal);
        }
Exemplo n.º 19
0
        public virtual IKlarnaOrderService Create(ConnectionConfiguration connectionConfiguration)
        {
            var client = new Client(ConnectorFactory.Create(connectionConfiguration.Username, connectionConfiguration.Password, new Uri(connectionConfiguration.ApiUrl)));

            var byteArray  = Encoding.ASCII.GetBytes($"{connectionConfiguration.Username}:{connectionConfiguration.Password}");
            var httpClient = new HttpClient
            {
                BaseAddress = new Uri(connectionConfiguration.ApiUrl)
            };

            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

            httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Platform", $"EPiServer_{typeof(EPiServer.Core.IContent).Assembly.GetName().Version.ToString()}"));
            httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Module", $"Klarna.OrderManagement_{typeof(Klarna.OrderManagement.KlarnaOrderService).Assembly.GetName().Version.ToString()}"));

            return(new KlarnaOrderService(client, RestService.For <IKlarnaOrderServiceApi>(httpClient)));
        }
Exemplo n.º 20
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";
                string       captureId    = "34567";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client   client  = new Client(connector);
                IOrder   order   = client.NewOrder(orderId);
                ICapture capture = client.NewCapture(order.Location, captureId);

                ShippingInfo shippingInfo = new ShippingInfo
                {
                    ShippingCompany       = "DHL",
                    ShippingMethod        = "Home",
                    TrackingUri           = new Uri("http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=1234567890"),
                    TrackingNumber        = "1234567890",
                    ReturnTrackingNumber  = "E-55-KL",
                    ReturnShippingCompany = "DHL",
                    ReturnTrackingUri     = new Uri("http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=98389222")
                };

                AddShippingInfo addShippingInfo = new AddShippingInfo();

                addShippingInfo.ShippingInfo = new List <ShippingInfo>()
                {
                    shippingInfo
                };

                try
                {
                    capture.AddShippingInfo(addShippingInfo);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        public override void Execute(TaskArgument <System.Web.HttpApplication> arg)
        {
            if (!this.IsValid(arg.Type))
            {
                return;
            }
            ILogger      logger   = IoC.Container.Resolve <ILogger>();
            string       baseUri  = Configuration.Current.Setting.BaseUri;
            IList <Type> handlers = AssemblyHelper.GetTypes <RemoteEventSubcriberHandler>().ToList();
            IList <EventRegistration> registrations = EventHelper.GetSubcriberRequests(handlers);
            IConnector restConnector = ConnectorFactory.Create(ConnectorType.REST);

            foreach (EventRegistration registration in registrations)
            {
                string fullUri = String.Format("{0}/{1}", baseUri, registration.Uri);
                RegisterEventSubcriber subcriberEvent = new RegisterEventSubcriber(registration.EventClassName, registration.ModuleName, fullUri);
                restConnector.Post <RegisterEventSubcriber, string>(Configurations.Configuration.Current.MessageBus.RegisterEventSubciberUri, subcriberEvent);
                logger.Info("Register uri \'{0}\' to \'{1}\'", subcriberEvent, Configurations.Configuration.Current.MessageBus.RegisterEventSubciberUri);
            }
        }
Exemplo n.º 22
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client client = new Client(connector);
                IOrder order  = client.NewOrder(orderId);

                UpdateCustomerDetails updateCustomerDetails = new UpdateCustomerDetails()
                {
                    ShippingAddress = new Address()
                    {
                        Email = "*****@*****.**",
                        Phone = "57-3895734"
                    },

                    BillingAddress = new Address()
                    {
                        Email = "*****@*****.**",
                        Phone = "57-3895734"
                    }
                };

                try
                {
                    order.UpdateCustomerDetails(updateCustomerDetails);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 23
0
        public void Execute(App.MessageBus.Event.MessageBus.OnMessageBusCreated ev)
        {
            ILogger logger = IoC.Container.Resolve <ILogger>();
            IEventSubcriberRepository subcriberRepo = IoC.Container.Resolve <IEventSubcriberRepository>();

            IList <EventSubcriber> subcribers = subcriberRepo.GetAllActive(ev.Key);
            IConnector             connector  = ConnectorFactory.Create(Common.ConnectorType.REST);

            foreach (EventSubcriber subcriber in subcribers)
            {
                try
                {
                    connector.Post <bool>(subcriber.Uri, ev.Content);
                    logger.Info("'{0}' was sent to '{1}' at '{2}' with parameters '{3}'", ev.Key, subcriber.Uri, DateTime.UtcNow, ev.Content);
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }
        }
Exemplo n.º 24
0
        protected override void Initialize()
        {
            base.Initialize();

            if (this.Verbose)
            {
                this.LoggingService.WriteLine("\nOpening Destination Database Connection...");
            }

            this.DestinationDatabase = ConnectorFactory.Create(this.Configuration.DestinationDatabase.DatabaseType);
            this.DestinationDatabase.Initialize(this.Configuration.DestinationDatabase.ConnectionString);

            if (!this.DestinationDatabase.IsOpen())
            {
                this.DestinationDatabase.Open();
            }

            this.Transaction = this.DestinationDatabase.CreateTransaction();

            if (this.Verbose)
            {
                this.LoggingService.WriteLine("Destination Database Connection openend.");
            }
        }
Exemplo n.º 25
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client   = new Client(connector);
                ICheckoutOrder checkout = client.NewCheckoutOrder();

                OrderLine orderLine = new OrderLine
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                };

                OrderLine orderLine2 = new OrderLine
                {
                    Type                = OrderLineType.Physical,
                    Reference           = "543670",
                    Name                = "Bananas",
                    Quantity            = 1,
                    QuantityUnit        = "bag",
                    UnitPrice           = 5000,
                    TaxRate             = 2500,
                    TotalAmount         = 4000,
                    TotalDiscountAmount = 1000,
                    TotalTaxAmount      = 800
                };

                MerchantUrls merchantUrls = new MerchantUrls
                {
                    Terms        = new Uri("http://www.merchant.com/toc"),
                    Checkout     = new Uri("http://www.merchant.com/checkout?klarna_order_id={checkout.order.id}"),
                    Confirmation = new Uri("http://www.merchant.com/thank-you?klarna_order_id={checkout.order.id}"),
                    Push         = new Uri("http://www.merchant.com/create_order?klarna_order_id={checkout.order.id}")
                };

                CheckoutOrderData orderData = new CheckoutOrderData()
                {
                    PurchaseCountry  = "gb",
                    PurchaseCurrency = "gbp",
                    Locale           = "en-gb",
                    OrderAmount      = 10000,
                    OrderTaxAmount   = 2000,
                    OrderLines       = new List <OrderLine> {
                        orderLine, orderLine2
                    },
                    MerchantUrls = merchantUrls
                };

                try
                {
                    checkout.Create(orderData);
                    orderData = checkout.Fetch();

                    string orderID = orderData.OrderId;
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 26
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderID      = "12345";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client   = new Client(connector);
                ICheckoutOrder checkout = client.NewCheckoutOrder(orderID);

                CheckoutOrderData orderData = new CheckoutOrderData();

                orderData.OrderAmount    = 11000;
                orderData.OrderTaxAmount = 2200;

                List <OrderLine> lines = new List <OrderLine>();

                lines.Add(new OrderLine()
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                });

                lines.Add(new OrderLine()
                {
                    Type                = OrderLineType.Physical,
                    Reference           = "543670",
                    Name                = "Bananas",
                    Quantity            = 1,
                    QuantityUnit        = "bag",
                    UnitPrice           = 5000,
                    TaxRate             = 2500,
                    TotalAmount         = 4000,
                    TotalDiscountAmount = 1000,
                    TotalTaxAmount      = 800
                });

                lines.Add(new OrderLine()
                {
                    Type           = OrderLineType.ShippingFee,
                    Name           = "Express delivery",
                    Quantity       = 1,
                    UnitPrice      = 1000,
                    TaxRate        = 2500,
                    TotalAmount    = 1000,
                    TotalTaxAmount = 200
                });

                orderData.OrderLines = lines;

                try
                {
                    orderData = checkout.Update(orderData);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
Exemplo n.º 27
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client         client   = new Client(connector);
                ICheckoutOrder checkout = client.NewCheckoutOrder();

                OrderLine orderLine = new OrderLine
                {
                    Type           = OrderLineType.Physical,
                    Reference      = "123050",
                    Name           = "Tomatoes",
                    Quantity       = 10,
                    QuantityUnit   = "kg",
                    UnitPrice      = 600,
                    TaxRate        = 2500,
                    TotalAmount    = 6000,
                    TotalTaxAmount = 1200
                };

                OrderLine orderLine2 = new OrderLine
                {
                    Type                = OrderLineType.Physical,
                    Reference           = "543670",
                    Name                = "Bananas",
                    Quantity            = 1,
                    QuantityUnit        = "bag",
                    UnitPrice           = 5000,
                    TaxRate             = 2500,
                    TotalAmount         = 4000,
                    TotalDiscountAmount = 1000,
                    TotalTaxAmount      = 800
                };

                MerchantUrls merchantUrls = new MerchantUrls
                {
                    Terms        = new Uri("http://www.merchant.com/toc"),
                    Checkout     = new Uri("http://www.merchant.com/checkout?klarna_order_id={checkout.order.id}"),
                    Confirmation = new Uri("http://www.merchant.com/thank-you?klarna_order_id={checkout.order.id}"),
                    Push         = new Uri("http://www.merchant.com/create_order?klarna_order_id={checkout.order.id}")
                };

                List <PaymentHistoryFull> purchaseHistoryFull = new List <PaymentHistoryFull>
                {
                    new PaymentHistoryFull
                    {
                        UniqueAccountIdentifier  = "Test Testperson",
                        PaymentOption            = "card",
                        NumberPaidPurchases      = 1,
                        TotalAmountPaidPurchases = 10000,
                        DateOfLastPaidPurchase   = DateTime.Now,
                        DateOfFirstPaidPurchase  = DateTime.Now
                    }
                };

                ExtraMerchantData extraMerchantData = new ExtraMerchantData
                {
                    Body = new ExtraMerchantDataBody
                    {
                        PaymentHistoryFull = purchaseHistoryFull
                    }
                };

                CheckoutOrderData orderData = new CheckoutOrderData()
                {
                    PurchaseCountry  = "gb",
                    PurchaseCurrency = "gbp",
                    Locale           = "en-gb",
                    OrderAmount      = 10000,
                    OrderTaxAmount   = 2000,
                    OrderLines       = new List <OrderLine> {
                        orderLine, orderLine2
                    },
                    MerchantUrls = merchantUrls,
                    Attachment   = extraMerchantData
                };

                try
                {
                    checkout.Create(orderData);
                    orderData = checkout.Fetch();

                    string            orderID = orderData.OrderId;
                    ExtraMerchantData emd     = orderData.Attachment;
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
 public BaseIntegrationTest(string uri)
 {
     this.Application = App.Common.Application.ApplicationFactory.Create <System.Web.HttpApplication>(App.Common.ApplicationType.UnitTest, null);
     this.BaseUrl     = uri;
     this.Connector   = ConnectorFactory.Create(ConnectorType.REST);
 }
 public DatabaseExportFileFormatter(Configuration.Configuration configuration) : base(configuration)
 {
     this.Connector = ConnectorFactory.Create(this.GetDatabaseType());
     this.Connector.Initialize();
     this.FormatProvider = this.Connector.GetCommandFormatProvider();
 }
Exemplo n.º 30
0
 public Managment(string clientEmail, byte[] privateKey)
 {
     this._connector = ConnectorFactory.Create(clientEmail, privateKey);
 }