Ejemplo n.º 1
0
        public void FinancialOperation_Rejected_Purchase()
        {
            var request = GetRequest();

            request.alias.aliasName = "351#911212212"; // FAKE FORCE REJECT
            var amount       = 70;                     //0.70€
            var operationId  = MBWayClient.GetUniqID();
            var currencyCode = CurrencyCodes.EURO_TWO_DECIMALS;

            request.financialOperation = new financialOperation
            {
                amount            = amount,
                currencyCode      = currencyCode,
                merchantOprId     = operationId,
                operationTypeCode = FinancialOperationTypes.PURCHASE
            };

            var result = this.GetClient().RequestFinancialOperation(request);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(amount, result.amount);
            Assert.AreEqual("113", result.statusCode);
            Assert.AreEqual(currencyCode, result.currencyCode);
            Assert.IsTrue(string.IsNullOrEmpty(result.token));
            Assert.IsNotNull(result.timestamp);

            currentResult = result;
        }
Ejemplo n.º 2
0
        public void FinancialOperation_PurchaseAuthorization()
        {
            var request = GetRequest();

            var amount       = 70; //0.70€
            var operationId  = MBWayClient.GetUniqID();
            var currencyCode = CurrencyCodes.EURO_TWO_DECIMALS;

            request.financialOperation = new financialOperation
            {
                amount            = amount,
                currencyCode      = currencyCode,
                merchantOprId     = operationId,
                operationTypeCode = FinancialOperationTypes.PURCHASE_AUTHORIZATION
            };

            var result = this.GetClient().RequestFinancialOperation(request);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(amount, result.amount);
            Assert.AreEqual(operationId, result.merchantOperationID);
            Assert.AreEqual(currencyCode, result.currencyCode);
            Assert.IsTrue(!string.IsNullOrEmpty(result.token));
            Assert.IsNotNull(result.timestamp);

            currentResult = result;
        }
Ejemplo n.º 3
0
        protected MBWayClient GetClient()
        {
            if (client != null)
                return client;

            client = new MBWayClient(this.GetConfig(), true);

            return client;
        }
Ejemplo n.º 4
0
        protected MBWayClient GetClient()
        {
            if (client != null)
            {
                return(client);
            }

            client = new MBWayClient(this.GetConfig(), true);

            return(client);
        }
Ejemplo n.º 5
0
        public void Config_WithCertificateThumbprint()
        {
            var config = new MBWayConfig
            {
                CertificateThumbprint = ConfigurationManager.AppSettings["CERTIFICATE_THUMBPRINT"],
                MerchantIP            = ConfigurationManager.AppSettings["MERCHANT_IP"],
                MerchantPOSID         = ConfigurationManager.AppSettings["MERCHANT_POSID"],
                AsyncServiceEndpoint  = ConfigurationManager.AppSettings["ASYNC_SERVICE_ENDPOINT"]
            };

            Assert.IsNotNull(config);

            var client = new MBWayClient(config);

            Assert.IsNotNull(client);
        }
Ejemplo n.º 6
0
        public void Config_WithCertificateThumbprintFail()
        {
            var config = new MBWayConfig
            {
                CertificateThumbprint = "123123123123",
                MerchantIP            = ConfigurationManager.AppSettings["MERCHANT_IP"],
                MerchantPOSID         = ConfigurationManager.AppSettings["MERCHANT_POSID"],
                AsyncServiceEndpoint  = ConfigurationManager.AppSettings["ASYNC_SERVICE_ENDPOINT"]
            };

            Assert.IsNotNull(config);

            MBWayClient client = null;

            AssertThrows <ApplicationException>(() =>
            {
                client = new MBWayClient(config);
            });
            Assert.IsNull(client);
        }
Ejemplo n.º 7
0
        public void Config_WithCertificatePathFail()
        {
            var config = new MBWayConfig
            {
                CertificatePass      = @"c:\path\to\nowhere.pfx",
                CertificatePath      = "NotThePassword!",
                MerchantIP           = ConfigurationManager.AppSettings["MERCHANT_IP"],
                MerchantPOSID        = ConfigurationManager.AppSettings["MERCHANT_POSID"],
                AsyncServiceEndpoint = ConfigurationManager.AppSettings["ASYNC_SERVICE_ENDPOINT"]
            };

            Assert.IsNotNull(config);

            MBWayClient client = null;

            AssertThrows <ApplicationException>(() =>
            {
                client = new MBWayClient(config);
            });
            Assert.IsNull(client);
        }
Ejemplo n.º 8
0
        public void FinancialOperation_PurchaseAfterAuthorization()
        {
            FinancialOperation_PurchaseAuthorization();

            Assert.IsNotNull(currentResult);
            Assert.IsTrue(currentResult.IsValid);

            ApprovalSleep(); // allow for aproval in app and async callback

            var request = GetRequest();

            request.referencedFinancialOperation = new financialOperation
            {
                amount            = currentResult.amount,
                currencyCode      = currentResult.currencyCode,
                merchantOprId     = currentResult.merchantOperationID,
                operationTypeCode = FinancialOperationTypes.PURCHASE_AUTHORIZATION
            };


            var newOperationId = MBWayClient.GetUniqID();

            request.financialOperation = new financialOperation
            {
                amount            = currentResult.amount,
                currencyCode      = currentResult.currencyCode,
                merchantOprId     = newOperationId,
                operationTypeCode = FinancialOperationTypes.PURCHASE_AFTER_AUTHORIZATION
            };

            var result = this.GetClient().RequestFinancialOperation(request);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(currentResult.amount, result.amount);
            Assert.AreEqual(newOperationId, result.merchantOperationID);
            Assert.AreEqual(currentResult.currencyCode, result.currencyCode);
            Assert.IsNotNull(result.timestamp);

            currentResult = result;
        }
Ejemplo n.º 9
0
        public void FinancialOperation_Purchase_Annulment()
        {
            FinancialOperation_Purchase();

            Assert.IsNotNull(currentResult);
            Assert.IsTrue(currentResult.IsValid);

            var request = GetRequest();

            request.referencedFinancialOperation = new financialOperation
            {
                amount            = currentResult.amount,
                currencyCode      = currentResult.currencyCode,
                merchantOprId     = currentResult.merchantOperationID,
                operationTypeCode = FinancialOperationTypes.PURCHASE
            };


            var newOperationId = MBWayClient.GetUniqID();

            request.financialOperation = new financialOperation
            {
                amount            = currentResult.amount,
                currencyCode      = currentResult.currencyCode,
                merchantOprId     = newOperationId,
                operationTypeCode = FinancialOperationTypes.ANNULMENT
            };

            var result = this.GetClient().RequestFinancialOperation(request);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(currentResult.amount, result.amount);
            Assert.AreEqual(newOperationId, result.merchantOperationID);
            Assert.AreEqual(currentResult.currencyCode, result.currencyCode);
            Assert.IsNotNull(result.timestamp);
        }