public static function create_from_paypal($data, $response) { $data['ipn_response'] = $response; $object = new Topup(); $object->method = "Paypal"; $object->transaction_id = $data['txn_id']; $object->sender = $data['payer_email']; $object->amount = $data['mc_gross']; $object->fees = $data['mc_fee']; $object->reference = $data['custom']; $object->status = $data['payment_status']; $object->extra = serialize($data); $object->save(); return $object; }
public function process($id = null) { if ($_GET['key'] == md5("winbarmint")) { if (!$id) { $id = mysql_real_escape_string($_GET['id']); } $topup = Topup::find_by_id($id); if ($topup) { $topup->processed = true; if ($topup->save()) { echo "OK"; } else { echo "Fail"; } die; } else { Error404(); } } else { Error403(); } }
/** * Store a newly created resource in storage. * * @return Response */ public function lotUsage(UsageRequest $request) { $usage = Usage::findOrFail($request->id); $usage->stock_id = $request->stock_id; $usage->quantity_used = $request->quantity_used; $usage->date_of_usage = $request->date_of_usage; $usage->issued_by = $request->issued_by; $usage->received_by = $request->received_by; $usage->remarks = $request->remarks; $usage->user_id = Auth::user()->id; $url = session('SOURCE_URL'); if ($usage->quantity_used > Stock::find((int) $usage->stock_id)->quantity()) { return redirect()->back()->with('message', trans('messages.insufficient-stock'))->withInput($request->all()); } else { if ($usage->quantity_used > Topup::find((int) $usage->request_id)->quantity_ordered) { return redirect()->back()->with('message', trans('messages.issued-greater-than-ordered'))->withInput($request->all()); } else { $usage->save(); return redirect()->to($url)->with('message', trans('messages.record-successfully-updated'))->with('active_stock', $usage->stock->id); } } }