Show the taxed total in your own signup form
For a theme or add-on that replaces the [benecaster_subscribe] form with its own on a show using built-in membership.
Once the podcaster has turned on Calculate tax automatically, Stripe Tax is ready in the show’s Stripe account, and every active paid tier and buy-up on the show has a tax category, the show collects sales tax. From then on the signup route requires a billing address, and refuses a paid signup without one (400 benecaster_tax_address_required) before any account is created. With tax added on top, the charge is not the price on the tier card, so show the visitor the taxed total before they pay.
POST /shows/{id}/subscribe/tax-preview works that total out. It is public, so a guest can call it, and it creates and charges nothing. It answers { currency, subtotal, tax, total, subtotal_display, tax_display, total_display }, the amounts in minor units and the *_display strings ready to show. Send the same address with the signup itself. Full reference: Membership Subscribe REST API.
Code
// `address` is Stripe's Address Element value: { line1, line2, city, state, postal_code, country }.
async function taxedTotal( showId, tierSlug, priceId, address ) {
const res = await fetch( `/wp-json/benecaster/v1/shows/${ showId }/subscribe/tax-preview`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': wpApiSettings.nonce },
body: JSON.stringify( { tier_slug: tierSlug, price_id: priceId, address } ),
} );
const body = await res.json();
if ( 409 === res.status ) return null; // this show does not collect tax: no address needed
if ( ! res.ok ) throw new Error( body.message ); // 422: Stripe could not place the address — ask again
return body; // { subtotal, tax, total, *_display } — minor units + strings
}
// Then send the same `address` with the signup:
// POST …/shows/{id}/subscribe { tier_slug, price_id, payment_method_id, address }
Need this built rather than just documented? See our services →