Пример #1
0
        public async Task Should_Cancel_Fraudulent_Payment()
        {
            CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create()
                                                  .StandardListingPayment()
                                                  .Build();

            Payment payment = await Payment.CreateAsync(paymentRequest, Options);

            CreateCancelRequest cancelRequest = CreateCancelRequestBuilder.Create()
                                                .PaymentId(payment.PaymentId)
                                                .Build();

            cancelRequest.Reason      = RefundReason.FRAUD.ToString();
            cancelRequest.Description = "stolen card request with 11000 try payment for default sample";

            Cancel cancel = await Cancel.CreateAsync(cancelRequest, Options);

            PrintResponse(cancel);

            Assert.AreEqual(Locale.TR.ToString(), cancel.Locale);
            Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status);
            Assert.AreEqual(payment.PaymentId, cancel.PaymentId);
            Assert.AreEqual("1.10000000", cancel.Price);
            Assert.AreEqual(1.1, cancel.Price.ParseDouble());
            AssertDecimal.AreEqual(1.10000000M, cancel.Price.ParseDecimal());
            Assert.AreEqual(Currency.TRY.ToString(), cancel.Currency);
            Assert.NotNull(cancel.SystemTime);
            Assert.Null(cancel.ErrorCode);
            Assert.Null(cancel.ErrorMessage);
            Assert.Null(cancel.ErrorGroup);
        }
Пример #2
0
        public async Task Should_Create_Listing_Payment()
        {
            CreatePaymentRequest request = CreatePaymentRequestBuilder.Create()
                                           .StandardListingPayment()
                                           .Build();

            Payment payment = await Payment.CreateAsync(request, Options);

            PrintResponse(payment);

            Assert.Null(payment.ConnectorName);
            Assert.AreEqual(Locale.TR.ToString(), payment.Locale);
            Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status);
            Assert.NotNull(payment.SystemTime);
            Assert.Null(payment.ErrorCode);
            Assert.Null(payment.ErrorMessage);
            Assert.Null(payment.ErrorGroup);
            Assert.NotNull(payment.PaymentId);
            Assert.NotNull(payment.BasketId);
            Assert.AreEqual("1", payment.Price);
            Assert.AreEqual("1.1", payment.PaidPrice);
            Assert.AreEqual("0.02887500", payment.IyziCommissionRateAmount);
            Assert.AreEqual("0.25000000", payment.IyziCommissionFee);
            Assert.AreEqual("10.00000000", payment.MerchantCommissionRate);
            Assert.AreEqual("0.1", payment.MerchantCommissionRateAmount);
            Assert.AreEqual(0.028875, payment.IyziCommissionRateAmount.ParseDouble());
            Assert.AreEqual(0.25, payment.IyziCommissionFee.ParseDouble());
            Assert.AreEqual(10, payment.MerchantCommissionRate.ParseDouble());
            AssertDecimal.AreEqual(0.02887500M, payment.IyziCommissionRateAmount.ParseDecimal());
            AssertDecimal.AreEqual(0.25000000M, payment.IyziCommissionFee.ParseDecimal());
            AssertDecimal.AreEqual(10.00000000M, payment.MerchantCommissionRate.ParseDecimal());
        }
Пример #3
0
        public async Task Should_Cancel_Payment()
        {
            CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create()
                                                  .StandardListingPayment()
                                                  .Build();

            Payment payment = await Payment.CreateAsync(paymentRequest, Options);

            CreateCancelRequest cancelRequest = CreateCancelRequestBuilder.Create()
                                                .PaymentId(payment.PaymentId)
                                                .Build();

            Cancel cancel = await Cancel.CreateAsync(cancelRequest, Options);

            PrintResponse(cancel);

            Assert.AreEqual(Locale.TR.ToString(), cancel.Locale);
            Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status);
            Assert.AreEqual(payment.PaymentId, cancel.PaymentId);
            Assert.AreEqual("1.10000000", cancel.Price);
            Assert.AreEqual(1.1, cancel.Price.ParseDouble());
            AssertDecimal.AreEqual(1.10000000M, cancel.Price.ParseDecimal());
            Assert.AreEqual(Currency.TRY.ToString(), cancel.Currency);
            Assert.NotNull(cancel.SystemTime);
            Assert.Null(cancel.ErrorCode);
            Assert.Null(cancel.ErrorMessage);
            Assert.Null(cancel.ErrorGroup);
        }
