namespace WPForms\Integrations\Square\Api\Webhooks;
* Webhook subscription.created class.
class SubscriptionCreated extends Base {
* Set subscription status to active.
* @throws RuntimeException If payment isn't found or not updated.
public function handle(): bool {
$payment = wpforms()->obj( 'payment' )->get_by( 'subscription_id', $this->data->object->subscription->id );
if ( ! wpforms()->obj( 'payment' )->update( $payment->id, [ 'subscription_status' => 'active' ] ) ) {
throw new RuntimeException( 'Payment not updated' );
wpforms()->obj( 'payment_meta' )->add_log(
'Square subscription was set to active.'