diff --git a/lib/MakeThemPay/Controller/Main.pm b/lib/MakeThemPay/Controller/Main.pm index 33b4e20..0693f27 100644 --- a/lib/MakeThemPay/Controller/Main.pm +++ b/lib/MakeThemPay/Controller/Main.pm @@ -44,7 +44,6 @@ sub _get_real_price($self) { my $discount = $self->config->{discount}; if ( !defined $price || !defined $discount - || $discount > 99 || $discount < 0 ) { die @@ -110,6 +109,15 @@ sub get_url ($self) { id => $product_id, } )->result; + my $base_url = $self->config->{'base-url'} or die 'Base URL not configured'; + if (int($self->_get_real_price) == 0) { + $self->render( + json => { + url => $base_url.'/set_paid/'.$uuid, + } + ); + return; + } $result = $ua->post( 'https://api.stripe.com/v1/prices' => { Authorization => $authorization @@ -126,7 +134,6 @@ sub get_url ($self) { if ( !defined $price_id ) { die 'Unable to get price'; } - my $base_url = $self->config->{'base-url'} or die 'Base URL not configured'; $result = $ua->post( 'https://api.stripe.com/v1/payment_links' => { Authorization => $authorization