Exemplo n.º 1
0
        public async Task <ChargebackResponse> Chargeback(Chargeback data)
        {
            var validator   = new ChargebackValidator();
            var validResult = validator.Validate(data);

            if (validResult.IsValid)
            {
                var url    = _routes[_chargeback];
                var sender = new Sender <Chargeback, ChargebackResponse>();
                var result = await sender.Post(data, url);

                if (result != null)
                {
                    //if (result.Err != null)
                    //{
                    //    LogResultError(url, result.Err);
                    //}
                }
                else
                {
                    // Logger.Error("Could't recive data. Check internet connection.");
                }

                return(result);
            }
            else
            {
                var errors = validResult.Errors;
                LogErrors(errors);
            }

            return(null);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ChargebackOrder(OrderViewModel viewModel, ChargebackStatus chargebackStatus)
        {
            return(await ModifyOrderView("ChargebackDone", viewModel, async order =>
            {
                #region Fraud Protection Service
                var chargeback = new Chargeback
                {
                    ChargebackId = Guid.NewGuid().ToString(),
                    Amount = order.Total,
                    Currency = order.RiskPurchase?.Currency,
                    BankEventTimestamp = DateTimeOffset.Now,
                    Reason = viewModel.ReturnOrChargebackReason,
                    Status = chargebackStatus.ToString(),
                    PurchaseId = order.RiskPurchase.PurchaseId,
                    UserId = order.RiskPurchase.User.UserId,
                };

                var correlationId = _fraudProtectionService.NewCorrelationId;
                var response = await _fraudProtectionService.PostChargeback(chargeback, correlationId);

                var fraudProtectionIO = new FraudProtectionIOModel(correlationId, chargeback, response, "Chargeback");
                TempData.Put(FraudProtectionIOModel.TempDataKey, fraudProtectionIO);
                #endregion

                order.ReturnOrChargebackReason = viewModel.ReturnOrChargebackReason;
                order.Status = OrderStatus.ChargeBack;
                order.RiskChargeback = chargeback;
                order.RiskChargebackResponse = response;
            }));
        }
Exemplo n.º 3
0
        public void TestChargebackEvent()
        {
            var chargeback = new Chargeback
            {
                user_id           = "test_dotnet_chargeback_event",
                session_id        = "gigtleqddo84l8cm15qe4il",
                transaction_id    = "719637215",
                order_id          = "ORDER-123124124",
                chargeback_state  = "$lost",
                chargeback_reason = "$duplicate",

                merchant_profile = new MerchantProfile
                {
                    merchant_id            = "123",
                    merchant_category_code = "9876",
                    merchant_name          = "ABC Merchant",
                    merchant_address       = new Address
                    {
                        name      = "Bill Jones",
                        phone     = "1-415-555-6040",
                        address_1 = "2100 Main Street",
                        address_2 = "Apt 3B",
                        city      = "New London",
                        region    = "New Hampshire",
                        country   = "US",
                        zipcode   = "03257"
                    }
                }
            };

            // Augment with custom fields
            chargeback.AddField("foo", "bar");
            Assert.Equal("{\"$type\":\"$chargeback\",\"$user_id\":\"test_dotnet_chargeback_event\",\"$session_id\":\"gigtleqddo84l8cm15qe4il\"," +
                         "\"$order_id\":\"ORDER-123124124\",\"$transaction_id\":\"719637215\",\"$chargeback_state\":\"$lost\",\"$chargeback_reason\":\"$duplicate\"," +
                         "\"$merchant_profile\":{\"$merchant_id\":\"123\",\"$merchant_category_code\":\"9876\",\"$merchant_name\":\"ABC Merchant\",\"$merchant_address\":" +
                         "{\"$name\":\"Bill Jones\",\"$address_1\":\"2100 Main Street\",\"$address_2\":\"Apt 3B\",\"$city\":\"New London\",\"$region\":\"New Hampshire\"," +
                         "\"$country\":\"US\",\"$zipcode\":\"03257\",\"$phone\":\"1-415-555-6040\"}},\"foo\":\"bar\"}",
                         chargeback.ToJson());

            EventRequest eventRequest = new EventRequest
            {
                Event = chargeback
            };

            Assert.Equal("https://api.sift.com/v205/events", eventRequest.Request.RequestUri.ToString());

            eventRequest = new EventRequest
            {
                Event       = chargeback,
                AbuseTypes  = { "legacy", "payment_abuse" },
                ReturnScore = true
            };

            Assert.Equal("https://api.sift.com/v205/events?abuse_types=legacy,payment_abuse&return_score=true",
                         Uri.UnescapeDataString(eventRequest.Request.RequestUri.ToString()));
        }
Exemplo n.º 4
0
        //添加扣款
        public void AddChargeback(Chargeback chargeback)
        {
            _sqlConnection.Open();
            var sqlCommand = new SqlCommand(AddChargebackSql +
                                            Sem + chargeback.ChargebackEmployeeId + Sem + Comma
                                            + chargeback.ChargebackMoney + Comma
                                            + Sem + chargeback.ChargebackContent + "')", _sqlConnection);

            sqlCommand.ExecuteNonQuery();
            _sqlConnection.Close();
        }
Exemplo n.º 5
0
        public async Task <ResponseStatus> Chargeback(Chargeback chargeback, dynamic customFields = null, bool returnScore = false)
        {
            JObject json = JObject.Parse(JsonConvert.SerializeObject(chargeback, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            json.Add("$api_key", _apiKey);
            json.Add("$type", "$chargeback");
            AddCustomFields(customFields, json);

            return(await PostEvent(json.ToString(), returnScore).ConfigureAwait(false));
        }
Exemplo n.º 6
0
        //根据员工ID获得扣款
        public List <Chargeback> GetChargebacksById(string userId)
        {
            _sqlConnection.Open();
            var sqlCommand    = new SqlCommand(GetCharbackSql + userId, _sqlConnection);
            var reader        = sqlCommand.ExecuteReader();
            var chargbackList = new List <Chargeback>();

            while (reader.Read())
            {
                var chargeback = new Chargeback(reader["chargebackMoney"].ToString()
                                                , reader["chargebackContent"].ToString().Trim());
                chargbackList.Add(chargeback);
            }
            _sqlConnection.Close();
            return(chargbackList);
        }
        public async Task <FraudProtectionResponse> PostChargeback(Chargeback chargeback, string correlationId, string envId)
        {
            var response = await PostAsync(_settings.Endpoints.Chargeback, chargeback, correlationId, envId);

            return(await Read <FraudProtectionResponse>(response));
        }
Exemplo n.º 8
0
 public ChargebackEvent(Chargeback chargeback)
 {
     Chargeback = chargeback;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Use chargeback to capture a chargeback reported on a transaction. This event can be called multiple times to record changes to the chargeback state. Note - When you send a chargeback event you also need to send a label event if you want to prevent the user from making another purchase.
        /// </summary>
        /// <exception cref="ai.thirdwatch.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="JSON">Pass chargeback to thirdwatch. Only &#x60;_userID&#x60; is required field. But this should contain chargeback info.</param>
        /// <returns>Task of ApiResponse (EventResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <EventResponse> > ChargebackAsyncWithHttpInfo(Chargeback JSON)
        {
            // verify the required parameter 'JSON' is set
            if (JSON == null)
            {
                throw new ApiException(400, "Missing required parameter 'JSON' when calling ChargebackApi->Chargeback");
            }

            var    localVarPath         = "/v1/chargeback";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (JSON != null && JSON.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(JSON); // http body (model) parameter
            }
            else
            {
                localVarPostBody = JSON; // byte array
            }

            // authentication (api_key) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("X-THIRDWATCH-API-KEY")))
            {
                localVarHeaderParams["X-THIRDWATCH-API-KEY"] = Configuration.GetApiKeyWithPrefix("X-THIRDWATCH-API-KEY");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("Chargeback", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <EventResponse>(localVarStatusCode,
                                                   localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                   (EventResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(EventResponse))));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Use chargeback to capture a chargeback reported on a transaction. This event can be called multiple times to record changes to the chargeback state. Note - When you send a chargeback event you also need to send a label event if you want to prevent the user from making another purchase.
        /// </summary>
        /// <exception cref="ai.thirdwatch.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="JSON">Pass chargeback to thirdwatch. Only &#x60;_userID&#x60; is required field. But this should contain chargeback info.</param>
        /// <returns>Task of EventResponse</returns>
        public async System.Threading.Tasks.Task <EventResponse> ChargebackAsync(Chargeback JSON)
        {
            ApiResponse <EventResponse> localVarResponse = await ChargebackAsyncWithHttpInfo(JSON);

            return(localVarResponse.Data);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Use chargeback to capture a chargeback reported on a transaction. This event can be called multiple times to record changes to the chargeback state. Note - When you send a chargeback event you also need to send a label event if you want to prevent the user from making another purchase.
        /// </summary>
        /// <exception cref="ai.thirdwatch.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="JSON">Pass chargeback to thirdwatch. Only &#x60;_userID&#x60; is required field. But this should contain chargeback info.</param>
        /// <returns>EventResponse</returns>
        public EventResponse Chargeback(Chargeback JSON)
        {
            ApiResponse <EventResponse> localVarResponse = ChargebackWithHttpInfo(JSON);

            return(localVarResponse.Data);
        }