コード例 #1
0
        public void CardHolderEnrolled_ChallengeRequired_AuthenticationSuccessful_FullCycle_v1_WithTokenizedPaymentMethod()
        {
            card.Number = GpApi3DSTestCards.CARDHOLDER_ENROLLED_V1;

            // Tokenize payment method
            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize()
            };

            Assert.IsNotNull(tokenizedCard.Token);

            // Check enrollment
            var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard)
                             .WithCurrency(Currency)
                             .WithAmount(Amount)
                             .Execute();

            Assert.IsNotNull(secureEcom);
            Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled");
            Assert.AreEqual(Secure3dVersion.One, secureEcom.Version);
            Assert.AreEqual(CHALLENGE_REQUIRED, secureEcom.Status);
            Assert.IsTrue(secureEcom.ChallengeMandated);
            Assert.IsNotNull(secureEcom.IssuerAcsUrl);
            Assert.IsNotNull(secureEcom.PayerAuthenticationRequest);
            Assert.IsNotNull(secureEcom.ChallengeReturnUrl);
            Assert.IsNotNull(secureEcom.MessageType);
            Assert.IsNotNull(secureEcom.SessionDataFieldName);

            // Perform ACS authentication
            GpApi3DSecureAcsClient acsClient = new GpApi3DSecureAcsClient(secureEcom.IssuerAcsUrl);
            string payerAuthenticationResponse;
            string authResponse = acsClient.Authenticate_v1(secureEcom, out payerAuthenticationResponse);

            Assert.AreEqual("{\"success\":true}", authResponse);

            // Get authentication data
            secureEcom = Secure3dService.GetAuthenticationData()
                         .WithServerTransactionId(secureEcom.ServerTransactionId)
                         .WithPayerAuthenticationResponse(payerAuthenticationResponse)
                         .Execute();

            Assert.IsNotNull(secureEcom);
            Assert.AreEqual(SUCCESS_AUTHENTICATED, secureEcom.Status);
            Assert.AreEqual("YES", secureEcom.LiabilityShift);

            tokenizedCard.ThreeDSecure = secureEcom;

            // Create transaction
            var response = tokenizedCard.Charge(Amount)
                           .WithCurrency(Currency)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage);
        }
コード例 #2
0
        public void CardHolderEnrolled_ChallengeRequired_v2_WithTokenizedCard()
        {
            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize(), CardHolderName = "Jason Mason"
            };

            Assert.IsNotNull(tokenizedCard.Token);

            var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard)
                             .WithCurrency(Currency)
                             .WithAmount(Amount)
                             .Execute();

            AssertThreeDSResponse(secureEcom, AVAILABLE);
            Assert.IsFalse(secureEcom.ChallengeMandated);
        }
コード例 #3
0
        public void BoardCard_Vault()
        {
            // TODO: for use with single use tokens
            string token = tokenizedCard.Tokenize();

            Assert.IsNotNull(token);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void SaleWithTokenizedPaymentMethod()
        {
            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize(),
            };

            var response = tokenizedCard.Charge(17.01m)
                           .WithCurrency("USD")
                           .WithAllowDuplicates(true)

                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage);
        }
コード例 #6
0
        // The used credentials on this test have not permissions to delete a tokenized card
        public void DeleteTokenizedPaymentMethod_WithNonExistingId()
        {
            _card = new CreditCardData {
                Number   = "4111111111111111",
                ExpMonth = expMonth,
                ExpYear  = expYear,
                Cvn      = "123"
            };

            var tokenizedCard = new CreditCardData {
                Token = _card.Tokenize()
            };

            Assert.IsNotNull(tokenizedCard.Token);
            Assert.IsTrue(tokenizedCard.DeleteToken());
            Assert.IsFalse(tokenizedCard.DeleteToken());

            var exceptionCaught = false;

            try {
                tokenizedCard.Verify()
                .WithCurrency("USD")
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("ACTION_NOT_AUTHORIZED", ex.ResponseCode);
                Assert.AreEqual("40212", ex.ResponseMessage);
                Assert.IsTrue(ex.Message.StartsWith("Status Code: Forbidden - Permission not enabled to execute action"));
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
コード例 #7
0
        public void DeleteTokenizedPaymentMethod_WithNonExistingId()
        {
            _card = new CreditCardData {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2025,
                Cvn      = "123"
            };

            var tokenizedCard = new CreditCardData {
                Token = _card.Tokenize()
            };

            Assert.IsNotNull(tokenizedCard.Token);
            Assert.IsTrue(tokenizedCard.DeleteToken());
            Assert.IsFalse(tokenizedCard.DeleteToken());

            try {
                tokenizedCard.Verify().Execute();
            }
            catch (GatewayException ex) {
                Assert.AreEqual("RESOURCE_NOT_FOUND", ex.ResponseCode);
                Assert.AreEqual("40118", ex.ResponseMessage);
                Assert.IsTrue(ex.Message.StartsWith("Status Code: NotFound - PAYMENT_METHODS"));
            }
        }
コード例 #8
0
        public PorticoEcommerceTests()
        {
            ServicesContainer.ConfigureService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A"
            });

            card   = TestCards.VisaManual();
            _token = card.Tokenize();
        }
