Esempio n. 1
0
        public void Test_008e_DeletePaymentMethod()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("ACH"));

            Assert.IsNotNull(paymentMethod);
            paymentMethod.Delete();
        }
Esempio n. 2
0
        public void ExceptionTest()
        {
            // Configure client & request settings
            ServicesContainer.ConfigureService(new GpEcomConfig {
                MerchantId               = "myMerchantId",
                AccountId                = "ecom3ds",
                SharedSecret             = "secret",
                MethodNotificationUrl    = "https://www.example.com/methodNotificationUrl",
                ChallengeNotificationUrl = "https://www.example.com/challengeNotificationUrl",
                MerchantContactUrl       = "https://www.example.com/about",
                Secure3dVersion          = Secure3dVersion.Two
            });

            // supply existing customer/payer ref
            string customerId = "20190819-Realex";
            // supply existing card/payment method ref
            string paymentId = "20190819-Realex-Credit";

            // create the payment method object
            RecurringPaymentMethod paymentMethod = new RecurringPaymentMethod(customerId, paymentId);

            ThreeDSecure threeDSecureData = null;

            try {
                threeDSecureData = Secure3dService.CheckEnrollment(paymentMethod)
                                   .Execute(Secure3dVersion.Two);
                Assert.IsNotNull(threeDSecureData);
                Assert.AreEqual("True", threeDSecureData.Enrolled);
            }
            catch (ApiException exc) {
                Assert.Fail(exc.Message);
            }
        }
        public void recurring_006_AddPaymentCheckCCD()
        {
            if (_customerBusiness == null)
            {
                Assert.Inconclusive();
            }

            var paymentMethod = _customerBusiness.AddPaymentMethod(
                GetIdentifier("CheckCCD"),
                new eCheck {
                AccountType          = AccountType.CHECKING,
                CheckType            = CheckType.BUSINESS,
                SecCode              = SecCode.CCD,
                RoutingNumber        = "490000018",
                DriversLicenseNumber = "3692581470",
                DriversLicenseState  = "TX",
                AccountNumber        = "24413815",
                BirthYear            = 1989
            }
                ).Create();

            Assert.IsNotNull(paymentMethod);
            Assert.IsNotNull(paymentMethod.Key);
            _paymentMethodCheckCcd = paymentMethod;
        }
Esempio n. 4
0
        public void Test_007b_CreditCharge_ScheduleIdWithCOF()
        {
            RecurringPaymentMethod paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod);

            Schedule schedule = Schedule.Find(PaymentId("Credit"));

            Assert.IsNotNull(schedule);

            Transaction response = paymentMethod.Charge(19m)
                                   .WithCurrency("USD")
                                   .WithScheduleId(schedule.Key)
                                   .WithAllowDuplicates(true)
                                   .WithOneTimePayment(false)
                                   .WithCardBrandStorage(StoredCredentialInitiator.CardHolder)
                                   .Execute();

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

            Transaction nextResponse = paymentMethod.Charge(15m)
                                       .WithCurrency("USD")
                                       .WithScheduleId(schedule.Key)
                                       .WithAllowDuplicates(true)
                                       .WithOneTimePayment(false)
                                       .WithCardBrandStorage(StoredCredentialInitiator.Merchant, response.CardBrandTransactionId)
                                       .Execute();

            Assert.IsNotNull(nextResponse);
            Assert.AreEqual("00", nextResponse.ResponseCode);
        }
