public void Should_Cancel_Fraudulent_Payment() { CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create() .StandardListingPayment() .Build(); Payment payment = Payment.Create(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 = Cancel.Create(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.1", cancel.Price.RemoveTrailingZeros()); Assert.AreEqual(Currency.TRY.ToString(), cancel.Currency); Assert.NotNull(cancel.SystemTime); Assert.Null(cancel.ErrorCode); Assert.Null(cancel.ErrorMessage); Assert.Null(cancel.ErrorGroup); }
public void Should_Cancel_Payment() { CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create() .StandardListingPayment() .Build(); Payment payment = Payment.Create(paymentRequest, _options); CreateCancelRequest cancelRequest = CreateCancelRequestBuilder.Create() .PaymentId(payment.PaymentId) .Build(); Cancel cancel = Cancel.Create(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.1", cancel.Price.RemoveTrailingZeros()); Assert.AreEqual(Currency.TRY.ToString(), cancel.Currency); Assert.NotNull(cancel.SystemTime); Assert.Null(cancel.ErrorCode); Assert.Null(cancel.ErrorMessage); Assert.Null(cancel.ErrorGroup); }
public void Should_Cancel_Payment() { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = "123456789"; request.Locale = Locale.TR.GetName(); request.PaymentId = "1"; request.Ip = "127.0.0.1"; Cancel cancel = Cancel.Create(request, options); PrintResponse <Cancel>(cancel); Assert.IsNotNull(cancel.SystemTime); Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status); Assert.AreEqual(Locale.TR.GetName(), cancel.Locale); Assert.AreEqual("123456789", cancel.ConversationId); Assert.AreEqual("1", cancel.PaymentId); }
public void Should_Cancel_Payment() { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = "123456789"; request.Locale = Locale.TR.ToString(); request.PaymentId = "1"; request.Ip = "85.34.78.112"; Cancel cancel = Cancel.Create(request, options); PrintResponse <Cancel>(cancel); Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status); Assert.AreEqual(Locale.TR.ToString(), cancel.Locale); Assert.AreEqual("123456789", cancel.ConversationId); Assert.IsNotNull(cancel.SystemTime); Assert.IsNull(cancel.ErrorCode); Assert.IsNull(cancel.ErrorMessage); Assert.IsNull(cancel.ErrorGroup); }
/// <summary> /// Ödeme Talebi İadesi /// </summary> /// <param name="refundPaymentRequest">Request</param> /// <returns>Result</returns> public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) { var refundResult = new RefundPaymentResult(); if (!refundPaymentRequest.IsPartialRefund) { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = refundPaymentRequest.Order.CustomOrderNumber; request.Locale = Locale.TR.ToString(); request.PaymentId = refundPaymentRequest.Order.AuthorizationTransactionId; request.Ip = refundPaymentRequest.Order.CustomerIp; Cancel cancel = Cancel.Create(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); if (cancel.Status == "success") { refundResult.NewPaymentStatus = PaymentStatus.Refunded; } else { refundResult.AddError(cancel.ErrorGroup); } } else { string[] list = refundPaymentRequest.Order.AuthorizationTransactionResult.Split('-'); CreateRefundRequest request = new CreateRefundRequest(); request.ConversationId = refundPaymentRequest.Order.CustomOrderNumber; request.Locale = Locale.TR.ToString(); request.PaymentTransactionId = list[0]; request.Price = refundPaymentRequest.AmountToRefund.ToString("##.###").Replace(',', '.'); request.Ip = refundPaymentRequest.Order.CustomerIp; request.Currency = Currency.TRY.ToString(); Iyzico.Models.Refund refund = Iyzico.Models.Refund.Create(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); if (refund.Status == "success") { refundResult.NewPaymentStatus = PaymentStatus.PartiallyRefunded; } } return(refundResult); }
public void Should_Cancel_Payment_With_Reason_And_Description() { CreateCancelRequest request = new CreateCancelRequest(); request.ConversationId = "123456789"; request.Locale = Locale.TR.ToString(); request.PaymentId = "1"; request.Ip = "85.34.78.112"; request.Reason = RefundReason.OTHER.ToString(); request.Description = "customer requested for default sample"; Cancel cancel = Cancel.Create(request, options); PrintResponse <Cancel>(cancel); Assert.AreEqual(Status.SUCCESS.ToString(), cancel.Status); Assert.AreEqual(Locale.TR.ToString(), cancel.Locale); Assert.AreEqual("123456789", cancel.ConversationId); Assert.IsNotNull(cancel.SystemTime); Assert.IsNull(cancel.ErrorCode); Assert.IsNull(cancel.ErrorMessage); Assert.IsNull(cancel.ErrorGroup); }