コード例 #9
0
        public void VerifyTokenizedPaymentMethodWithFingerprint()
        {
            var customer = new Customer {
                DeviceFingerPrint = "ALWAYS"
            };
            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize(),
            };

            var response = tokenizedCard.Verify()
                           .WithCurrency("GBP")
                           .WithCustomerData(customer)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual("VERIFIED", response?.ResponseMessage);
            Assert.IsNotNull(response.FingerPrint);
        }
コード例 #10
0
        public void CreditTokenize()
        {
            ServicesContainer.ConfigureService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A"
            }, "tokenize");

            var token = card.Tokenize("tokenize");

            Assert.IsNotNull(token);
        }
コード例 #11
0
        public void TokenizeWithoutVerification()
        {
            CreditCardData card = new CreditCardData {
                Number   = "5454545454545454",
                ExpMonth = 12,
                ExpYear  = 2015,
                Cvn      = "123"
            };

            string mut = card.Tokenize(false);

            Assert.IsNotNull(mut);
            Assert.IsTrue(mut.Contains("5454"));
        }
コード例 #12
0
        public static void ClassInitialize(TestContext context)
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId  = "P3LRVjtGRGxWQQJDE345mSkEh2KfdAyg",
                AppKey = "ockJr6pv6KFoGiZA",
            });

            try {
                Token = Card.Tokenize();
                Assert.IsTrue(!string.IsNullOrEmpty(Token), "Token could not be generated.");
            }
            catch (GatewayException ex) {
                Assert.Fail(ex.Message);
            }
        }
コード例 #13
0
        public void CardHolderEnrolled_ChallengeRequired_v1_TokenizedCard()
        {
            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize()
            };

            Assert.IsNotNull(tokenizedCard.Token);

            var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard)
                             .WithCurrency(Currency)
                             .WithAmount(Amount)
                             .Execute();

            AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED);
        }
コード例 #14
0
 public void Initialize()
 {
     try {
         _card = new CreditCardData {
             Number   = "4111111111111111",
             ExpMonth = 12,
             ExpYear  = 2025,
             Cvn      = "123"
         };
         _token = _card.Tokenize();
         Assert.IsTrue(!string.IsNullOrEmpty(_token), "Token could not be generated.");
     }
     catch (ApiException ex) {
         Assert.Fail(ex.Message);
     }
 }
コード例 #15
0
        public static void ClassInitialize(TestContext context)
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId         = APP_ID,
                AppKey        = APP_KEY,
                RequestLogger = new RequestConsoleLogger()
            });

            try {
                Token = Card.Tokenize();
                Assert.IsTrue(!string.IsNullOrEmpty(Token), "Token could not be generated.");
            }
            catch (GatewayException ex) {
                Assert.Fail(ex.Message);
            }
        }
コード例 #16
0
 public void VerifyTokenizedPaymentMethod_WithMissingCardNumber()
 {
     _card = new CreditCardData {
         ExpMonth = 12,
         ExpYear  = 2025,
         Cvn      = "123"
     };
     try {
         _token = _card.Tokenize();
     }
     catch (GatewayException ex) {
         Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
         Assert.AreEqual("40005", ex.ResponseMessage);
         Assert.AreEqual("Status Code: BadRequest - Request expects the following fields : number", ex.Message);
     }
 }
コード例 #17
0
        public void Tokenize_UsingCreditCard_WithCustomerData_ReturnsToken()
        {
            var token = clearTextCredit.Tokenize(true, address, customer);

            Assert.IsFalse(string.IsNullOrWhiteSpace(token));

            // Tokenize via Verify() call
            //var response = clearTextCredit.Verify()
            //    // Billing address will be prioritized if specified separately
            //    .WithAddress(address)
            //    // or Customer.Address will be used as a backup if a billing address isn't provided via builder method
            //    .WithCustomerData(customer)
            //    .WithRequestMultiUseToken(true)
            //    .Execute();

            //Assert.IsFalse(string.IsNullOrWhiteSpace(response.Token));
        }
コード例 #18
0
        public void VerifyTokenizedPaymentMethod_WithMissingCardNumber()
        {
            _card = new CreditCardData {
                ExpMonth = expMonth,
                ExpYear  = expYear,
            };
            var exceptionCaught = false;

            try {
                _card.Tokenize();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
                Assert.AreEqual("40005", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - Request expects the following fields : number", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
コード例 #19
0
        public PorticoTokenManagement()
        {
            ServicesContainer.ConfigureService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A"
            });

            try {
                CreditCardData card = new CreditCardData {
                    Number   = "4111111111111111",
                    ExpMonth = 12,
                    ExpYear  = 2015,
                    Cvn      = "123"
                };
                _token = card.Tokenize();
                Assert.IsTrue(!string.IsNullOrEmpty(_token), "TOKEN COULD NOT BE GENERATED.");
            }
            catch (ApiException exc) {
                Assert.Fail(exc.Message);
            }
        }
コード例 #20
0
        public GpApiTokenManagement()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId  = "Uyq6PzRbkorv2D4RQGlldEtunEeGNZll",
                AppKey = "QDsW1ETQKHX6Y4TA",
            });

            try {
                CreditCardData card = new CreditCardData {
                    Number   = "4111111111111111",
                    ExpMonth = 12,
                    ExpYear  = 2015,
                    Cvn      = "123"
                };
                _token = card.Tokenize();
                Assert.IsTrue(!string.IsNullOrEmpty(_token), "Token could not be generated.");
            }
            catch (ApiException ex) {
                Assert.Fail(ex.Message);
            }
        }
