-
Notifications
You must be signed in to change notification settings - Fork 69
/
main.php
161 lines (129 loc) · 6.11 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
namespace WordCamp\Budgets\Sponsor_Payment_Stripe;
use WordCamp\Utilities\Form_Spam_Prevention;
/** @var array $data */
/** @var Form_Spam_Prevention $fsp */
get_header();
?>
<div id="container">
<div id="content" class="wcorg-sponsor-payment" role="main">
<h1 class="entry-title"><?php esc_html_e( 'Sponsorship Payment', 'wordcamporg' ); ?></h1>
<?php if ( ! empty( $data['errors'] ) ) : ?>
<?php foreach ( $data['errors'] as $error ) : ?>
<p class="notice notice-error">
<strong><?php esc_html_e( 'Error:', 'wordcamporg' ); ?></strong>
<?php echo wp_kses_data( $error ); ?>
</p>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( $fsp->is_ip_address_throttled() ) : ?>
<p class="payment-instructions">
This form is currently unavailable. Please try again later.
</p>
<?php elseif ( $data['step'] == STEP_SELECT_INVOICE ) : ?>
<p class="payment-instructions">
<?php esc_html_e( 'Use this form to pay your WordCamp sponsorship fee to WordPress Community Support, PBC. If you did not receive an invoice ID yet, please get in touch with the event\'s Sponsorships Coordinator for more information.', 'wordcamporg' ); ?>
</p>
<form method="POST" class="payment-form" data-step="<?php echo STEP_SELECT_INVOICE; ?>">
<input type="hidden" name="step" value="<?php echo STEP_SELECT_INVOICE; ?>" />
<input type="hidden" name="sponsor_payment_submit" value="1" />
<div class="control">
<input type="radio" id="payment_type_invoice" name="payment_type" value="invoice" checked> <label for="payment_type_invoice"><?php esc_html_e( 'Invoice payment', 'wordcamporg' ); ?></label>
<input type="radio" id="payment_type_other" name="payment_type" value="other"> <label for="payment_type_other"><?php esc_html_e( 'Other payment', 'wordcamporg' ); ?></label>
</div>
<div class="clear"></div>
<fieldset class="invoice-fields">
<label class="control-header"><?php esc_html_e( 'Event', 'wordcamporg' ); ?></label>
<div class="control">
<?php echo get_wordcamp_dropdown( 'wordcamp_id', $data['wordcamp_query_options'] ); ?>
</div>
<label class="control-header"><?php esc_html_e( 'Invoice ID', 'wordcamporg' ); ?></label>
<div class="control">
<input type="text" name="invoice_id" />
</div>
</fieldset>
<fieldset class="other-fields">
<label class="control-header"><?php esc_html_e( 'Description (100 character limit)', 'wordcamporg' ); ?></label>
<div class="control">
<input type="text" name="description" maxlength="100" value="" />
</div>
</fieldset>
<div class="clear"></div>
<?php $fsp->render_form_fields(); ?>
<label class="control-header"><?php esc_html_e( 'Currency', 'wordcamporg' ); ?></label>
<div class="control">
<select name="currency">
<option value="" disabled selected><?php esc_html_e( 'Select a Currency', 'wordcamporg' ); ?></option>
<?php foreach ( $data['currencies'] as $currency_key => $currency_name ) : ?>
<option value="<?php echo esc_attr( $currency_key ); ?>">
<?php echo esc_html( $currency_name ); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<label class="control-header"><?php esc_html_e( 'Amount', 'wordcamporg' ); ?></label>
<div class="control">
<input type="text" name="amount" /><br />
<em><?php esc_html_e( 'An additional 2.9% to cover processing fees on credit card payments is highly appreciated but not required.', 'wordcamporg' ); ?></em>
</div>
<div class="clear"></div>
<input type="submit" value="<?php esc_attr_e( 'Continue', 'wordcamporg' ); ?>" />
</form>
<?php elseif ( $data['step'] == STEP_PAYMENT_DETAILS ) : ?>
<p><?php esc_html_e( 'Please review the details below and hit "Make a Payment" when you\'re ready.', 'wordcamporg' ); ?></p>
<table>
<?php if ( 'invoice' === $data['payment']['payment_type'] ) : ?>
<tr>
<td><?php esc_html_e( 'Event', 'wordcamporg' ); ?></td>
<td><?php echo esc_html( get_wordcamp_name( get_wordcamp_site_id( $data['payment']['wordcamp_obj'] ) ) ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Invoice', 'wordcamporg' ); ?></td>
<td><?php echo esc_html( $data['payment']['invoice_id'] ); ?></td>
</tr>
<?php elseif ( 'other' === $data['payment']['payment_type'] ) : ?>
<tr>
<td><?php esc_html_e( 'Description', 'wordcamporg' ); ?></td>
<td><?php echo esc_html( $data['payment']['description'] ); ?></td>
</tr>
<?php endif; ?>
<tr>
<td><?php esc_html_e( 'Currency', 'wordcamporg' ); ?></td>
<td><?php echo esc_html( $data['payment']['currency'] ); ?></td>
</tr>
<tr>
<td><?php esc_html_e( 'Amount', 'wordcamporg' ); ?></td>
<td><?php echo number_format( round( $data['payment']['amount'], 2 ), 2, '.', ' ' ); ?></td>
</tr>
</table>
<div id="checkout"></div>
<script
src="https://js.stripe.com/v3/"
id="script-stripe-checkout"
data-key="<?php echo esc_attr( $data['keys']['publishable'] ); ?>"
data-secret="<?php echo esc_attr( $data['session_secret'] ); ?>"
></script>
<script>
(async function(){
const stripeEl = document.getElementById('script-stripe-checkout');
const stripe = Stripe( stripeEl.dataset.key );
const checkout = await stripe.initEmbeddedCheckout( {
clientSecret: stripeEl.dataset.secret
} );
checkout.mount('#checkout');
})()
</script>
<?php elseif ( $data['step'] == STEP_PAYMENT_SUCCESS ) : ?>
<script>history.replaceState( {}, '', window.location.pathname );</script>
<p class="notice notice-success">
<strong><?php esc_html_e( 'Success!', 'wordcamporg' ); ?></strong>
<?php esc_html_e( 'Your payment has been received, thank you!', 'wordcamporg' ); ?>
</p>
<ul>
<li><a href="<?php echo esc_url( add_query_arg( 'again', 1, get_permalink() ) ); ?>"><?php esc_html_e( 'Make another payment', 'wordcamporg' ); ?></a></li>
<li><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Go back to Central', 'wordcamporg' ); ?></a></li>
</ul>
<?php endif; ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_footer(); ?>