Add PayPal pay now button to course signup

This commit is contained in:
Tanner Collin 2020-02-09 06:59:22 +00:00
parent a6ca9a1a6e
commit 2a607bfa11
2 changed files with 48 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import moment from 'moment';
import { isAdmin, isInstructor, BasicTable, requester } from './utils.js'; import { isAdmin, isInstructor, BasicTable, requester } from './utils.js';
import { NotFound, PleaseLogin } from './Misc.js'; import { NotFound, PleaseLogin } from './Misc.js';
import { InstructorClassDetail, InstructorClassAttendance } from './InstructorClasses.js'; import { InstructorClassDetail, InstructorClassAttendance } from './InstructorClasses.js';
import { PayPal } from './PayPal.js';
function ClassTable(props) { function ClassTable(props) {
const { classes } = props; const { classes } = props;
@ -190,6 +191,7 @@ export function ClassDetail(props) {
(userTraining ? (userTraining ?
<div> <div>
<p>Status: {userTraining.attendance_status}</p> <p>Status: {userTraining.attendance_status}</p>
<p>
{userTraining.attendance_status === 'Withdrawn' ? {userTraining.attendance_status === 'Withdrawn' ?
<Button onClick={() => handleToggle('Waiting for payment')}> <Button onClick={() => handleToggle('Waiting for payment')}>
Sign back up Sign back up
@ -199,6 +201,18 @@ export function ClassDetail(props) {
Withdraw from Class Withdraw from Class
</Button> </Button>
} }
</p>
{userTraining.attendance_status === 'Waiting for payment' &&
<div>
<p>Please pay the course fee of ${clazz.cost} to confirm your attendance.</p>
<PayPal
amount={clazz.cost}
name={clazz.course_name}
custom={JSON.stringify({ training: userTraining.id })}
/>
</div>
}
</div> </div>
: :
((clazz.max_students && clazz.student_count >= clazz.max_students) ? ((clazz.max_students && clazz.student_count >= clazz.max_students) ?

26
webclient/src/PayPal.js Normal file
View File

@ -0,0 +1,26 @@
import React, { useState, useEffect, useReducer } from 'react';
export function PayPal(props) {
const { amount, custom, name } = props;
return (
<div className='paypal-container'>
<form action='https://sandbox.paypal.com/cgi-bin/webscr' method='post' target='_top'>
<input type='hidden' name='cmd' value='_xclick' />
<input type='hidden' name='business' value='info@protospace.ca' />
<input type='hidden' name='lc' value='CA' />
<input type='hidden' name='item_name' value={name} />
<input type='hidden' name='amount' value={amount} />
<input type='hidden' name='custom' value={custom} />
<input type='hidden' name='currency_code' value='CAD' />
<input type='hidden' name='button_subtype' value='services' />
<input type='hidden' name='no_note' value='0' />
<input type='hidden' name='tax_rate' value='0.000' />
<input type='hidden' name='shipping' value='0.00' />
<input type='hidden' name='bn' value='PP-BuyNowBF:btn_paynowCC_LG.gif:NonHostedGuest' />
<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!' />
<img alt='' border='0' src='https://www.paypalobjects.com/en_US/i/scr/pixel.gif' width='1' height='1' />
</form>
</div>
);
}