Esempio n. 5
0
        public string Build(Element envelope, Credentials credentials, RecurringPaymentMethod paymentMethod)
        {
            var body           = et.SubElement(envelope, "soapenv:Body");
            var methodElement  = et.SubElement(body, "bil:SaveCustomerAccount");
            var requestElement = et.SubElement(methodElement, "bil:SaveCustomerAccountRequest");

            BuildCredentials(requestElement, credentials);

            var customerAccountElement = et.SubElement(requestElement, "bdms:CustomerAccount");

            string accountNumber = "";
            string routingNumber = "";
            string bankName      = "";
            int?   expMonth      = null;
            int?   expYear       = null;

            if (paymentMethod.PaymentMethod is eCheck eCheck)
            {
                et.SubElement(customerAccountElement, "bdms:ACHAccountType", GetDepositType(eCheck.CheckType.Value));
                et.SubElement(customerAccountElement, "bdms:ACHDepositType", GetACHAccountType(eCheck.AccountType.Value));
                accountNumber = eCheck.AccountNumber;
                routingNumber = eCheck.RoutingNumber;
                bankName      = eCheck.BankName;
            }

            var accountHolder = et.SubElement(customerAccountElement, "bdms:AccountHolderData");

            BuildAccountHolderData(accountHolder, paymentMethod.Address, paymentMethod.NameOnAccount);

            if (paymentMethod.PaymentMethod is CreditCardData credit)
            {
                accountNumber = credit.Number;
                expMonth      = credit.ExpMonth;
                expYear       = credit.ExpYear;
                bankName      = credit.BankName;
            }
            et.SubElement(customerAccountElement, "bdms:AccountNumber", accountNumber);
            if (string.IsNullOrWhiteSpace(bankName))
            {
                // Need to explicity set the empty value
                et.SubElement(customerAccountElement, "bdms:BankName");
            }
            else
            {
                et.SubElement(customerAccountElement, "bdms:BankName", bankName);
            }
            et.SubElement(customerAccountElement, "bdms:CustomerAccountName", paymentMethod.Id);
            et.SubElement(customerAccountElement, "bdms:ExpirationMonth", expMonth);
            et.SubElement(customerAccountElement, "bdms:ExpirationYear", expYear);
            et.SubElement(customerAccountElement, "bdms:IsCustomerDefaultAccount", SerializeBooleanValues(paymentMethod.PreferredPayment));
            et.SubElement(customerAccountElement, "bdms:RoutingNumber", routingNumber);
            //   <bdms:Token>?</bdms:Token>
            et.SubElement(customerAccountElement, "bdms:TokenPaymentMethod", GetPaymentMethodType(paymentMethod.PaymentMethod.PaymentMethodType));

            et.SubElement(requestElement, "bdms:MerchantCustomerID", paymentMethod.CustomerKey);

            return(et.ToString(envelope));
        }
Esempio n. 6
0
        public void Test_006b_GetPaymentMethod()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod);

            paymentMethod = RecurringService.Get <RecurringPaymentMethod>(paymentMethod.Key);
            Assert.IsNotNull(paymentMethod);
        }
Esempio n. 7
0
        public void Test_004b_EditPaymentMethod()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod);

            paymentMethod.PreferredPayment = false;
            paymentMethod.SaveChanges();
        }
Esempio n. 8
0
        public void Test_004b_VerifyStoredCard()
        {
            var paymentMethod = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));
            var response      = paymentMethod.Verify()
                                .WithCvn("123")
                                .Execute("test");

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 9
0
        public void Test_004c_RefundStoredCard()
        {
            var paymentMethod = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));
            var response      = paymentMethod.Refund(10.01m)
                                .WithCurrency("USD")
                                .Execute("test");

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 10
0
        public void Test_004a_ChargeStoredCard()
        {
            var paymentMethod = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));
            var response      = paymentMethod.Charge(10m)
                                .WithCurrency("USD")
                                .WithCvn("123")
                                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 11
0
        public void Test_005_RecurringPayment()
        {
            var paymentMethod = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));
            var response      = paymentMethod.Charge(12m)
                                .WithRecurringInfo(RecurringType.Fixed, RecurringSequence.First)
                                .WithCurrency("USD")
                                .Execute("test");

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 12
0
        public void Test_007_ChargeStoredCard_from_different_configs()
        {
            ServicesContainer.ConfigureService(new GpEcomConfig
            {
                MerchantId     = "heartlandgpsandbox",
                AccountId      = "3dsecure",
                RefundPassword = "******",
                SharedSecret   = "secret",
                RequestLogger  = new RequestConsoleLogger()
            });

            var paymentMethod = new_customer.AddPaymentMethod(PaymentId("Credit"), new CreditCardData
            {
                Number         = "4263970000005262",
                ExpMonth       = 5,
                ExpYear        = DateTime.Now.AddYears(2).Year,
                CardHolderName = "James Mason"
            }).Create("test");

            Assert.IsNotNull(paymentMethod);
            var response = paymentMethod.Charge(12m)
                           .WithRecurringInfo(RecurringType.Fixed, RecurringSequence.First)
                           .WithCurrency("USD")
                           .Execute("test");

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

            var pm = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));

            pm.Delete(configName: "test");

            var paymentMethod2 = new_customer.AddPaymentMethod(PaymentId("Credit"), new CreditCardData
            {
                Number         = "4263970000005262",
                ExpMonth       = 5,
                ExpYear        = DateTime.Now.AddYears(2).Year,
                CardHolderName = "James Mason 2"
            }).Create();

            Assert.IsNotNull(paymentMethod2);
            var response2 = paymentMethod2.Charge(12m)
                            .WithRecurringInfo(RecurringType.Fixed, RecurringSequence.First)
                            .WithCurrency("USD")
                            .Execute();

            Assert.IsNotNull(response2);
            Assert.AreEqual("00", response2.ResponseCode);

            var pm2 = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));

            pm2.Delete();
        }
