Beispiel #1
0
        /// <summary>
        /// Example for performing simple capture request.
        /// </summary>
        public void SimpleCapture()
        {
            //Reserving amount in order to capture method example could be successful
            PaymentResult paymentResult = ReserveAmount(Amount.Get(2190.00, Currency.EUR), AuthType.payment);
            //Transaction ID is returned from the gateway when payment request was successful
            string transactionId = paymentResult.Payment.TransactionId;

            //initialize capture request class, this class is used for forwarding all the data needed for capture request
            //for simple capture request only transaction ID is required
            CaptureRequest captureRequest = new CaptureRequest
            {
                PaymentId = transactionId
            };

            //call capture method
            CaptureResult captureResult = _api.Capture(captureRequest);

            //Result property contains information if the request was successful or not
            if (captureResult.Result == Result.Success)
            {
                //capture was successful
                Transaction transaction = captureResult.Payment;
            }
            else
            {
                //capture unsuccessful
                //error messages contain information about what went wrong
                string errorMerchantMessage = captureResult.ResultMerchantMessage;
                string errorMessage         = captureResult.ResultMessage;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Helper method needed for reserving and capturing payment in order to refund examples could work
        /// </summary>
        /// <param name="amount"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private CaptureResult ReserveAndCapture(Amount amount, AuthType type)
        {
            var request = new ReserveRequest
            {
                ShopOrderId = "csharpexample" + Guid.NewGuid().ToString(),
                Terminal    = "AltaPay Dev Terminal",
                Amount      = amount,
                PaymentType = type,
                Pan         = "4111000011110000",
                ExpiryMonth = 1,
                ExpiryYear  = 2012,
                Cvc         = "123",
            };

            PaymentResult paymentResult = _api.ReserveAmount(request);

            if (paymentResult.Result != Result.Success)
            {
                throw new Exception("The result was: " + paymentResult.Result + ", message: " + paymentResult.ResultMerchantMessage);
            }

            CaptureRequest captureRequest = new CaptureRequest
            {
                PaymentId = paymentResult.Payment.TransactionId
            };

            CaptureResult captureResult = _api.Capture(captureRequest);

            if (captureResult.Result != Result.Success)
            {
                throw new Exception("The result was: " + captureResult.Result + ", message: " + captureResult.ResultMerchantMessage);
            }

            return(captureResult);
        }
Beispiel #3
0
        [Test]         // Not really a unit test, just a Klarna calling example
        public static void Main()
        {
            String paymentId = "35";             // PUT A PAYMENT ID FROM A PREVIOUSLY CREATED ORDER HERE

            CaptureResult captureResult = _api.Capture(new CaptureRequest {
                PaymentId = paymentId
            });

            Assert.AreEqual(Result.Success, captureResult.Result);

            List <PaymentOrderLine> orderLines = new List <PaymentOrderLine> {
                new PaymentOrderLine {
                    Description = "description 1",
                    ItemId      = "id 01",
                    Quantity    = -1,
                    UnitPrice   = 1.1,
                    GoodsType   = GoodsType.Item
                },
                new PaymentOrderLine {
                    Description = "new item",
                    ItemId      = "new id",
                    Quantity    = 1,
                    UnitPrice   = 1.1,
                    GoodsType   = GoodsType.Item
                }
            };

            UpdateOrderRequest req = new UpdateOrderRequest(paymentId, orderLines);

            UpdateOrderResult result = _api.UpdateOrder(req);

            Assert.AreEqual(Result.Success, result.Result);
        }
Beispiel #4
0
        public void NoaNoa_LongOrderLines()
        {
            var captureRequest = new CaptureRequest()
            {
                PaymentId  = "59",
                Amount     = Amount.Get(2039, Currency.XXX),
                OrderLines =
                {
                    new PaymentOrderLine()
                    {
                        Description = "Beautiful linen dress with print", ItemId = "2-1099-1", Quantity = 1, TaxPercent = 0, UnitCode = "ROSEBUD", UnitPrice = 274.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Striped leggings", ItemId = "2-1357-1", Quantity = 1, TaxPercent = 0, UnitCode = "LIGHT ARO", UnitPrice = 74.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Gorgeous tunic with brodery anglaise", ItemId = "2-1135-1", Quantity = 1, TaxPercent = 0, UnitCode = "PURPLE", UnitPrice = 214.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Cool cotton trousers with stretch", ItemId = "2-1127-1", Quantity = 1, TaxPercent = 0, UnitCode = "WALNUT", UnitPrice = 249.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Cotton dress with print and short slee", ItemId = "2-1277-1", Quantity = 1, TaxPercent = 0, UnitCode = "DOE", UnitPrice = 449, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Striped, long-sleeved T-shirt", ItemId = "2-0177-11", Quantity = 1, TaxPercent = 0, UnitCode = "CHALK", UnitPrice = 99.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Cool cotton trousers with stretch", ItemId = "2-1127-1", Quantity = 1, TaxPercent = 0, UnitCode = "WALNUT", UnitPrice = 249.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "T-shirt I many colours", ItemId = "1-2766-1", Quantity = 1, TaxPercent = 0, UnitCode = "IBIS", UnitPrice = 89.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Striped leggings", ItemId = "2-1357-1", Quantity = 1, TaxPercent = 0, UnitCode = "LIGHT ARO", UnitPrice = 74.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Pretty printed sleeveless cotton top", ItemId = "2-1060-1", Quantity = 1, TaxPercent = 0, UnitCode = "PURPLE", UnitPrice = 189.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Feminine patterned cotton shirt", ItemId = "2-0856-1", Quantity = 1, TaxPercent = 0, UnitCode = "STONE", UnitPrice = 199.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Striped, long-sleeved T-shirt", ItemId = "2-0177-9", Quantity = 1, TaxPercent = 0, UnitCode = "LIGHT NEC", UnitPrice = 199.5, Discount = 0, GoodsType = GoodsType.Item
                    },
                    new PaymentOrderLine()
                    {
                        Description = "Freight", ItemId = "", Quantity = 1, TaxPercent = 0, UnitCode = "", UnitPrice = 0, Discount = 0, GoodsType = GoodsType.Shipment
                    },
                }
            };
            PaymentResult result = _api.Capture(captureRequest);

            Console.Out.WriteLine("test: " + result.ResultMessage);
        }