@@ -24,8 +24,6 @@ class BillingController extends Controller
}
//Expects an array 'packs' representing the amount of each multiple of credits.
//This controller should have a way of figuring out how much of each pack
//was bought later.
//Should validate that all amounts are positive integers in a reasonable range
public function secret(Request $request) {
$user = Auth::user();
@@ -34,14 +32,14 @@ class BillingController extends Controller
+ $request->packs[ 'credits1000' ]*101000;
$transaction = new Transaction;
$transaction->credits = $request->packs['credits10']*10 +
$request->packs['credits50']*50 +
$request->packs['credits100']*100 +
$request->packs['credits1000']*1000;
$transaction->credits = $request->packs['credits10']*1000 +
$request->packs['credits50']*5000 +
$request->packs['credits100']*10000 +
$request->packs['credits1000']*100000 ;
$transaction->credits_extra =
$request->packs['credits50']*5 +
$request->packs['credits100']*10 +
$request->packs['credits1000']*150;
$request->packs['credits50']*500 +
$request->packs['credits100']*1000 +
$request->packs['credits1000']*15000 ;
$transaction->user_id = $user->id;
$transaction->charge = $amount;
@@ -75,6 +73,7 @@ class BillingController extends Controller
]);
}
//Adds correct credit amount to the charged user, precise to two decimal places
public function chargeEvent(Request $request) {
$event = \Stripe\Event::constructFrom($request->all());
$charge = $event->data->object;