/// <summary>
        /// Request money
        /// Use this method to request funds from a source user, originating 
        /// from the user associated with the authorized access token.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public DwollaResponse<string> Request(RequestTransactionOptions options)
        {
            var url = Urls.Requests + "?oauth_token=" +
                HttpUtility.UrlEncode(options.OAuthToken);

            var client = new RestClient();

            var data = new {
                sourceId = options.SourceId,
                sourceType = options.SourceType,
                amount = options.Amount,
                facilitatorAmount = options.FacilitatorAmount,
                notes = options.Notes
            };

            var request = new RestRequest(url, Method.POST) {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(data);

            var response = client.Execute(request);

            return Mapper<DwollaResponse<string>>.MapFromJson(response.Content);
        }
        /// <summary>
        /// Request money
        /// Use this method to request funds from a source user, originating
        /// from the user associated with the authorized access token.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public DwollaResponse <string> Request(RequestTransactionOptions options)
        {
            var url = Urls.Requests + "?oauth_token=" +
                      HttpUtility.UrlEncode(options.OAuthToken);

            var client = new RestClient();

            var data = new {
                sourceId          = options.SourceId,
                sourceType        = options.SourceType,
                amount            = options.Amount,
                facilitatorAmount = options.FacilitatorAmount,
                notes             = options.Notes
            };

            var request = new RestRequest(url, Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(data);

            var response = client.Execute(request);

            return(Mapper <DwollaResponse <string> > .MapFromJson(response.Content));
        }
Beispiel #3
0
        public void It_should_make_transaction_request()
        {
            // arrange
            var requestService = new DwollaRequestService();

            var options = new RequestTransactionOptions {
                // required options
                OAuthToken = TestOAuthToken,
                SourceId = _dwollaReflectorId,
                Amount = new decimal(1.50),

                // optional
                SourceType = "Dwolla"
            };

            // act
            DwollaResponse<string> response = requestService.Request(options);

            // assert
            response.Success.ShouldBeTrue();
        }