Esempio n. 13
0
        public void Test_002c_EditPaymentMethodExpOnly()
        {
            var paymentMethod = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));

            paymentMethod.PaymentMethod = new CreditCardData {
                CardType       = "MC",
                ExpMonth       = 10,
                ExpYear        = DateTime.Now.AddYears(2).Year,
                CardHolderName = "Philip Marlowe"
            };
            paymentMethod.SaveChanges("test");
        }
Esempio n. 14
0
        public void Test_002b_EditPaymentMethod()
        {
            var paymentMethod = new RecurringPaymentMethod(CustomerId, PaymentId("Credit"));

            paymentMethod.PaymentMethod = new CreditCardData {
                Number         = "5425230000004415",
                ExpMonth       = 10,
                ExpYear        = DateTime.Now.AddYears(2).Year,
                CardHolderName = "Philip Marlowe"
            };
            paymentMethod.SaveChanges("test");
        }
        public string Build(Element envelope, Credentials credentials, RecurringPaymentMethod paymentMethod)
        {
            var body           = et.SubElement(envelope, "soapenv:Body");
            var methodElement  = et.SubElement(body, "bil:DeleteCustomerAccount");
            var requestElement = et.SubElement(methodElement, "bil:DeleteCustomerAccountRequest");

            BuildCredentials(requestElement, credentials);

            et.SubElement(requestElement, "bdms:CustomerAccountNameToDelete", paymentMethod.Id);
            et.SubElement(requestElement, "bdms:MerchantCustomerID", paymentMethod.CustomerKey);

            return(et.ToString(envelope));
        }
Esempio n. 16
0
        public void Test_007c_ACHCharge_OneTime()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("ACH"));

            Assert.IsNotNull(paymentMethod, "Payment method missing.");

            var response = paymentMethod.Charge(11m)
                           .WithCurrency("USD")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode, response.ResponseMessage);
        }
Esempio n. 17
0
        public void Test_007e_CreditCharge_Declined()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod, "Payment method missing.");

            var response = paymentMethod.Charge(10.08m)
                           .WithCurrency("USD")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("51", response.ResponseCode);
        }
