예제 #1
0
        public static Transaction MapToTransaction(StripeBalanceTransaction transaction, StripeCharge charge)
        {
            string donorName;
            string donorEmail;
            string donorId;
            string designation;
            string recurringDonation;

            charge.Metadata.TryGetValue("donorbox_name", out donorName);
            charge.Metadata.TryGetValue("donorbox_email", out donorEmail);
            charge.Metadata.TryGetValue("donorbox_donor_id", out donorId);
            charge.Metadata.TryGetValue("donorbox_designation", out designation);
            charge.Metadata.TryGetValue("donorbox_recurring_donation", out recurringDonation);

            return(new Transaction
            {
                TransactionId = transaction.Id,
                Source = "DonorBox",
                DonorName = donorName,
                DonorEmail = donorEmail,
                DonorId = donorId,
                PaymentMethod = GetPaymentMethod(charge),
                Amount = decimal.Divide(transaction.Amount, 100),
                Fee = decimal.Divide(transaction.Fee, 100),
                Net = decimal.Divide(transaction.Net, 100),
                Currency = transaction.Currency.ToUpper(),
                PaymentDetails = designation,
                RecurringDonation = recurringDonation == "true",
                TransactionDate = transaction.Created,
                PostedDate = transaction.AvailableOn
            });
        }
예제 #2
0
        internal static BalanceTransaction TransformStripeBalanceTransactionToBalanceTransaction(StripeBalanceTransaction stripeBalanceTransaction)
        {
            try
            {
                var balanceTransaction = new BalanceTransaction
                {
                    BalanceTransactionID = stripeBalanceTransaction.Id,
                    Amount = Sahara.Core.Common.Methods.Billing.ConvertStripeAmountToDecimals(stripeBalanceTransaction.Amount.ToString()),
                    Net    = Sahara.Core.Common.Methods.Billing.ConvertStripeAmountToDecimals(stripeBalanceTransaction.Net.ToString()),
                    Fee    = Sahara.Core.Common.Methods.Billing.ConvertStripeAmountToDecimals(stripeBalanceTransaction.Fee.ToString()),

                    Type   = stripeBalanceTransaction.Type,
                    Status = stripeBalanceTransaction.Status,

                    Created   = stripeBalanceTransaction.Created,
                    Available = stripeBalanceTransaction.AvailableOn
                };

                if (balanceTransaction.Type == "transfer")
                {
                    balanceTransaction.Amount = Math.Abs(balanceTransaction.Amount);
                    balanceTransaction.Net    = Math.Abs(balanceTransaction.Net);
                }

                return(balanceTransaction);
            }
            catch
            {
                return(null);
            }
        }