Example #1
0
 public static function readCallback($payload)
 {
     $crypt = new Encrypter(base64_decode(Config::get('services.etupay.key')), 'AES-256-CBC');
     $payload = json_decode($crypt->decrypt($payload));
     if ($payload && is_numeric($payload->service_data)) {
         $paymentId = $payload->service_data;
         $payment = Payment::findOrFail($paymentId);
         switch ($payload->step) {
             case 'INITIALISED':
                 $payment->state = 'returned';
                 break;
             case 'PAID':
             case 'AUTHORISATION':
                 $payment->state = 'paid';
                 break;
             case 'REFUSED':
             case 'CANCELED':
                 $payment->state = 'refused';
                 break;
             case 'REFUNDED':
                 $payment->state = 'refunded';
                 break;
         }
         $payment->informations = ['transaction_id' => $payload->transaction_id];
         $payment->save();
         if ($payment->newcomer) {
             $payment->newcomer->updateWei();
         } elseif ($payment->student) {
             $payment->student->updateWei();
         }
         return $payment;
     }
     return null;
 }
Example #2
0
 public function index(Request $request)
 {
     $data = $request->json()->all('bags');
     $payment = Payment::findOrFail($data['payment_id']);
     $logistics = Logistics::findOrFail($data['logistics_id']);
     $bags = Bag::with('stock.product')->find($data['bags']);
     $order = new Order(array_except($data, 'bags'));
     \DB::transaction(function () use($bags, $logistics, $payment, $order, $data, $request) {
         $order_products = [];
         foreach ($bags as $bag) {
             $order_products[] = $bag->stock->pick($bag->quantity);
             $bag->stock->save();
         }
         $order->user_id = $request->user->id;
         $order->calc($order_products);
         $order->save();
         $order->products()->saveMany($order_products);
         Bag::destroy($data['bags']);
     });
     return response()->created($order);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $obj = Payment::findOrFail($id);
     return view('internal.promoter.payment.show', ['payment' => $obj]);
 }
Example #4
0
 public function logo(Request $request, $id)
 {
     $payment = Payment::findOrFail($id);
     return \Image::make($payment->gateway->logo)->response();
 }