Esempio n. 18
0
        public void Test_007a_CreditCharge_OneTime()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod, "Payment method missing.");

            var response = paymentMethod.Charge(9m)
                           .WithCurrency("USD")
                           .WithShippingAmt(5m)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
        public IActionResult CreditstoreApi(Datos detalles)
        {
            // configure client & request settings
            ServicesContainer.ConfigureService(new GatewayConfig {
                MerchantId     = "addonnettest",
                AccountId      = "api",
                SharedSecret   = "secret",
                RefundPassword = "******",
                ServiceUrl     = "https://remote.sandbox.addonpayments.com/remote"
            });

            // Identificador del cliente
            var customerId = detalles.Cliente.payerref;

            // Identificador de la tarjeta
            var paymentId = detalles.Cliente.paymentmethod;

            // Asociamos la tarjeta al cliente
            var paymentMethod = new RecurringPaymentMethod(customerId, paymentId);


            try {
                // process an auto-capture authorization
                Transaction response = paymentMethod.Refund(detalles.Tarjeta.importe)
                                       .WithCurrency("EUR")
                                       .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

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

                return(Ok(respuesta));
            }

            catch (ApiException exce) {
                RespuestaError respuesta = new RespuestaError {
                    resultado = "Error en el envío de datos <br><br>" + exce
                };
                return(BadRequest(respuesta));
            }
        }
        public IActionResult EditcardApi(Datos detalles)
        {
            // configure client & request settings
            ServicesContainer.ConfigureService(new GatewayConfig {
                MerchantId   = "addonnettest",
                AccountId    = "api",
                SharedSecret = "secret",
                ServiceUrl   = "https://remote.sandbox.addonpayments.com/remote"
            });

            // Identificador del cliente
            var customerId = detalles.Cliente.payerref;

            // Identificador de la tarjeta
            var paymentId = detalles.Cliente.paymentmethod;

            // Asociamos la tarjeta al cliente
            var paymentMethod = new RecurringPaymentMethod(customerId, paymentId);


            // Creamos el objeto de la tarjeta
            var newCardDetails = new CreditCardData {
                Number         = detalles.Tarjeta.cardNumber,
                ExpMonth       = detalles.Tarjeta.month,
                ExpYear        = detalles.Tarjeta.year,
                CardHolderName = detalles.Tarjeta.cardholderName
            };

            // Añadimos los nuevos datos de tarjeta al objeto paymentMethod
            paymentMethod.PaymentMethod = newCardDetails;

            try {
                // process an auto-capture authorization
                paymentMethod.SaveChanges();

                Respuesta respuesta = new Respuesta {
                    result = "Tarjeta modificada correctamente."
                };

                return(Ok(respuesta));
            }

            catch (ApiException exce) {
                RespuestaError respuesta = new RespuestaError {
                    resultado = "Error en el envío de datos <br><br>" + exce
                };
                return(BadRequest(respuesta));
            }
        }
Esempio n. 21
0
        public void Test_008g_CreditCharge_WithNewCryptoURL()
        {
            ServicesContainer.ConfigureService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A"
            });
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod);

            var response = paymentMethod.Charge(17.01m)
                           .WithCurrency("USD")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("51", response.ResponseCode);
        }
Esempio n. 22
0
        public void Test_001i_CreateSchedule_ACH()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("ACH"));

            Assert.IsNotNull(paymentMethod, "Payment method does not exist.");

            var schedule = paymentMethod.AddSchedule(PaymentId("ACH"))
                           .WithAmount(11m)
                           .WithStartDate(DateTime.Now.AddDays(7))
                           .WithFrequency(ScheduleFrequency.MONTHLY)
                           .WithStatus("Active")
                           .Create();

            Assert.IsNotNull(schedule);
            Assert.IsNotNull(schedule.Key);
        }
        public void recurring_003_AddPaymentCreditVisa()
        {
            if (_customerPerson == null)
            {
                Assert.Inconclusive();
            }

            var paymentMethod = _customerPerson.AddPaymentMethod(GetIdentifier("CreditV"), new CreditCardData {
                Number   = "4012002000060016",
                ExpMonth = 12,
                ExpYear  = 2025
            }).Create();

            Assert.IsNotNull(paymentMethod);
            Assert.IsNotNull(paymentMethod.Key);
            _paymentMethodVisa = paymentMethod;
        }
        private T CustomerAccountRequest(RecurringPaymentMethod paymentMethod, TransactionType type)
        {
            switch (type)
            {
            case TransactionType.Create:
                return(CreateCustomerAccount(paymentMethod));

            case TransactionType.Edit:
                return(UpdateCustomerAccount(paymentMethod));

            case TransactionType.Delete:
                return(DeleteCustomerAccount(paymentMethod));

            default:
                throw new UnsupportedTransactionException();
            }
        }
        public void recurring_004_AddPaymentCreditMasterCard()
        {
            if (_customerPerson == null)
            {
                Assert.Inconclusive();
            }

            var paymentMethod = _customerPerson.AddPaymentMethod(
                GetIdentifier("CreditMC"),
                new CreditCardData {
                Number   = "5473500000000014",
                ExpMonth = 12,
                ExpYear  = 2025
            }).Create();

            Assert.IsNotNull(paymentMethod);
            Assert.IsNotNull(paymentMethod.Key);
            _paymentMethodMasterCard = paymentMethod;
        }
