@@ -30,18 +30,20 @@ <h1>Support Runestone Interactive</h1>
3030 < input type ="radio " name ="donate " id ="donate20 " value ="20.00 "> < label for ="donate20 "> $20</ label > < br >
3131 < input type ="radio " name ="donate " id ="donate50 " value ="50.00 "> < label for ="donate50 "> $50</ label > < br >
3232 Other: < input type ="text " name ="donate " id ="donateother " value =""/> < br >
33- < a class ="btn btn-warning " href ="{{=URL('index')}} " role ="button "> Sorry, not Today</ a > < br >
34- If you don't PayPal, see below for Venmo option!
33+ < div style ="margin-top: 15px; margin-left: 30px; ">
34+ < a class ="btn btn-warning " href ="{{=URL('index')}} " role ="button "> Sorry, not Today</ a >
35+ </ div >
3536 </ div >
3637 </ div >
3738 </ div >
3839</ div >
3940< div id ="paypal-button-container " class ="col-md-8 col-md-offset-2 "> </ div >
4041
42+ < div class ="col-md-8 col-md-offset-2 " style ="margin-top: 20px; ">
43+ < p > Note: < i > Payment processing is handled by Paypal Inc., Runestone Academy LTD has no access to your payment information.</ i > </ p >
44+ </ div >
4145
42-
43- < script src ="https://www.paypal.com/sdk/js?client-id=AVsIrTPVGQOcMILmCSyfLioKBiqdTgAzC_ax74na1CZ0HZV0EPf9Vq7PDp_sWPeqNitq0yRGRYq5vjDp
44- ¤cy=USD&intent=capture&enable-funding=venmo " data-sdk-integration-source ="integrationbuilder "> </ script >
46+ < script src ="https://www.paypal.com/sdk/js?client-id=ASkp77N-Kiw5GKOF_0I13P0GCW6lrnaukdVqeFykz7zBT9F-WXHRIisBsau5VEmC-vCKCzt--41kaOjb¤cy=USD&intent=capture&enable-funding=venmo "> </ script >
4547
4648 < script >
4749 const fundingSources = [
@@ -65,11 +67,27 @@ <h1>Support Runestone Interactive</h1>
6567 createOrder : ( data , actions ) => {
6668 // pass in any options from the v2 orders create call:
6769 // https://developer.paypal.com/api/orders/v2/#orders-create-request-body
70+ var amt_opts = document . getElementsByName ( "donate" )
71+ var amt = ""
72+ for ( let rb of amt_opts ) {
73+ if ( rb . type === "radio" & rb . checked ) {
74+ amt = rb . value
75+ }
76+ }
77+ if ( amt === "" ) {
78+ amt = document . getElementById ( "donateother" ) . value
79+ let amtFloat = parseFloat ( amt ) ;
80+ // amounts under a dollar are not worth processing
81+ if ( isNaN ( amtFloat ) || amtFloat < 1.0 ) {
82+ alert ( "Sorry we cannot accept donations under $1" )
83+ return
84+ }
85+ }
6886 const createOrderPayload = {
6987 purchase_units : [
7088 {
7189 amount : {
72- value : '88.44' ,
90+ value : amt ,
7391 } ,
7492 } ,
7593 ] ,
@@ -82,6 +100,9 @@ <h1>Support Runestone Interactive</h1>
82100 onApprove : ( data , actions ) => {
83101 const captureOrderHandler = ( details ) => {
84102 const payerName = details . payer . name . given_name
103+ $ . get ( "/{{=request.application}}/ajax/save_donate" )
104+ alert ( 'Payment successful - Thank you! ' )
105+ window . location . href = "/{{=request.application}}/default"
85106 console . log ( 'Transaction completed!' )
86107 }
87108
0 commit comments