You are here: Home
Stripe payment plugins for your WordPress site
OK, I figured out what’s going on. You do all the arithmetic twice: once in class-shortcode-asp.php to create the button and form, and then do it all again (reading the price from the database a second time) in process_ipn.php.
I suppose that stops anyone spoofing their own price in the <form>.
So to get the option of [asp_product id=”196″ price=”200″] to work I:
a) send the custom price into get_button_code_new_method( $data ) by adding
685: if (isset($atts[‘price’])) { //ARM20190503
$data[‘customPrice’] = $atts[‘price’];
}
and then
b) spoof the “user set amount” feature by adding a (hidden) field with name ‘stripeAmount’
802: if (isset($data[‘customPrice’])) { //ARM20190503
$data[‘amount’] = $data[‘customPrice’];
error_log($data[‘price’]);
$output .= “<input type=’hidden’ name=’stripeAmount’ value='” . $data[‘customPrice’] . “‘ >”;
}
Now when process_ipn.php is run the field with that name triggers the //Custom amount conditional on 216, as if the customer had entered the amount themselves.
Can you think of a neater way to do this? It’s a bit ‘hacky’.