Add Protocoin to Paymaster

This commit is contained in:
2022-08-22 22:15:03 +00:00
parent 1c225da510
commit 1444a52a11
4 changed files with 45 additions and 9 deletions

View File

@@ -78,7 +78,7 @@ class Transaction(models.Model):
paypal_txn_id = models.CharField(max_length=17, blank=True, null=True, unique=True)
paypal_txn_type = models.CharField(max_length=64, blank=True, null=True)
paypal_payer_id = models.CharField(max_length=13, blank=True, null=True)
protocoin = models.DecimalField(max_digits=7, decimal_places=2)
protocoin = models.DecimalField(max_digits=7, decimal_places=2, default=0)
report_type = models.TextField(blank=True, null=True)
report_memo = models.TextField(blank=True, null=True)

View File

@@ -243,23 +243,33 @@ def check_training(data, training_id, amount):
logger.info('IPN - Amount valid for training cost, id: ' + str(training.id))
return create_member_training_tx(data, member, training)
def create_category_tx(data, member, custom_json):
def create_category_tx(data, member, custom_json, amount):
transactions = models.Transaction.objects
user = getattr(member, 'user', None)
category = custom_json['category']
if category == 'Exchange':
protocoin = amount
note = '{} Protocoin Purchase'.format(amount)
else:
protocoin = 0
note = custom_json.get('memo', 'none')
memo = '{} {} - {}, email: {}, note: {}'.format(
data.get('first_name', 'unknown'),
data.get('last_name', 'unknown'),
custom_json['category'],
category,
data.get('payer_email', 'unknown'),
custom_json.get('memo', 'none'),
note,
)
return transactions.create(
**build_tx(data),
category=custom_json['category'],
category=category,
memo=memo,
user=user,
protocoin=protocoin,
)
@@ -354,10 +364,10 @@ def process_paypal_ipn(data):
defaults=dict(user=user),
)
if custom_json.get('category', False) in ['Snacks', 'OnAcct', 'Donation', 'Consumables', 'Purchases']:
if custom_json.get('category', False) in ['Snacks', 'OnAcct', 'Donation', 'Consumables', 'Purchases', 'Exchange']:
logger.info('IPN - Category matched')
update_ipn(ipn, 'Accepted, category')
return create_category_tx(data, member, custom_json)
return create_category_tx(data, member, custom_json, amount)
monthly_fees = member.monthly_fees