Create a tier or buy-up on a show that collects tax
Once Stripe Tax is ready in a show’s Stripe account, Benecaster refuses to save a paid tier or any buy-up without a tax_code (400 benecaster_tax_code_required), whether or not the podcaster has turned on Calculate tax automatically. Code that creates tiers or buy-ups for a podcaster, such as an import or migration tool, has to ask first, and must not answer on the podcaster’s behalf.
GET /membership/stripe/tax-status?show_id={id} answers { show_id, state, category_required }. It needs manage_options, like the tier and buy-up routes it guards. When category_required is true, collect a category from the podcaster and send it as tax_code on POST /membership-tiers or POST /buyups. Full reference: Buy-ups Admin REST API.
Code
<?php
$req = new WP_REST_Request( 'GET', '/benecaster/v1/membership/stripe/tax-status' );
$req->set_param( 'show_id', $show_id );
$needs_category = ! empty( rest_do_request( $req )->get_data()['category_required'] );
if ( $needs_category ) {
// Do NOT pick a code. Ask the podcaster, then send what they chose:
// $create->set_param( 'tax_code', $their_choice ); // e.g. 'txcd_10804010'
my_tool_flag_tier_needs_category( $source_tier );
return;
}
Need this built rather than just documented? See our services →