public async Task <ResponseWithLinks <DetailedTransaction> > RefundTransaction(string resourceIdentifier, decimal?amount = null)
        {
            var requestBody = new RequestWithData <RefundTransaction>
            {
                data = new RefundTransaction
                {
                    amount = Convert.ToInt32(amount * 100)
                }
            };

            if (!amount.HasValue)
            {
                requestBody = null;
            }

            var request = new RestRequest($"/v1/transaction/{resourceIdentifier}/refund", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddJsonBody(requestBody);

            var response = await _resourceClient.ExecuteTaskAsync <ResponseWithLinks <DetailedTransaction> >(request);

            if (response.Data == null)
            {
                throw new Exception(response.Content);
            }

            return(response.Data);
        }
Exemple #2
0
        public async Task <ResponseWithLinks <DetailedTransaction> > AuthorizeSubscription(string resourceIdentifier, decimal amount, string orderId)
        {
            var requestBody = new RequestWithData <SubscriptionAuthorize>
            {
                data = new SubscriptionAuthorize
                {
                    amount   = Convert.ToInt32(amount * 100),
                    order_id = orderId
                }
            };

            var request = new RestRequest($"/v1/subscription/{resourceIdentifier}/authorize", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddJsonBody(requestBody);

            var response = await _resourceClient.ExecuteTaskAsync <ResponseWithLinks <DetailedTransaction> >(request);

            if (response.Data == null)
            {
                throw new Exception(response.Content);
            }

            return(response.Data);
        }