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 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); }
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 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); }
public CreateCancelRequest Build() { CreateCancelRequest cancelRequest = new CreateCancelRequest(); cancelRequest.PaymentId = _paymentId; cancelRequest.Ip = _ip; return(cancelRequest); }
public void Should_Cancel_Payment() { CreateCancelRequest request = new CreateCancelRequest(); request.Locale = Locale.TR.GetName(); request.ConversationId = "123456789"; request.PaymentId = "24"; request.Ip = "127.0.0.1"; ConnectCancel connectCancel = ConnectCancel.Create(request, options); PrintResponse <ConnectCancel>(connectCancel); Assert.IsNotNull(connectCancel.SystemTime); Assert.AreEqual(Status.SUCCESS.ToString(), connectCancel.Status); Assert.AreEqual(Locale.TR.GetName(), connectCancel.Locale); Assert.AreEqual("123456789", connectCancel.ConversationId); }
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 async Task Should_Cancel_Payment() { CreateCancelRequest request = new CreateCancelRequest { ConversationId = "123456789", Locale = Locale.TR.ToString(), PaymentId = "1", Ip = "85.34.78.112" }; Cancel cancel = await Cancel.CreateAsync(request, Options); PrintResponse(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); }
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); }
public async Task Should_Cancel_Payment_With_Reason_And_Description() { CreateCancelRequest request = new CreateCancelRequest { ConversationId = "123456789", Locale = Locale.TR.ToString(), PaymentId = "1", Ip = "85.34.78.112", Reason = RefundReason.OTHER.ToString(), Description = "customer requested for default sample" }; Cancel cancel = await Cancel.CreateAsync(request, Options); PrintResponse(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); }
public static Cancel Create(CreateCancelRequest request, Options options) { return(RestHttpClient.Create().Post <Cancel>(options.BaseUrl + "/payment/cancel", GetHttpHeaders(request, options), request)); }
public static async Task <Cancel> CreateAsync(CreateCancelRequest request, Options options) { return(await RestHttpClient.Instance.PostAsync <Cancel>(options.BaseUrl + CancelUrl, GetHttpHeaders(request, options), request)); }
public static Cancel Create(CreateCancelRequest request, Options options) { return(RestHttpClient.Instance.Post <Cancel>(options.BaseUrl + CancelUrl, GetHttpHeaders(request, options), request)); }
// Async public static async Task <Cancel> CreateAsync(CreateCancelRequest request, Options options) { return(await RestHttpClient.Create().PostAsync <Cancel>(options.BaseUrl + "/payment/cancel", GetHttpHeaders(request, options), request)); }