コード例 #21
0
        public void CreditDccRateCardTokenizationThenPayingWithToken()
        {
            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize(),
            };

            var dccDetails = tokenizedCard.GetDccRate()
                             .WithAmount(Amount)
                             .WithCurrency(CURRENCY)
                             .Execute();
            var expectedDccAmountValue = GetDccAmount(dccDetails);

            AssertDccInfoResponse(dccDetails, expectedDccAmountValue);

            waitForGpApiReplication();
            var response = tokenizedCard.Charge(Amount)
                           .WithCurrency(CURRENCY)
                           .WithDccRateData(dccDetails.DccRateData)
                           .Execute();

            AssertTransactionResponse(response, TransactionStatus.Captured, expectedDccAmountValue);
        }
コード例 #22
0
        public void CreditSale_WithStoredCredentials_RecurringPayment()
        {
            var amount   = 15.00m;
            var currency = "USD";
            var card     = new CreditCardData
            {
                Number   = "4263970000005262",
                ExpMonth = 05,
                ExpYear  = 2025,
            };

            var tokenizedCard = new CreditCardData
            {
                Token = card.Tokenize(),
            };

            var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard)
                             .WithCurrency(currency)
                             .WithAmount(amount)
                             .WithAuthenticationSource(AuthenticationSource.BROWSER)

                             .Execute();

            Assert.IsNotNull(secureEcom);
            Assert.AreEqual("ENROLLED", secureEcom.Enrolled, "Card not enrolled");
            Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version);
            Assert.AreEqual("AVAILABLE", secureEcom.Status);
            Assert.IsNotNull(secureEcom.IssuerAcsUrl);
            Assert.IsNotNull(secureEcom.PayerAuthenticationRequest);
            Assert.IsNotNull(secureEcom.ChallengeReturnUrl);
            Assert.IsNotNull(secureEcom.MessageType);
            Assert.IsNotNull(secureEcom.SessionDataFieldName);
            Assert.IsNull(secureEcom.Eci);

            var initAuth = Secure3dService.InitiateAuthentication(tokenizedCard, secureEcom)
                           .WithAmount(amount)
                           .WithCurrency(currency)
                           .WithAuthenticationSource(AuthenticationSource.BROWSER)
                           .WithBrowserData(new BrowserData
            {
                AcceptHeader        = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,*/*;q=0.8",
                ColorDepth          = ColorDepth.TWENTY_FOUR_BITS,
                IpAddress           = "123.123.123.123",
                JavaEnabled         = true,
                Language            = "en",
                ScreenHeight        = 1080,
                ScreenWidth         = 1920,
                ChallengeWindowSize = ChallengeWindowSize.WINDOWED_600X400,
                Timezone            = "0",
                UserAgent           =
                    "Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
            })
                           .WithMethodUrlCompletion(MethodUrlCompletion.YES)
                           .WithOrderCreateDate(DateTime.Now)

                           .Execute();

            Assert.IsNotNull(initAuth);
            Assert.AreEqual("ENROLLED", initAuth.Enrolled, "Card not enrolled");
            Assert.AreEqual(Secure3dVersion.Two, initAuth.Version);
            Assert.AreEqual("SUCCESS_AUTHENTICATED", initAuth.Status);
            Assert.IsNotNull(initAuth.IssuerAcsUrl);
            Assert.IsNotNull(initAuth.PayerAuthenticationRequest);
            Assert.IsNotNull(initAuth.ChallengeReturnUrl);
            Assert.IsNotNull(initAuth.MessageType);
            Assert.IsNotNull(initAuth.SessionDataFieldName);

            tokenizedCard.ThreeDSecure = initAuth;

            var response = tokenizedCard.Charge(amount)
                           .WithCurrency(currency)

                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage);
            Assert.IsNotNull(response.CardBrandTransactionId);

            var response2 = tokenizedCard.Charge(amount)
                            .WithCurrency(currency)
                            .WithStoredCredential(new StoredCredential
            {
                Initiator = StoredCredentialInitiator.Merchant,
                Type      = StoredCredentialType.Recurring,
                Sequence  = StoredCredentialSequence.Subsequent,
                Reason    = StoredCredentialReason.Incremental
            })
                            .WithCardBrandStorage(StoredCredentialInitiator.Merchant, response.CardBrandTransactionId)

                            .Execute();

            Assert.IsNotNull(response2);
            Assert.AreEqual(SUCCESS, response2?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response2?.ResponseMessage);
        }
コード例 #23
0
        public void BoardCard_Encrypted_Keyed()
        {
            string token = encryptedCard.Tokenize();

            Assert.IsNotNull(token);
        }