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 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 void Should_Create_Marketplace_Payment() { CreateSubMerchantRequest createSubMerchantRequest = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); string subMerchantKey = SubMerchant.Create(createSubMerchantRequest, _options).SubMerchantKey; CreatePaymentRequest request = CreatePaymentRequestBuilder.Create() .MarketplacePayment(subMerchantKey) .Build(); Payment payment = Payment.Create(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.028875", payment.IyziCommissionRateAmount.RemoveTrailingZeros()); Assert.AreEqual("0.25", payment.IyziCommissionFee.RemoveTrailingZeros()); Assert.AreEqual("10", payment.MerchantCommissionRate.RemoveTrailingZeros()); Assert.AreEqual("0.1", payment.MerchantCommissionRateAmount.RemoveTrailingZeros()); Assert.AreEqual(1, payment.Installment); }
public void Should_Create_Listing_Payment() { CreatePaymentRequest request = CreatePaymentRequestBuilder.Create() .StandardListingPayment() .Build(); Payment payment = Payment.Create(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(payment.Price, "1"); Assert.AreEqual(payment.PaidPrice, "1.1"); Assert.AreEqual(payment.IyziCommissionRateAmount.RemoveTrailingZeros(), "0.028875"); Assert.AreEqual(payment.IyziCommissionFee.RemoveTrailingZeros(), "0.25"); Assert.AreEqual(payment.MerchantCommissionRate.RemoveTrailingZeros(), "10"); Assert.AreEqual(payment.MerchantCommissionRateAmount.RemoveTrailingZeros(), "0.1"); }
public async Task Should_Not_Update_Payment_Item_When_TransactionId_Is_Wrong() { CreateSubMerchantRequest createSubMerchantRequest = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); SubMerchant subMerchant = await SubMerchant.CreateAsync(createSubMerchantRequest, Options); string subMerchantKey = subMerchant.SubMerchantKey; CreatePaymentRequest request = CreatePaymentRequestBuilder .Create() .MarketplacePayment(subMerchantKey, "40", "30") .Price("40") .PaidPrice("40") .Build(); Payment payment = await Payment.CreateAsync(request, Options); UpdatePaymentItemRequest updateRequest = new UpdatePaymentItemRequest { Locale = Locale.TR.ToString(), ConversationId = payment.ConversationId, SubMerchantKey = subMerchantKey, PaymentTransactionId = "1", SubMerchantPrice = "25" }; PaymentItem paymentItem = await PaymentItem.UpdateAsync(updateRequest, Options); PrintResponse(paymentItem); Assert.NotNull(paymentItem); Assert.AreEqual(Status.FAILURE.ToString(), paymentItem.Status); }
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_Approve_Payment_Item() { CreateSubMerchantRequest request = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); SubMerchant subMerchant = await SubMerchant.CreateAsync(request, Options); CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create() .MarketplacePayment(subMerchant.SubMerchantKey) .Build(); Payment payment = await Payment.CreateAsync(paymentRequest, Options); string paymentTransactionId = payment.PaymentItems[0].PaymentTransactionId; CreateApprovalRequest approvalRequest = CreateApprovalRequestBuilder.Create() .PaymentTransactionId(paymentTransactionId) .Build(); Approval approval = await Approval.CreateAsync(approvalRequest, Options); Assert.AreEqual(paymentTransactionId, approval.PaymentTransactionId); 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); }
public void Should_Refund_Fraudulent_Payment() { CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create() .StandardListingPayment() .Build(); Payment payment = Payment.Create(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 = Refund.Create(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.RemoveTrailingZeros()); Assert.NotNull(refund.SystemTime); Assert.Null(refund.ErrorCode); Assert.Null(refund.ErrorMessage); Assert.Null(refund.ErrorGroup); }
public void Should_Create_Threeds_Payment_With_Physical_And_Virtual_Item_For_Marketplace_Merchant() { CreateSubMerchantRequest createSubMerchantRequest = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); SubMerchant subMerchant = SubMerchant.Create(createSubMerchantRequest, _options); CreatePaymentRequest createPaymentRequest = CreatePaymentRequestBuilder.Create() .MarketplacePayment(subMerchant.SubMerchantKey) .CallbackUrl("https://www.merchant.com/callback") .Build(); ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(createPaymentRequest, _options); PrintResponse(threedsInitialize); Assert.AreEqual(Locale.TR.ToString(), threedsInitialize.Locale); Assert.AreEqual(Status.SUCCESS.ToString(), threedsInitialize.Status); Assert.NotNull(threedsInitialize.SystemTime); Assert.NotNull(threedsInitialize.HtmlContent); Assert.Null(threedsInitialize.ErrorCode); Assert.Null(threedsInitialize.ErrorMessage); Assert.Null(threedsInitialize.ErrorGroup); }
public void Should_Disapprove_Payment() { CreateSubMerchantRequest request = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); SubMerchant subMerchant = SubMerchant.Create(request, _options); CreatePaymentRequest paymentRequest = CreatePaymentRequestBuilder.Create() .MarketplacePayment(subMerchant.SubMerchantKey) .Build(); Payment payment = Payment.Create(paymentRequest, _options); String paymentTransactionId = payment.PaymentItems[0].PaymentTransactionId; CreateApprovalRequest approvalRequest = CreateApprovalRequestBuilder.Create() .PaymentTransactionId(paymentTransactionId) .Build(); Approval.Create(approvalRequest, _options); Disapproval disapproval = Disapproval.Create(approvalRequest, _options); PrintResponse(disapproval); Assert.AreEqual(paymentTransactionId, disapproval.PaymentTransactionId); Assert.AreEqual(Status.SUCCESS.ToString(), disapproval.Status); Assert.AreEqual(Locale.TR.ToString(), disapproval.Locale); Assert.NotNull(disapproval.SystemTime); Assert.Null(disapproval.ErrorCode); Assert.Null(disapproval.ErrorMessage); Assert.Null(disapproval.ErrorGroup); }
public async Task Should_Retrieve_Payment() { CreatePaymentRequest request = CreatePaymentRequestBuilder.Create() .StandardListingPayment() .Build(); Payment createdPayment = await Payment.CreateAsync(request, Options); PrintResponse(createdPayment); RetrievePaymentRequest retrievePaymentRequest = new RetrievePaymentRequest { Locale = Locale.TR.ToString(), ConversationId = "123456789", PaymentId = createdPayment.PaymentId }; Payment payment = await Payment.RetrieveAsync(retrievePaymentRequest, Options); Assert.AreEqual(Locale.TR.ToString(), payment.Locale); Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status); Assert.AreEqual(1, payment.Installment); Assert.AreEqual("123456789", payment.ConversationId); Assert.AreEqual(createdPayment.PaymentId, payment.PaymentId); Assert.NotNull(payment.SystemTime); Assert.Null(payment.ErrorCode); Assert.Null(payment.ErrorMessage); Assert.Null(payment.ErrorGroup); Assert.NotNull(payment.BasketId); }
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()); }
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_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); }
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); }
public async Task Should_Update_Payment_Item() { CreateSubMerchantRequest createSubMerchantRequest = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); SubMerchant subMerchant = await SubMerchant.CreateAsync(createSubMerchantRequest, Options); string subMerchantKey = subMerchant.SubMerchantKey; CreatePaymentRequest request = CreatePaymentRequestBuilder .Create() .MarketplacePayment(subMerchantKey, "0.4", "0.3") .Price("0.4") .PaidPrice("0.4") .Build(); Payment payment = await Payment.CreateAsync(request, Options); UpdatePaymentItemRequest updateRequest = new UpdatePaymentItemRequest { Locale = Locale.TR.ToString(), ConversationId = payment.ConversationId, SubMerchantKey = subMerchantKey, PaymentTransactionId = payment.PaymentItems?[0]?.PaymentTransactionId, SubMerchantPrice = "0.23" }; PaymentItem paymentItem = await PaymentItem.UpdateAsync(updateRequest, Options); PrintResponse(paymentItem); Assert.NotNull(paymentItem); Assert.NotNull(paymentItem.Locale); Assert.NotNull(paymentItem.ConversationId); Assert.NotNull(paymentItem.SubMerchantKey); Assert.NotNull(paymentItem.PaymentTransactionId); Assert.NotNull(paymentItem.SubMerchantPrice); Assert.AreEqual(Status.SUCCESS.ToString(), paymentItem.Status); Assert.AreEqual(Locale.TR.ToString(), paymentItem.Locale); Assert.AreEqual(updateRequest.ConversationId, paymentItem.ConversationId); Assert.AreEqual(updateRequest.SubMerchantKey, paymentItem.SubMerchantKey); Assert.AreEqual(updateRequest.PaymentTransactionId, paymentItem.PaymentTransactionId); Assert.AreEqual(updateRequest.SubMerchantPrice, paymentItem.SubMerchantPrice); }
public async Task Should_Not_MakePayment_When_Price_And_PaidPrice_Are_Same() { CreateSubMerchantRequest createSubMerchantRequest = CreateSubMerchantRequestBuilder.Create() .PersonalSubMerchantRequest() .Build(); SubMerchant subMerchant = await SubMerchant.CreateAsync(createSubMerchantRequest, Options); string subMerchantKey = subMerchant.SubMerchantKey; CreatePaymentRequest request = CreatePaymentRequestBuilder.Create() .MarketplacePaymentWithSamePrice(subMerchantKey) .Build(); Payment payment = await Payment.CreateAsync(request, Options); Assert.AreEqual(Status.FAILURE.ToString(), payment.Status); Assert.NotNull(payment.ErrorCode); Assert.NotNull(payment.ErrorMessage); }
public async Task Should_Create_Payment_With_Physical_And_Virtual_Item_For_Standard_Merchant() { CreatePaymentRequest createPaymentRequest = CreatePaymentRequestBuilder.Create() .StandardListingPayment() .CallbackUrl("https://www.merchant.com/callback") .Build(); ThreedsInitialize threedsInitialize = await ThreedsInitialize.CreateAsync(createPaymentRequest, Options); PrintResponse(threedsInitialize); Assert.AreEqual(Locale.TR.ToString(), threedsInitialize.Locale); Assert.AreEqual(Status.SUCCESS.ToString(), threedsInitialize.Status); Assert.NotNull(threedsInitialize.SystemTime); Assert.NotNull(threedsInitialize.HtmlContent); Assert.Null(threedsInitialize.ErrorCode); Assert.Null(threedsInitialize.ErrorMessage); Assert.Null(threedsInitialize.ErrorGroup); }