예제 #1
0
        public void CreditVerify()
        {
            var response = card.Verify()
                           .WithAllowDuplicates(true)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode, response.ResponseMessage);
        }
        public void CreditVerify_CardNumberDetails()
        {
            var response = card.Verify()
                           .WithCurrency(currency)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(VERIFIED, response?.ResponseMessage);
        }
예제 #3
0
        public void Tokenize_UsingCreditCard_ReturnsToken()
        {
            var response = clearTextCredit.Verify()
                           .WithAddress(new Address {
                PostalCode = "12345"
            })
                           .WithRequestMultiUseToken(true)
                           .Execute();

            Assert.IsFalse(string.IsNullOrWhiteSpace(response.Token));
        }
예제 #4
0
        public void Tokenize_UsingCreditCard_ReturnsTokenInformation()
        {
            var tokenResponse = clearTextCredit.Verify()
                                .WithAddress(address)
                                .WithCustomerData(customer)
                                .WithRequestMultiUseToken(true)
                                .Execute();

            clearTextCredit.Token = tokenResponse.Token;
            var tokenInfoResponse = clearTextCredit.GetTokenInformation();

            Assert.IsNotNull(tokenInfoResponse);
            Assert.IsNotNull(tokenInfoResponse.TokenData);
        }
예제 #5
0
        // The used credentials on this test have not permissions to delete a tokenized card
        public void DeleteTokenizedPaymentMethod_WithMalformedId()
        {
            const string token = "This_is_not_a_payment_id";

            var tokenizedCard = new CreditCardData {
                Token = token
            };

            Assert.IsFalse(tokenizedCard.DeleteToken());

            var exceptionCaught = false;

            try {
                tokenizedCard.Verify()
                .WithCurrency("USD")
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("INVALID_REQUEST_DATA", ex.ResponseCode);
                Assert.AreEqual("40213", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: BadRequest - payment_method.id: {token} contains unexpected data", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #6
0
        public void Verify_Manual()
        {
            var response = card.Verify().Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode, response.ResponseMessage);
        }
예제 #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
        // 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);
            }
        }
예제 #9
0
        public void GenerateAccessTokenManualWithSecondsToExpire()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                Environment     = Environment.TEST,
                AppId           = "JF2GQpeCrOivkBGsTRiqkpkdKp67Gxi0",
                AppKey          = "y7vALnUtFulORlTV",
                SecondsToExpire = 60
            });

            var response = card.Verify()
                           .WithCurrency("USD")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(VERIFIED, response?.ResponseMessage);
        }
        public void CreditVerify()
        {
            var response = card.Verify()
                           .WithCurrency(CURRENCY)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response.ResponseCode);
            Assert.AreEqual(VERIFIED, response.ResponseMessage);
        }
예제 #11
0
        public void CreditVerifyWithCOF()
        {
            Transaction response = card.Verify()
                                   .WithAllowDuplicates(true)
                                   .WithCardBrandStorage(StoredCredentialInitiator.CardHolder)
                                   .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            Assert.IsNotNull(response.CardBrandTransactionId);

            Transaction cofResponse = card.Verify()
                                      .WithAllowDuplicates(true)
                                      .WithCardBrandStorage(StoredCredentialInitiator.Merchant, response.CardBrandTransactionId)
                                      .Execute();

            Assert.IsNotNull(cofResponse);
            Assert.AreEqual("00", cofResponse.ResponseCode);
        }
예제 #12
0
        public void VerifyTokenizedPaymentMethod()
        {
            var tokenizedCard = new CreditCardData {
                Token = _token,
            };

            var response = tokenizedCard.Verify().Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            Assert.AreEqual("ACTIVE", response.ResponseMessage);
        }
예제 #13
0
        public static bool ValidateCard(OrderDetails details, ref string result, appSettings _config)
        {
            try
            {
                ServicesContainer.ConfigureService(new GatewayConfig
                {
                    MerchantId   = _config.MerchantId,
                    AccountId    = _config.AccountId,
                    SharedSecret = _config.SharedSecret,
                    ServiceUrl   = _config.ServiceUrl
                });

                int expYear  = 0;
                int expMonth = 0;
                int.TryParse(details.CardExpYear, out expYear);
                int.TryParse(details.CardExpMonth, out expMonth);
                // create the card object
                var card = new CreditCardData
                {
                    Number         = details.CardNumber,
                    ExpMonth       = expMonth,
                    ExpYear        = expYear,
                    Cvn            = details.CardCvn,
                    CardHolderName = details.CardHolderName
                };
                try
                {
                    // process an auto-capture authorization
                    decimal amount = 0.0m;
                    decimal.TryParse(details.Amount, out amount);
                    Transaction GPresponse = card.Verify()
                                             .Execute();
                    responseMsg["message"]  = GPresponse.ResponseMessage;
                    responseMsg["code"]     = GPresponse.ResponseCode;
                    responseMsg["SchemeId"] = GPresponse.SchemeId;
                    result = JsonConvert.SerializeObject(responseMsg);
                    return(true);
                }

                catch (ApiException ex)
                {
                    throw new Exception(ex.Message);
                    // TODO: Add your error handling here
                }
            }
            catch (Exception ex)
            {
                result = JsonConvert.SerializeObject(ex.Message);
                return(false);
            }
        }
        public void VerifyTokenizedPaymentMethod()
        {
            var tokenizedCard = new CreditCardData {
                Token = Token,
            };

            var response = tokenizedCard.Verify()
                           .WithCurrency(CURRENCY)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response.ResponseCode);
            Assert.AreEqual(VERIFIED, response.ResponseMessage);
        }
