public bool Equals(RecurlyTransaction transaction)
 {
     return this.Id == transaction.Id;
 }
        public static RecurlyTransaction Get(string appName, string transactionId)
        {
            RecurlyTransaction transaction = new RecurlyTransaction();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(appName, RecurlyClient.HttpRequestMethod.Get,
                UrlPrefix + System.Web.HttpUtility.UrlEncode(transactionId),
                new RecurlyClient.ReadXmlDelegate(transaction.ReadXml));

            if (statusCode == HttpStatusCode.NotFound)
                return null;

            return transaction;
        }
        public static RecurlyTransaction CreateAccountTransaction(string accountCode, int amountInCents, string description)
        {
            var transaction = new RecurlyTransaction { AccountCode = accountCode, AmountInCents = amountInCents, Description = description };

            var resultCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                               UrlPrefix,
                                               new RecurlyClient.WriteXmlDelegate(transaction.WriteXml),
                                               new RecurlyClient.ReadXmlDelegate(transaction.ReadXml));

            return transaction;
        }
        public static void Create(RecurlyAccount acct, int amountInCents, string description)
        {
            RecurlyTransaction toCreate = new RecurlyTransaction();

            toCreate.Account = acct;
            toCreate.AmountInCents = amountInCents;
            toCreate.Description = description;

            RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                UrlPrefix,
                new RecurlyClient.WriteXmlDelegate(toCreate.WriteXml));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a list of transactions for an account.
 /// </summary>
 /// <param name="state">The state of transactions to return</param>
 /// <param name="type">The type of transactions to return</param>
 /// <param name="pageSize">Number of records to return per page</param>
 /// <returns></returns>
 public RecurlyTransactionList ListTransactions(RecurlyTransaction.TransactionState state =
                                                    RecurlyTransaction.TransactionState.All,
                                                RecurlyTransaction.TransactionType type =
                                                    RecurlyTransaction.TransactionType.All,
                                                int pageSize = RecurlyPager.DefaultPageSize)
 {
     return RecurlyTransactionList.ListAccountTransactions(AccountCode, state, type, pageSize);
 }
        /// <summary>
        /// If the transaction has not settled and you perform a full refund, the transaction will be voided instead. Voided transactions typically do not show up on the customer's card statement. If the transaction has settled, a refund will be performed.
        /// If the transaction has not settled and you attempt a partial refund, the request will fail. Please wait until the transaction has settled (typically 24 hours) before performing a partial refund. This advice varies depending on when your payment gateway settles the transaction.
        /// </summary>
        /// <param name="amountInCents">The amount (in cents) to refund (refunds fully if null or not provided).</param>
        /// <returns>The updated original transaction if voided, a new refund transaction, or null if the transaction isn't voidable or refundable.</returns>
        public RecurlyTransaction Refund(int? amountInCents = null)
        {
            var transaction = new RecurlyTransaction();

            var statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Delete,
                String.Format(Settings.Default.PathTransactionRefund, Id.UrlEncode(), amountInCents.HasValue ? amountInCents.Value.ToString(CultureInfo.InvariantCulture) : String.Empty),
                                         reader =>
                                             {
                                                 var element = XDocument.Load(reader).Root;
                                                 transaction.ReadElement(element);
                                                 if (transaction.Id == Id)
                                                     ReadElement(element);
                                             });

            return RecurlyClient.OkOrAccepted(statusCode) ? transaction.Id == Id ? this : transaction : null;
        }
        /// <summary>
        /// Lists details for an individual transaction.
        /// </summary>
        /// <param name="transactionId"></param>
        /// <returns></returns>
        public static RecurlyTransaction Get(string transactionId)
        {
            var transaction = new RecurlyTransaction();

            var statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                String.Format(Settings.Default.PathTransactionGet, transactionId.UrlEncode()),
                transaction.ReadXml);

            return statusCode == HttpStatusCode.OK ? transaction : null;
        }