コード例 #1
0
 /**
  * Creates a new Events model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Events();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: johnsunam/reminder
 public function actionSubmit()
 {
     $event = new Events();
     $address = new Addresses();
     if ($event->load(yii::$app->request->post()) && $event->save() && $address->load(yii::$app->request->post()) && $address->save()) {
         return $this->render('sucess');
     } else {
         return $this->return('unsucess');
     }
 }
コード例 #3
0
ファイル: EventController.php プロジェクト: Akelcehg/psycho
 /**
  * Creates a new Events model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Events();
     $imagesModel = new Image();
     if ($model->load(Yii::$app->request->post())) {
         $userId = Yii::$app->user->id;
         $model->is_user_organizer = $userId;
         $model->organizer_id = $userId;
         if ($model->save()) {
             $imagesModel->image_file = UploadedFile::getInstance($imagesModel, 'image_file');
             if ($imagesModel->image_file) {
                 $imagesModel->saveEventImage($model->id, 550, 330);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model, 'imagesModel' => $imagesModel]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'imagesModel' => $imagesModel]);
     }
 }
コード例 #4
0
 public function store()
 {
     $getid = Events::select('EventID')->get();
     if (!$getid->isEmpty()) {
         $getid = Events::select('EventID')->orderBy('EventID', 'desc')->first()->get();
         foreach ($getid as $key) {
             $id = (int) $key->EventID + 1;
         }
     } else {
         $id = 1;
     }
     $result = Request::all();
     $quoteID = $result['quoteid'];
     $eventType = $result['eventType'];
     $downpayment = $result['downpayment'];
     $userID = Auth::user()->id;
     $addedDate = date('Y-m-d H:i:s');
     try {
         /*
          * Insert the new Quote to Database Table 'quote_requests'
          */
         $events = new Events();
         $events->EventID = $id;
         $events->QuoteID = $quoteID;
         $events->UserID = $userID;
         $events->EventType = $eventType;
         $events->AddedDate = $addedDate;
         $events->save();
         Quote_Requests::where('id', $quoteID)->update(['Status' => 'Paid']);
     } catch (QueryException $e) {
     }
     // ### Address
     // Base Address object used as shipping or billing
     // address in a payment. [Optional]
     $addr = Paypalpayment::address();
     $addr->setLine1("22/1, Nagavihara Road");
     $addr->setLine2("Pitakotte");
     $addr->setCity("Pitakotte");
     $addr->setState("");
     $addr->setPostalCode("10100");
     $addr->setCountryCode("SL");
     $addr->setPhone("0094773685526");
     // ### CreditCard
     $card = Paypalpayment::creditCard();
     $card->setType("visa")->setNumber("4758411877817150")->setExpireMonth("05")->setExpireYear("2019")->setCvv2("456")->setFirstName("Hasitha")->setLastName("Jayasinghe");
     // ### FundingInstrument
     // A resource representing a Payer's funding instrument.
     // Use a Payer ID (A unique identifier of the payer generated
     // and provided by the facilitator. This is required when
     // creating or using a tokenized funding instrument)
     // and the `CreditCardDetails`
     $fi = Paypalpayment::fundingInstrument();
     $fi->setCreditCard($card);
     // ### Payer
     // A resource representing a Payer that funds a payment
     // Use the List of `FundingInstrument` and the Payment Method
     // as 'credit_card'
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $item_1 = new Item();
     $item_1->setName('Quote ID: ' . $quoteID)->setCurrency('USD')->setQuantity(1)->setPrice($downpayment);
     // unit price
     // add item to list
     $item_list = new ItemList();
     $item_list->setItems(array($item_1));
     $amount = new Amount();
     $amount->setCurrency('USD')->setTotal($downpayment);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($item_list)->setDescription('Your transaction description');
     // ### Payment
     // A Payment Resource; create one using
     // the above types and intent as 'sale'
     $redirect_urls = new RedirectUrls();
     $redirect_urls->setReturnUrl(URL::route('payment-status'))->setCancelUrl(URL::route('payment-status'));
     $payment = new Payment();
     $payment->setIntent('order')->setPayer($payer)->setRedirectUrls($redirect_urls)->setTransactions(array($transaction));
     try {
         // ### Create Payment
         // Create a payment by posting to the APIService
         // using a valid ApiContext
         // The return object contains the status;
         $payment->create($this->_apiContext);
     } catch (\PPConnectionException $ex) {
         return "Exception: " . $ex->getMessage() . PHP_EOL;
         exit(1);
     }
     foreach ($payment->getLinks() as $link) {
         if ($link->getRel() == 'approval_url') {
             $redirect_url = $link->getHref();
             break;
         }
     }
     // add payment ID to session
     Session::put('paypal_payment_id', $payment->getId());
     if (isset($redirect_url)) {
         // redirect to paypal
         return Redirect::away($redirect_url);
     }
     return Redirect::route('original-route')->with('error', 'Unknown error occurred');
     dd($payment);
 }