예제 #15
0
        public void VerifyTokenizedPaymentMethod()
        {
            CreditCardData tokenizedCard = new CreditCardData {
                Token = Token,
            };

            Transaction response = tokenizedCard.Verify()
                                   .WithCurrency("USD")
                                   .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("SUCCESS", response.ResponseCode);
            Assert.AreEqual("VERIFIED", response.ResponseMessage);
        }
예제 #16
0
        public void Cleanup()
        {
            var tokenizedCard = new CreditCardData {
                Token = _token
            };

            Assert.IsTrue(tokenizedCard.DeleteToken());

            try {
                tokenizedCard.Verify().Execute();
            }
            catch (GatewayException ex) {
                Assert.AreEqual("RESOURCE_NOT_FOUND", ex.ResponseCode);
            }
        }
예제 #17
0
        public void DeleteToken()
        {
            var token = new CreditCardData {
                Token = _token
            };

            Assert.IsTrue(token.DeleteToken());

            try {
                token.Verify().Execute();
            }
            catch (GatewayException exc) {
                Assert.AreEqual("23", exc.ResponseCode);
            }
        }
        public void VerifyTokenizedPaymentMethod_withIdempotencyKey()
        {
            var idempotencyKey = Guid.NewGuid().ToString();

            var tokenizedCard = new CreditCardData {
                Token = Token,
            };

            var response = tokenizedCard.Verify()
                           .WithCurrency(CURRENCY)
                           .WithIdempotencyKey(idempotencyKey)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response.ResponseCode);
            Assert.AreEqual(VERIFIED, response.ResponseMessage);

            var exceptionCaught = false;

            try {
                tokenizedCard.Verify()
                .WithCurrency(CURRENCY)
                .WithIdempotencyKey(idempotencyKey)
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("40039", ex.ResponseMessage);
                Assert.AreEqual("DUPLICATE_ACTION", ex.ResponseCode);
                Assert.AreEqual(
                    $"Status Code: Conflict - Idempotency Key seen before: id={response.TransactionId}, status=VERIFIED",
                    ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
예제 #19
0
        public void VerifyTokenizedPaymentMethod_WithRandomId()
        {
            var tokenizedCard = new CreditCardData {
                Token = "PMT_" + Guid.NewGuid().ToString(),
            };

            try {
                var response = 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"));
            }
        }
예제 #20
0
        public void FullCycle_v2_OTB()
        {
            // check enrollment
            ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card)
                                      .Execute(Secure3dVersion.Two);

            Assert.IsNotNull(secureEcom);

            if (secureEcom.Enrolled.Equals("True"))
            {
                Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version);

                // initiate authentication
                ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom)
                                        .WithAmount(10.01m)
                                        .WithCurrency("USD")
                                        .WithOrderCreateDate(DateTime.Now)
                                        .WithAddress(billingAddress, AddressType.Billing)
                                        .WithAddress(shippingAddress, AddressType.Shipping)
                                        .WithBrowserData(browserData)
                                        .WithMethodUrlCompletion(MethodUrlCompletion.NO)
                                        .Execute();
                Assert.IsNotNull(initAuth);

                // get authentication data
                secureEcom = Secure3dService.GetAuthenticationData()
                             .WithServerTransactionId(initAuth.ServerTransactionId)
                             .Execute();
                card.ThreeDSecure = secureEcom;

                if (secureEcom.Status.Equals("AUTHENTICATION_SUCCESSFUL"))
                {
                    Transaction response = card.Verify()
                                           .WithCurrency("USD")
                                           .Execute();
                    Assert.IsNotNull(response);
                    Assert.AreEqual("00", response.ResponseCode);
                }
                else
                {
                    Assert.Fail("Signature verification failed.");
                }
            }
            else
            {
                Assert.Fail("Card not enrolled.");
            }
        }