Пример #4
0
        public async Task Should_Refund_Payment()
        {
            CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create()
                                                  .StandardListingPayment()
                                                  .Build();

            Payment payment = await Payment.CreateAsync(paymentRequest, Options);

            CreateRefundRequest request = new CreateRefundRequest
            {
                Locale               = Locale.TR.ToString(),
                ConversationId       = "123456789",
                PaymentTransactionId = payment.PaymentItems[0].PaymentTransactionId,
                Price    = "0.2",
                Currency = Currency.TRY.ToString(),
                Ip       = "85.34.78.112"
            };

            Refund refund = await Refund.CreateAsync(request, Options);

            PrintResponse(refund);

            Assert.AreEqual(Status.SUCCESS.ToString(), refund.Status);
            Assert.AreEqual(Locale.TR.ToString(), refund.Locale);
            Assert.AreEqual("123456789", refund.ConversationId);
            Assert.AreEqual(payment.PaymentId, refund.PaymentId);
            Assert.AreEqual(payment.PaymentItems[0].PaymentTransactionId, refund.PaymentTransactionId);
            Assert.AreEqual("0.2", refund.Price);
            Assert.AreEqual(0.2, refund.Price.ParseDouble());
            AssertDecimal.AreEqual(0.2M, refund.Price.ParseDecimal());
            Assert.NotNull(refund.SystemTime);
            Assert.Null(refund.ErrorCode);
            Assert.Null(refund.ErrorMessage);
            Assert.Null(refund.ErrorGroup);
        }
Пример #5
0
        public async Task Should_Create_Payment_With_Registered_Card()
        {
            string          externalUserId  = RandomGenerator.RandomId;
            CardInformation cardInformation = CardInformationBuilder.Create()
                                              .Build();

            CreateCardRequest cardRequest = CreateCardRequestBuilder.Create()
                                            .Card(cardInformation)
                                            .ExternalId(externalUserId)
                                            .Email("*****@*****.**")
                                            .Build();

            Card card = await Card.CreateAsync(cardRequest, Options);

            PaymentCard paymentCard = PaymentCardBuilder.Create()
                                      .CardUserKey(card.CardUserKey)
                                      .CardToken(card.CardToken)
                                      .Build();

            CreatePaymentRequest request = CreatePaymentRequestBuilder.Create()
                                           .StandardListingPayment()
                                           .PaymentCard(paymentCard)
                                           .Build();

            Payment payment = await Payment.CreateAsync(request, Options);

            PrintResponse(payment);

            Assert.Null(payment.ConnectorName);
            Assert.AreEqual(Locale.TR.ToString(), payment.Locale);
            Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status);
            Assert.NotNull(payment.SystemTime);
            Assert.AreEqual("123456789", payment.ConversationId);
            Assert.Null(payment.ErrorCode);
            Assert.Null(payment.ErrorMessage);
            Assert.Null(payment.ErrorGroup);
            Assert.NotNull(payment.PaymentId);
            Assert.NotNull(payment.BasketId);
            Assert.AreEqual("1", payment.Price);
            Assert.AreEqual("1.1", payment.PaidPrice);
            Assert.AreEqual("0.02887500", payment.IyziCommissionRateAmount);
            Assert.AreEqual("0.25000000", payment.IyziCommissionFee);
            Assert.AreEqual("10.00000000", payment.MerchantCommissionRate);
            Assert.AreEqual("0.1", payment.MerchantCommissionRateAmount);
            Assert.AreEqual(0.028875, payment.IyziCommissionRateAmount.ParseDouble());
            Assert.AreEqual(0.25, payment.IyziCommissionFee.ParseDouble());
            Assert.AreEqual(10, payment.MerchantCommissionRate.ParseDouble());
            AssertDecimal.AreEqual(0.02887500M, payment.IyziCommissionRateAmount.ParseDecimal());
            AssertDecimal.AreEqual(0.25000000M, payment.IyziCommissionFee.ParseDecimal());
            AssertDecimal.AreEqual(10.00000000M, payment.MerchantCommissionRate.ParseDecimal());
            Assert.AreEqual(1, payment.Installment);
        }
