Пример #1
0
        public void DoErrorCreditCardSale()
        {
            // Arrange
            AcquirerClientSaleService Service = new AcquirerClientSaleService();
            AcquirerSale    AcquirerSale      = this.GetNewAcquirerSale();
            string          ErrorRawResponse;
            HttpUtilityMock HttpUtilityMock = new HttpUtilityMock();

            // Act
            ErrorRawResponse = "{    \"MerchantOrderId\": \"2014111706\",    \"Customer\": {        \"Name\": \"Comprador crédito simples\"    },    \"Payment\": {        \"ServiceTaxAmount\": 0,        \"Installments\": 1,        \"Interest\": \"ByMerchant\",        \"Capture\": false,        \"Authenticate\": false,        \"CreditCard\": {            \"CardNumber\": \"455187******0183\",            \"Holder\": \"Teste Holder\",            \"ExpirationDate\": \"12/2030\",            \"SaveCard\": false,            \"Brand\": \"Visa\"        },        \"ProofOfSale\": \"674532\",        \"Tid\": \"0305023644309\",        \"AuthorizationCode\": \"123456\",        \"PaymentId\": \"24bc8366-fc31-4d6c-8555-17049a836a07\",        \"Type\": \"CreditCard\",        \"Amount\": 15700,        \"Currency\": \"BRL\",        \"Country\": \"BRA\",        \"ExtraDataCollection\": [],        \"Status\": 1,        \"ReturnCode\": \"4\",        \"ReturnMessage\": \"Operation Successful\",        \"Links\": [            {                \"Method\": \"GET\",                \"Rel\": \"self\",                \"Href\": \"https://apiquerysandbox.cieloecommerce.cielo.com.br/1/sales/{PaymentId}\"        },            {                \"Method\": \"PUT\",                \"Rel\": \"capture\",                \"Href\": \"https://apisandbox.cieloecommerce.cielo.com.br/1/sales/{PaymentId}/capture\"            },            {                \"Method\": \"PUT\",                \"Rel\": \"void\",                \"Href\": \"https://apisandbox.cieloecommerce.cielo.com.br/1/sales/{PaymentId}/void\"            }        ]    }}";
            HttpUtilityMock.MockRawResponse = ErrorRawResponse;
            HttpUtilityMock.MockStatusCode  = System.Net.HttpStatusCode.BadRequest;
            Service.HttpUtility             = HttpUtilityMock;
            Service.Create(ref AcquirerSale);
            // Assert
            Assert.True(AcquirerSale.AcquirerSuccess == false);
        }
        public void DoSuccessCreditCardSale()
        {
            // Arrange
            AcquirerClientSaleService Service = new AcquirerClientSaleService();
            AcquirerSale    AcquirerSale      = this.GetNewAcquirerSale();
            string          SuccessRawResponse;
            HttpUtilityMock HttpUtilityMock = new HttpUtilityMock();

            // Act
            SuccessRawResponse = "{\"ErrorReport\": null,  \"InternalTime\": 137,  \"MerchantKey\": \"F2A1F485-CFD4-49F5-8862-0EBC438AE923\",  \"RequestKey\": \"857a5a07-ff3c-46e3-946e-452e25f149eb\",  \"BoletoTransactionResultCollection\": [],  \"BuyerKey\": \"00000000-0000-0000-0000-000000000000\",  \"CreditCardTransactionResultCollection\": [    {      \"AcquirerMessage\": \"Simulator|Transação de simulação autorizada com sucesso\",      \"AcquirerName\": \"Simulator\",      \"AcquirerReturnCode\": \"0\",      \"AffiliationCode\": \"000000000\",      \"AmountInCents\": 10000,      \"AuthorizationCode\": \"168147\",      \"AuthorizedAmountInCents\": 10000,      \"CapturedAmountInCents\": 10000,      \"CapturedDate\": \"2015-12-04T19:51:11\",      \"CreditCard\": {        \"CreditCardBrand\": \"Visa\",        \"InstantBuyKey\": \"3b3b5b62-6660-428d-905e-96f49d46ae28\",        \"IsExpiredCreditCard\": false,        \"MaskedCreditCardNumber\": \"411111****1111\"      },      \"CreditCardOperation\": \"AuthAndCapture\",      \"CreditCardTransactionStatus\": \"Captured\",      \"DueDate\": null,      \"ExternalTime\": 0,      \"PaymentMethodName\": \"Simulator\",      \"RefundedAmountInCents\": null,      \"Success\": true,      \"TransactionIdentifier\": \"246844\",      \"TransactionKey\": \"20ba0520-7d09-44f8-8fbc-e4329e2b18d5\",      \"TransactionKeyToAcquirer\": \"20ba05207d0944f8\",      \"TransactionReference\": \"1c65eaf7-df3c-4c7f-af63-f90fb6200996\",      \"UniqueSequentialNumber\": \"636606\",      \"VoidedAmountInCents\": null    }  ],  \"OrderResult\": {    \"CreateDate\": \"2015-12-04T19:51:11\",    \"OrderKey\": \"219d7581-78e2-4aa9-b708-b7c585780bfc\",    \"OrderReference\": \"NúmeroDoPedido\"  }}";
            HttpUtilityMock.MockRawResponse = SuccessRawResponse;
            HttpUtilityMock.MockStatusCode  = System.Net.HttpStatusCode.Created;
            Service.HttpUtility             = HttpUtilityMock;
            Service.Create(ref AcquirerSale);
            // Assert
            Assert.True(AcquirerSale.AcquirerSuccess == true);
        }
        public void DoErrorCreditCardSale()
        {
            // Arrange
            AcquirerClientSaleService Service = new AcquirerClientSaleService();
            AcquirerSale    AcquirerSale      = this.GetNewAcquirerSale();
            string          ErrorRawResponse;
            HttpUtilityMock HttpUtilityMock = new HttpUtilityMock();

            // Act
            ErrorRawResponse = "{  \"ErrorReport\": {    \"Category\": \"RequestError\",    \"ErrorItemCollection\": [      {        \"Description\": \"A bandeira Invalida atualmente não é suportada.\",        \"ErrorCode\": 400,        \"ErrorField\": \"CreditCardBrand\",        \"SeverityCode\": \"Error\"      }    ]  },  \"InternalTime\": 0,  \"MerchantKey\": \"F2A1F485-CFD4-49F5-8862-0EBC438AE923\",  \"RequestKey\": \"fb0f6d14-3564-4ac2-bc88-9d319816b966\",  \"BuyerKey\": \"00000000-0000-0000-0000-000000000000\",}";
            HttpUtilityMock.MockRawResponse = ErrorRawResponse;
            HttpUtilityMock.MockStatusCode  = System.Net.HttpStatusCode.BadRequest;
            Service.HttpUtility             = HttpUtilityMock;
            Service.Create(ref AcquirerSale);
            // Assert
            Assert.True(AcquirerSale.AcquirerSuccess == false);
        }
Пример #4
0
        public void DoDeniedAuthorization()
        {
            // Arrange
            AntifraudClientService Service      = new AntifraudClientService();
            AcquirerSale           AcquirerSale = this.GetNewAcquirerSale();
            string          SuccessRawResponse;
            HttpUtilityMock HttpUtilityMock = new HttpUtilityMock();

            // Act
            SuccessRawResponse = "{\"Orders\": [{                \"ID\": \"1\",\"Status\":\"RPM\",\"Score\": \"1\"}],\"TransactionID\":\"BRA\"}";
            HttpUtilityMock.MockRawResponse = SuccessRawResponse;
            HttpUtilityMock.MockStatusCode  = System.Net.HttpStatusCode.OK;
            Service.HttpUtility             = HttpUtilityMock;
            Service.Execute(ref AcquirerSale);
            // Assert
            Assert.True(AcquirerSale.Authorized == false);
        }