-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshort-codes.php
40 lines (32 loc) · 952 Bytes
/
short-codes.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
<?php
// Short Codes
add_shortcode('stripe_payment', 'stripe_payment');
function stripe_payment($atts, $content = null ) {
extract(shortcode_atts(array(
"amount" => 500.0,
"payment_id" => null
), $atts));
$errors = verify_configuration_settings();
return $errors.create_payment_form($amount, $payment_id);
}
// Verify configuration settings
function verify_configuration_settings() {
global $publicKey;
global $secretKey;
global $currencySymbol;
$error = "";
if( strlen($publicKey)==0) {
$error .= "<li>Public key is not set.</li>";
}
if( strlen($secretKey)==0) {
$error .= "<li>Secret key is not set.</li>";
}
if( strlen($currencySymbol)==0) {
$error .= "<li>Secret key is not set.</li>";
}
if(strlen($error)>0) {
$error = "<div class='stripe-payment-config-errors'><p>Fix the following configuration errors before using the form.</p><ul>".$error."</ul></div>";
}
return $error;
}
?>