Esempio n. 26
0
        public void Test_007d_ACHCharge_ScheduleId()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("ACH"));

            Assert.IsNotNull(paymentMethod, "Payment method missing.");

            var schedule = Schedule.Find(PaymentId("ACH"));

            Assert.IsNotNull(schedule, "Schedule is missing.");

            var response = paymentMethod.Charge(12m)
                           .WithCurrency("USD")
                           .WithScheduleId(schedule.Key)
                           .WithOneTimePayment(false)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 27
0
        public void StoredCredential_ReceiptIn_OTB()
        {
            RecurringPaymentMethod storedCard = new RecurringPaymentMethod("03e28f0e-492e-80bd-20ec318e9334", "3c4af936-483e-a393-f558bec2fb2a");

            StoredCredential storedCredential = new StoredCredential {
                Type      = StoredCredentialType.Recurring,
                Initiator = StoredCredentialInitiator.Merchant,
                Sequence  = StoredCredentialSequence.Subsequent
            };

            Transaction response = storedCard.Verify()
                                   .WithAllowDuplicates(true)
                                   .WithStoredCredential(storedCredential)
                                   .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            Assert.IsNotNull(response.SchemeId);
        }
Esempio n. 28
0
        public void Test_001h_CreateSchedule_Credit()
        {
            var paymentMethod = RecurringPaymentMethod.Find(PaymentId("Credit"));

            Assert.IsNotNull(paymentMethod);

            var schedule = paymentMethod.AddSchedule(PaymentId("Credit"))
                           .WithAmount(30.02m)
                           .WithCurrency("USD")
                           .WithStartDate(DateTime.Parse("02/01/2027"))
                           .WithFrequency(ScheduleFrequency.WEEKLY)
                           .WithStatus("Active")
                           .WithReprocessingCount(2)
                           .WithEndDate(DateTime.Parse("04/01/2027"))
                           .Create();

            Assert.IsNotNull(schedule);
            Assert.IsNotNull(schedule.Key);
        }
        private T DeleteCustomerAccount(RecurringPaymentMethod paymentMethod)
        {
            var et       = new ElementTree();
            var envelope = CreateSOAPEnvelope(et, "DeleteCustomerAccount");
            var request  = new DeleteCustomerAccountRequest(et)
                           .Build(envelope, Credentials, paymentMethod);

            var response = DoTransaction(request, publicEndpoint);

            var result = new SingleSignOnAccountResponse()
                         .WithResponseTagName("DeleteCustomerAccountResponse")
                         .WithResponse(response)
                         .Map();

            if (result.IsSuccessful)
            {
                return(paymentMethod as T);
            }

            throw new GatewayException(message: "An error occurred while deleting the customer account", responseCode: result.ResponseMessage, responseMessage: result.ResponseMessage);
        }
Esempio n. 30
0
        public void SeansLatestSNAFU()
        {
            // configure client & request settings
            ServicesContainer.ConfigureService(new GatewayConfig {
                MerchantId   = "seanmacdomhnalltest",
                AccountId    = "yoma",
                SharedSecret = "secret",
                ServiceUrl   = "https://api.sandbox.realexpayments.com/epage-remote.cgi"
            });

            // add obtained 3D Secure 2 authentication data
            var threeDSecureData = new ThreeDSecure()
            {
                AuthenticationValue          = "ODQzNjgwNjU0ZjM3N2JmYTg0NTM=",
                DirectoryServerTransactionId = "c272b04f-6e7b-43a2-bb78-90f4fb94aa25",
                Eci            = 5,
                MessageVersion = "2.1.0"
            };

            // supply existing customer/payer ref
            string customerId = "03e28f0e-4cf0-492e-80bd-20ec318e9334";
            // supply existing card/payment method ref
            string paymentId = "cdb398ac-8a0e-49f7-acf0-52a38832cfc9";

            // create the payment method object
            RecurringPaymentMethod paymentMethod = new RecurringPaymentMethod(customerId, paymentId)
            {
                ThreeDSecure = threeDSecureData
            };

            var orderId = "ezJDQjhENTZBLTdCNzNDQw"; // use the same Order ID from the Verify-Enrolled & Verify-Sig
                                                    // create the Authorization with 3D Secure information
            var response = paymentMethod.Charge(99.99m)
                           .WithOrderId(orderId)
                           .WithCurrency("EUR")
                           .Execute();

            Assert.IsNotNull(response);
        }