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 ReportPayLinkDetail() { var paylinkId = "LNK_hUh2IIO1YoyDU3wGwkcb4e6SE9v5dY"; var response = PayLinkService.PayLinkDetail(paylinkId) .Execute(); Assert.IsNotNull(response); Assert.IsInstanceOfType(response, typeof(PayLinkSummary)); Assert.AreEqual(paylinkId, response.Id); }
public void ReportPayLinkDetail_NullLinkId() { var exceptionCaught = false; try { PayLinkService.PayLinkDetail(null) .Execute(); } catch (BuilderException ex) { exceptionCaught = true; Assert.AreEqual("PayLinkId cannot be null for this transaction type.", ex.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void ReportPayLinkDetail_RandomLinkId() { var paylinkId = Guid.NewGuid().ToString(); var exceptionCaught = false; try { PayLinkService.PayLinkDetail(paylinkId) .Execute(); } catch (GatewayException ex) { exceptionCaught = true; Assert.AreEqual("RESOURCE_NOT_FOUND", ex.ResponseCode); Assert.AreEqual("40118", ex.ResponseMessage); Assert.AreEqual($"Status Code: NotFound - Links {paylinkId} not found at this /ucp/links/{paylinkId}", ex.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); }