Add Protocoin to Paymaster
This commit is contained in:
parent
1c225da510
commit
1444a52a11
|
@ -78,7 +78,7 @@ class Transaction(models.Model):
|
||||||
paypal_txn_id = models.CharField(max_length=17, blank=True, null=True, unique=True)
|
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_txn_type = models.CharField(max_length=64, blank=True, null=True)
|
||||||
paypal_payer_id = models.CharField(max_length=13, 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_type = models.TextField(blank=True, null=True)
|
||||||
report_memo = models.TextField(blank=True, null=True)
|
report_memo = models.TextField(blank=True, null=True)
|
||||||
|
|
|
@ -243,23 +243,33 @@ def check_training(data, training_id, amount):
|
||||||
logger.info('IPN - Amount valid for training cost, id: ' + str(training.id))
|
logger.info('IPN - Amount valid for training cost, id: ' + str(training.id))
|
||||||
return create_member_training_tx(data, member, training)
|
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
|
transactions = models.Transaction.objects
|
||||||
|
|
||||||
user = getattr(member, 'user', None)
|
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(
|
memo = '{} {} - {}, email: {}, note: {}'.format(
|
||||||
data.get('first_name', 'unknown'),
|
data.get('first_name', 'unknown'),
|
||||||
data.get('last_name', 'unknown'),
|
data.get('last_name', 'unknown'),
|
||||||
custom_json['category'],
|
category,
|
||||||
data.get('payer_email', 'unknown'),
|
data.get('payer_email', 'unknown'),
|
||||||
custom_json.get('memo', 'none'),
|
note,
|
||||||
)
|
)
|
||||||
|
|
||||||
return transactions.create(
|
return transactions.create(
|
||||||
**build_tx(data),
|
**build_tx(data),
|
||||||
category=custom_json['category'],
|
category=category,
|
||||||
memo=memo,
|
memo=memo,
|
||||||
user=user,
|
user=user,
|
||||||
|
protocoin=protocoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,10 +364,10 @@ def process_paypal_ipn(data):
|
||||||
defaults=dict(user=user),
|
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')
|
logger.info('IPN - Category matched')
|
||||||
update_ipn(ipn, 'Accepted, category')
|
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
|
monthly_fees = member.monthly_fees
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ export function Paymaster(props) {
|
||||||
const [pop, setPop] = useState('20.00');
|
const [pop, setPop] = useState('20.00');
|
||||||
const [locker, setLocker] = useState('5.00');
|
const [locker, setLocker] = useState('5.00');
|
||||||
const [consumables, setConsumables] = useState('20.00');
|
const [consumables, setConsumables] = useState('20.00');
|
||||||
|
const [buyProtocoin, setBuyProtocoin] = useState('10.00');
|
||||||
const [consumablesMemo, setConsumablesMemo] = useState('');
|
const [consumablesMemo, setConsumablesMemo] = useState('');
|
||||||
const [donate, setDonate] = useState('20.00');
|
const [donate, setDonate] = useState('20.00');
|
||||||
const [memo, setMemo] = useState('');
|
const [memo, setMemo] = useState('');
|
||||||
|
@ -20,6 +21,31 @@ export function Paymaster(props) {
|
||||||
<Header size='large'>Paymaster</Header>
|
<Header size='large'>Paymaster</Header>
|
||||||
<p>Use these buttons to send money to Protospace.</p>
|
<p>Use these buttons to send money to Protospace.</p>
|
||||||
|
|
||||||
|
<Header size='medium'>Protocoin</Header>
|
||||||
|
<p>Protocoin is used to buy things at Protospace's vending machines. Current balance: ₱ {user.member.protocoin}</p>
|
||||||
|
|
||||||
|
<Grid stackable padded columns={3}>
|
||||||
|
<Grid.Column>
|
||||||
|
Buy {buyProtocoin} Protocoin:
|
||||||
|
|
||||||
|
<div className='pay-custom'>
|
||||||
|
<Input
|
||||||
|
fluid
|
||||||
|
label={{ basic: true, content: '$' }}
|
||||||
|
labelPosition='left'
|
||||||
|
value={buyProtocoin}
|
||||||
|
onChange={(e, v) => setBuyProtocoin(v.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PayPalPayNow
|
||||||
|
amount={buyProtocoin}
|
||||||
|
name='Protospace Protocoin'
|
||||||
|
custom={JSON.stringify({ category: 'Exchange', member: user.member.id })}
|
||||||
|
/>
|
||||||
|
</Grid.Column>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Header size='medium'>Snacks, Pop, Coffee</Header>
|
<Header size='medium'>Snacks, Pop, Coffee</Header>
|
||||||
<Grid stackable padded columns={3}>
|
<Grid stackable padded columns={3}>
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
|
|
|
@ -281,7 +281,7 @@ export function TransactionList(props) {
|
||||||
<Table.HeaderCell>Date</Table.HeaderCell>
|
<Table.HeaderCell>Date</Table.HeaderCell>
|
||||||
{!noMember && <Table.HeaderCell>Member</Table.HeaderCell>}
|
{!noMember && <Table.HeaderCell>Member</Table.HeaderCell>}
|
||||||
<Table.HeaderCell>Amount</Table.HeaderCell>
|
<Table.HeaderCell>Amount</Table.HeaderCell>
|
||||||
<Table.HeaderCell>Account</Table.HeaderCell>
|
<Table.HeaderCell>Method</Table.HeaderCell>
|
||||||
{!noCategory && <Table.HeaderCell>Category</Table.HeaderCell>}
|
{!noCategory && <Table.HeaderCell>Category</Table.HeaderCell>}
|
||||||
<Table.HeaderCell>Memo</Table.HeaderCell>
|
<Table.HeaderCell>Memo</Table.HeaderCell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
|
@ -371,7 +371,7 @@ class TransactionTable extends React.Component {
|
||||||
<Table.Cell>{transaction.category}</Table.Cell>
|
<Table.Cell>{transaction.category}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell>Account:</Table.Cell>
|
<Table.Cell>Method:</Table.Cell>
|
||||||
<Table.Cell>{transaction.account_type}</Table.Cell>
|
<Table.Cell>{transaction.account_type}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
{/* <Table.Row>
|
{/* <Table.Row>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user