mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Showing refunds and finding both paypal and stripe refunds in premium history.
This commit is contained in:
parent
d02825eedd
commit
ae6bbc0aec
3 changed files with 12 additions and 7 deletions
|
@ -519,9 +519,8 @@ class Profile(models.Model):
|
|||
logging.user(self.user, f"~FRCouldn't find paypal transactions: ~SB{paypal_id}")
|
||||
continue
|
||||
for transaction in transactions['transactions']:
|
||||
import pdb; pdb.set_trace()
|
||||
created = dateutil.parser.parse(transaction['time'])
|
||||
if transaction['status'] not in ['COMPLETED', 'PARTIALLY_REFUNDED']: continue
|
||||
if transaction['status'] not in ['COMPLETED', 'PARTIALLY_REFUNDED', 'REFUNDED']: continue
|
||||
if created in seen_payments: continue
|
||||
seen_payments.add(created)
|
||||
total_paypal_payments += 1
|
||||
|
@ -561,10 +560,14 @@ class Profile(models.Model):
|
|||
if created in seen_payments: continue
|
||||
seen_payments.add(created)
|
||||
total_stripe_payments += 1
|
||||
refunded = None
|
||||
if payment.refunded:
|
||||
refunded = True
|
||||
PaymentHistory.objects.get_or_create(user=self.user,
|
||||
payment_date=created,
|
||||
payment_amount=payment.amount / 100.0,
|
||||
payment_provider='stripe')
|
||||
payment_provider='stripe',
|
||||
refunded=refunded)
|
||||
else:
|
||||
logging.user(self.user, "~FBNo Stripe payments")
|
||||
|
||||
|
@ -746,7 +749,7 @@ class Profile(models.Model):
|
|||
if days_since < 365:
|
||||
days_left = (365 - days_since)
|
||||
pct_left = days_left/365
|
||||
refund_amount = pct_left * refund_amount * 0.5
|
||||
refund_amount = pct_left * refund_amount
|
||||
else:
|
||||
logging.user(self.user, f"~FRCouldn't prorate paypal payment, too old: ~SB{transaction}")
|
||||
try:
|
||||
|
@ -765,7 +768,7 @@ class Profile(models.Model):
|
|||
logging.user(self.user, f"Paypal refund response: {response}")
|
||||
if 'status' in response and response['status'] == "COMPLETED":
|
||||
refunded = int(float(transaction['amount_with_breakdown']['gross_amount']['value']))
|
||||
logging.user(self.user, "~FRRefunding paypal payment: $%s" % refunded)
|
||||
logging.user(self.user, "~FRRefunding paypal payment: $%s/%s" % (refund_amount, refunded))
|
||||
else:
|
||||
logging.user(self.user, "~FRCouldn't refund paypal payment: %s" % response)
|
||||
refunded = response
|
||||
|
@ -1841,6 +1844,7 @@ class PaymentHistory(models.Model):
|
|||
'payment_date': self.payment_date.strftime('%Y-%m-%d'),
|
||||
'payment_amount': self.payment_amount,
|
||||
'payment_provider': self.payment_provider,
|
||||
'refunded': self.refunded,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -11220,7 +11220,8 @@ form.opml_import_form input {
|
|||
.NB-account-payments .NB-scheduled .NB-account-payment-provider {
|
||||
color: darkgrey;
|
||||
}
|
||||
.NB-account-payments .NB-scheduled.NB-canceled .NB-account-payment-provider {
|
||||
.NB-account-payments .NB-scheduled.NB-canceled .NB-account-payment-provider,
|
||||
.NB-account-payments .NB-refunded .NB-account-payment-amount {
|
||||
text-decoration: line-through;
|
||||
color: darkred;
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ _.extend(NEWSBLUR.ReaderAccount.prototype, {
|
|||
}
|
||||
_.each(data.payments, function (payment) {
|
||||
var date = new Date(payment.payment_date);
|
||||
$history.append($.make('li', { className: 'NB-account-payment ' + (payment.scheduled ? 'NB-scheduled' : '') }, [
|
||||
$history.append($.make('li', { className: 'NB-account-payment ' + (payment.scheduled ? ' NB-scheduled' : '') + (payment.refunded ? ' NB-refunded' : '') }, [
|
||||
$.make('div', { className: 'NB-account-payment-date' }, date.format("F d, Y")),
|
||||
$.make('div', { className: 'NB-account-payment-amount' }, "$" + payment.payment_amount),
|
||||
$.make('div', { className: 'NB-account-payment-provider' }, payment.payment_provider)
|
||||
|
|
Loading…
Add table
Reference in a new issue