Add starting price.
This commit is contained in:
parent
ebb2fd6cff
commit
ef43cfc335
@ -17,12 +17,13 @@ use MakeThemPay::DB;
|
||||
|
||||
sub price($self) {
|
||||
my $uuid = $self->param('uuid');
|
||||
my ( $price, $discount );
|
||||
my ( $price, $discount, $starting_price );
|
||||
eval { $self->_insert_license( $uuid, 0 ); };
|
||||
if ($@) {
|
||||
warn $@;
|
||||
}
|
||||
eval { ( $price, $discount ) = $self->_get_real_price; };
|
||||
eval { ( $price, $discount, $starting_price ) = $self->_get_real_price; };
|
||||
say $starting_price;
|
||||
if ($@) {
|
||||
warn $@;
|
||||
$self->res->code(500);
|
||||
@ -33,6 +34,7 @@ sub price($self) {
|
||||
json => {
|
||||
price => $price,
|
||||
discount => $discount,
|
||||
starting_price => $starting_price,
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -48,11 +50,11 @@ sub _get_real_price($self) {
|
||||
die
|
||||
"Bad price and/or discount format price: $price discount: $discount";
|
||||
}
|
||||
my $discounted_price = int($price - ( ( $price * $discount ) / 100 ));
|
||||
if (!wantarray) {
|
||||
my $discounted_price = int( $price - ( ( $price * $discount ) / 100 ) );
|
||||
if ( !wantarray ) {
|
||||
return $discounted_price;
|
||||
}
|
||||
return ( $discounted_price, $discount );
|
||||
return ( $discounted_price, $discount, $price );
|
||||
}
|
||||
|
||||
sub get_paid($self) {
|
||||
@ -114,7 +116,7 @@ sub get_url ($self) {
|
||||
},
|
||||
form => {
|
||||
currency => 'eur',
|
||||
unit_amount => int($self->_get_real_price),
|
||||
unit_amount => int( $self->_get_real_price ),
|
||||
product => $product_id,
|
||||
}
|
||||
)->result;
|
||||
|
Loading…
Reference in New Issue
Block a user