public void CreatePayLink_ThenCharge_WithTokenizedCard() { var response = PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); AssertTransactionResponse(response); ServicesContainer.ConfigureService(SetupTransactionConfig(), "createTransaction"); var tokenizedCard = new CreditCardData { Token = card.Tokenize("createTransaction") }; var charge = tokenizedCard.Charge(AMOUNT) .WithCurrency(CURRENCY) .WithPaymentLinkId(response.PayLinkResponse.Id) .Execute("createTransaction"); Assert.IsNotNull(charge); Assert.AreEqual(SUCCESS, charge?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), charge?.ResponseMessage); Thread.Sleep(2000); var getPayLinkById = PayLinkService.PayLinkDetail(response.PayLinkResponse.Id) .Execute(); Assert.IsNotNull(getPayLinkById); Assert.IsInstanceOfType(getPayLinkById, typeof(PayLinkSummary)); Assert.AreEqual(response.PayLinkResponse.Id, getPayLinkById.Id); Assert.AreEqual(1, getPayLinkById.Transactions.Count); }
public void CreatePayLink() { payLink.Type = PayLinkType.PAYMENT; payLink.UsageMode = PaymentMethodUsageMode.Single; payLink.AllowedPaymentMethods = new PaymentMethodName[] { PaymentMethodName.Card }; payLink.UsageLimit = 1; payLink.Name = "Mobile Bill Payment"; payLink.IsShippable = true; payLink.ShippingAmount = 1.23m; payLink.ExpirationDate = DateTime.UtcNow.AddDays(10); //date('Y-m-d H:i:s') + 10; payLink.Images = new string[] { "test", "test2", "test3" }; payLink.ReturnUrl = "https://www.example.com/returnUrl"; payLink.StatusUpdateUrl = "https://www.example.com/statusUrl"; payLink.CancelUrl = "https://www.example.com/returnUrl"; var response = PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); Assert.AreEqual("SUCCESS", response.ResponseCode); Assert.AreEqual(PayLinkStatus.ACTIVE.ToString().ToUpper(), response.ResponseMessage.ToUpper()); Assert.AreEqual(AMOUNT, response.BalanceAmount); Assert.IsNotNull(response.PayLinkResponse.Url); Assert.IsNotNull(response.PayLinkResponse.Id); }
public void CreatePayLink_MissingShippable() { payLink.IsShippable = null; var response = PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); AssertTransactionResponse(response); Assert.IsFalse(response.PayLinkResponse.IsShippable != null && response.PayLinkResponse.IsShippable.Value); }
public void CreatePayLink_MultipleUsage() { payLink.UsageMode = PaymentMethodUsageMode.Multiple; payLink.UsageLimit = 2; var response = PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); AssertTransactionResponse(response); Assert.AreEqual(2, response.PayLinkResponse.UsageLimit); }
public void CreatePayLink_MissingCurrency() { var exceptionCaught = false; try { PayLinkService.Create(payLink, AMOUNT) .WithDescription("March and April Invoice") .Execute(); } catch (GatewayException e) { exceptionCaught = true; Assert.AreEqual("40005", e.ResponseMessage); Assert.AreEqual("Status Code: BadRequest - Request expects the following field transactions.currency", e.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void CreatePayLink_MissingDescription() { var exceptionCaught = false; try { PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .Execute(); } catch (GatewayException e) { exceptionCaught = true; Assert.AreEqual("40005", e.ResponseMessage); Assert.AreEqual("Status Code: BadRequest - Request expects the following field description", e.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void CreatePayLink_MissingPaymentMethods() { payLink.AllowedPaymentMethods = null; var exceptionCaught = false; try { PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); } catch (GatewayException e) { exceptionCaught = true; Assert.AreEqual("40005", e.ResponseMessage); Assert.AreEqual("Status Code: BadRequest - Request expects the following field transactions.allowed_payment_methods", e.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void CreatePayLink_MultipleUsage_ThenCharge() { payLink.UsageMode = PaymentMethodUsageMode.Multiple; payLink.UsageLimit = 2; var response = PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); AssertTransactionResponse(response); ServicesContainer.ConfigureService(SetupTransactionConfig(), "createTransaction"); for (var i = 1; i <= payLink.UsageLimit; i++) { var charge = card.Charge(AMOUNT) .WithCurrency(CURRENCY) .WithPaymentLinkId(response.PayLinkResponse.Id) .Execute("createTransaction"); Assert.IsNotNull(charge); Assert.AreEqual(SUCCESS, charge?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), charge?.ResponseMessage); } Thread.Sleep(2000); var getPayLinkById = PayLinkService.PayLinkDetail(response.PayLinkResponse.Id) .Execute(); Assert.IsNotNull(getPayLinkById); Assert.IsInstanceOfType(getPayLinkById, typeof(PayLinkSummary)); Assert.AreEqual(response.PayLinkResponse.Id, getPayLinkById.Id); Assert.AreEqual(2, getPayLinkById.Transactions.Count); }
public void CreatePayLink_ThenCharge_With3DS() { var response = PayLinkService.Create(payLink, AMOUNT) .WithCurrency(CURRENCY) .WithClientTransactionId(GenerationUtils.GenerateRecurringKey()) .WithDescription("March and April Invoice") .Execute(); AssertTransactionResponse(response); ServicesContainer.ConfigureService(SetupTransactionConfig(), "createTransaction"); card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_2; var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(CURRENCY) .WithAmount(AMOUNT) .Execute("createTransaction"); Assert.IsNotNull(secureEcom); Assert.AreEqual("ENROLLED", secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); Assert.AreEqual("AVAILABLE", secureEcom.Status); var initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(AMOUNT) .WithCurrency(CURRENCY) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithOrderCreateDate(DateTime.Now) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute("createTransaction"); Assert.IsNotNull(initAuth); Assert.AreEqual("SUCCESS_AUTHENTICATED", initAuth.Status); secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(initAuth.ServerTransactionId) .Execute("createTransaction"); Assert.AreEqual("SUCCESS_AUTHENTICATED", secureEcom.Status); Assert.AreEqual(secureEcom.LiabilityShift, "YES"); card.ThreeDSecure = secureEcom; var charge = card.Charge(AMOUNT) .WithCurrency(CURRENCY) .WithPaymentLinkId(response.PayLinkResponse.Id) .Execute("createTransaction"); Assert.IsNotNull(charge); Assert.AreEqual(SUCCESS, charge?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), charge?.ResponseMessage); Thread.Sleep(2000); var getPayLinkById = PayLinkService.PayLinkDetail(response.PayLinkResponse.Id) .Execute(); Assert.IsNotNull(getPayLinkById); Assert.IsInstanceOfType(getPayLinkById, typeof(PayLinkSummary)); Assert.AreEqual(response.PayLinkResponse.Id, getPayLinkById.Id); Assert.AreEqual(1, getPayLinkById.Transactions.Count); }