Пример #6
0
 public void Should_Parse_Given_String_Price_To_Decimal()
 {
     AssertDecimal.AreEqual(0.0M, "0.0".ParseDecimal());
     AssertDecimal.AreEqual(1.0M, "1.0".ParseDecimal());
     AssertDecimal.AreEqual(1.00000M, "1.00000".ParseDecimal());
     AssertDecimal.AreEqual(1M, "1.00000".ParseDecimal());
     AssertDecimal.AreEqual(1.001M, "1.001".ParseDecimal());
     AssertDecimal.AreEqual(-1.0M, "-1.0".ParseDecimal());
     AssertDecimal.AreEqual(-1.00000M, "-1.00000".ParseDecimal());
     AssertDecimal.AreEqual(-1, "-1.00000".ParseDecimal());
     AssertDecimal.AreEqual(-1.001M, "-1.001".ParseDecimal());
     AssertDecimal.AreEqual(10000.00001M, "10000.00001".ParseDecimal());
     AssertDecimal.AreEqual(-10000.00001M, "-10000.00001".ParseDecimal());
     AssertDecimal.AreEqual(0.02887500M, "0.02887500".ParseDecimal());
     AssertDecimal.AreEqual(0.25000000M, "0.25000000".ParseDecimal());
     AssertDecimal.AreEqual(10.00000000M, "10.00000000".ParseDecimal());
     AssertDecimal.AreEqual(10.000000001M, "10.000000001".ParseDecimal());
     AssertDecimal.AreEqual(99999999999999999999999999.99999999999999999999999M, "99999999999999999999999999.99999999999999999999999".ParseDecimal());
     AssertDecimal.AreEqual(-99999999999999999999999999.99999999999999999999999M, "-99999999999999999999999999.99999999999999999999999".ParseDecimal());
 }
Пример #7
0
        public async Task Should_Refund_Fraudulent_Payment()
        {
            CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create()
                                                  .StandardListingPayment()
                                                  .Build();

            Payment payment = await Payment.CreateAsync(paymentRequest, Options);

            CreateRefundRequest request = new CreateRefundRequest();

            request.Locale               = Locale.TR.ToString();
            request.ConversationId       = "123456789";
            request.PaymentTransactionId = payment.PaymentItems[0].PaymentTransactionId;
            request.Price       = "0.2";
            request.Currency    = Currency.TRY.ToString();
            request.Ip          = "85.34.78.112";
            request.Reason      = RefundReason.FRAUD.ToString();
            request.Description = "stolen card request with 11000 try payment for default sample";

            Refund refund = await Refund.CreateAsync(request, Options);

            PrintResponse(refund);

            Assert.AreEqual(Status.SUCCESS.ToString(), refund.Status);
            Assert.AreEqual(Locale.TR.ToString(), refund.Locale);
            Assert.AreEqual("123456789", refund.ConversationId);
            Assert.AreEqual(payment.PaymentId, refund.PaymentId);
            Assert.AreEqual(payment.PaymentItems[0].PaymentTransactionId, refund.PaymentTransactionId);
            Assert.AreEqual("0.2", refund.Price);
            Assert.AreEqual(0.2, refund.Price.ParseDouble());
            AssertDecimal.AreEqual(0.2M, refund.Price.ParseDecimal());
            Assert.NotNull(refund.SystemTime);
            Assert.Null(refund.ErrorCode);
            Assert.Null(refund.ErrorMessage);
            Assert.Null(refund.ErrorGroup);
        }