public void MustBeAbleToReachCreateOrder() { MerchantConfig config = new MerchantConfig("K500746", "fia'w2ahSheahahc", Server.Playground); OrderHandler oh = new OrderHandler(config); MerchantUrls urls = new MerchantUrls(); var lines = new List <PaymentsOrderLine> { new PaymentsOrderLine("test", 1, 1000, 2500) }; PaymentsOrder o = new PaymentsOrder(lines, urls); oh.CreateOrder("3eaeb557-5e30-47f8-b840-b8d987f5945d", o); }
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); }
/// <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); } }
/// <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 PaymentsOrder(List <PaymentsOrderLine> cart, MerchantUrls urls) : base(urls) { OrderLines = cart; }
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; }