예제 #21
0
        public void UpdateToken()
        {
            var token = new CreditCardData {
                Token    = _token,
                ExpMonth = 12,
                ExpYear  = 2025
            };

            Assert.IsTrue(token.UpdateTokenExpiry());

            // should succeed
            var response = token.Verify().Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
예제 #22
0
        public void UpdateTokenizedPaymentMethod()
        {
            var tokenizedCard = new CreditCardData {
                Token    = _token,
                ExpMonth = 12,
                ExpYear  = 2030
            };

            Assert.IsTrue(tokenizedCard.UpdateTokenExpiry());

            var response = tokenizedCard.Verify().Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            Assert.AreEqual("ACTIVE", response.ResponseMessage);
        }
예제 #23
0
        public IActionResult OtbApi(Datos detalles)
        {
            // configure client & request settings
            ServicesContainer.ConfigureService(new GatewayConfig {
                MerchantId   = "addonnettest",
                AccountId    = "api",
                SharedSecret = "secret",
                ServiceUrl   = "https://remote.sandbox.addonpayments.com/remote"
            });

            // create the card object
            var card = new CreditCardData {
                Number         = detalles.Tarjeta.cardNumber,
                ExpMonth       = detalles.Tarjeta.month,
                ExpYear        = detalles.Tarjeta.year,
                Cvn            = detalles.Tarjeta.cvn,
                CardHolderName = detalles.Tarjeta.cardholderName
            };

            try {
                // process an auto-capture authorization
                Transaction response = card.Verify()
                                       .Execute();

                var result  = response.ResponseCode;    // 00 == Success
                var message = response.ResponseMessage; // [ test system ] AUTHORISED

                // get the response details to save to the DB for future requests
                var orderId             = response.OrderId;           // ezJDQjhENTZBLTdCNzNDQw
                var authCode            = response.AuthorizationCode; // 12345
                var paymentsReference   = response.TransactionId;     // pasref 14622680939731425
                var schemeReferenceData = response.SchemeId;          // MMC0F00YE4000000715

                Respuesta respuesta = new Respuesta {
                    result = result, message = message, orderId = orderId, authCode = authCode, paymentsReference = paymentsReference, schemeReferenceData = schemeReferenceData
                };

                return(Ok(respuesta));
            }

            catch (ApiException exce) {
                RespuestaError respuesta = new RespuestaError {
                    resultado = "Error en el envío de datos <br><br>" + exce
                };
                return(BadRequest(respuesta));
            }
        }
예제 #24
0
        public void VerifyTokenizedPaymentMethod_WithMalformedId()
        {
            string token = "This_is_not_a_payment_id";

            var tokenizedCard = new CreditCardData {
                Token = token,
            };

            try {
                tokenizedCard.Verify().Execute();
            }
            catch (GatewayException ex) {
                Assert.AreEqual("INVALID_REQUEST_DATA", ex.ResponseCode);
                Assert.AreEqual("40006", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: BadRequest - payment_method.id: {token} contains unexpected data", ex.Message);
            }
        }
예제 #25
0
        public void UpdateTokenizedPaymentMethod()
        {
            CreditCardData tokenizedCard = new CreditCardData {
                Token    = Token,
                ExpMonth = 12,
                ExpYear  = 2030
            };

            Assert.IsTrue(tokenizedCard.UpdateTokenExpiry());

            Transaction response = tokenizedCard.Verify()
                                   .WithCurrency("USD")
                                   .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("SUCCESS", response.ResponseCode);
            Assert.AreEqual("VERIFIED", response.ResponseMessage);
        }
        public void UpdateTokenizedPaymentMethod()
        {
            var tokenizedCard = new CreditCardData {
                Token    = Token,
                ExpMonth = 12,
                ExpYear  = 2030
            };

            Assert.IsTrue(tokenizedCard.UpdateTokenExpiry());

            var response = tokenizedCard.Verify()
                           .WithCurrency(CURRENCY)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response.ResponseCode);
            Assert.AreEqual(VERIFIED, response.ResponseMessage);
        }
예제 #27
0
        public void CreditVerify_InvalidCVV()
        {
            var card = new CreditCardData {
                Number   = "4263970000005262",
                ExpMonth = 05,
                ExpYear  = 2025,
                Cvn      = "SMA",
            };

            try {
                card.Verify()
                .WithCurrency("USD")
                .Execute();
            }
            catch (GatewayException ex) {
                Assert.AreEqual("SYSTEM_ERROR_DOWNSTREAM", ex.ResponseCode);
                Assert.AreEqual("50018", ex.ResponseMessage);
            }
        }
        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);
        }
예제 #29
0
        public void DeleteTokenizedPaymentMethod_WithRandomId()
        {
            var tokenizedCard = new CreditCardData {
                Token = "PMT_" + Guid.NewGuid().ToString()
            };

            Assert.IsFalse(tokenizedCard.DeleteToken());

            try {
                tokenizedCard.Verify()
                .WithCurrency("USD")
                .Execute();
            }
            catch (GatewayException ex) {
                Assert.AreEqual("RESOURCE_NOT_FOUND", ex.ResponseCode);
                Assert.AreEqual("40116", ex.ResponseMessage);
                Assert.IsTrue(ex.Message.StartsWith("Status Code: NotFound - payment_method"));
            }
        }
예제 #30
0
        public void GenerateAccessTokenManual_AccessToken()
        {
            var info = GpApiService.GenerateTransactionKey(gpApiConfig);

            gpApiConfig.AccessTokenInfo = info;

            ServicesContainer.ConfigureService(gpApiConfig);

            var response = card.Verify()
                           .WithCurrency("USD")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(VERIFIED, response?.ResponseMessage);
        }