コード例 #1
0
 /**
  * Handle the event.
  *
  * @param  Event  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $payment = Payment::findOrFail($event->transactionDetail['transaction_id']);
     if ($event instanceof \GoProp\Events\PaymentCompletedEvent) {
         switch ($event->transactionDetail['method']) {
             case MyShortCart::getMachineName():
                 if ($event->transactionDetail['status'] == 'success') {
                     if (isset($event->transactionDetail['payment_channel'])) {
                     } else {
                         $payment->order->update(['status' => Order::STATUS_PENDING]);
                         $payment->update(['status' => Payment::STATUS_PAID, 'amount' => $event->transactionDetail['amount'], 'received_at' => Carbon::now()->toDateTimeString()]);
                         Session::set('payment_redirect_to', route('frontend.property.success', ['id' => $payment->order->property->id]));
                     }
                 }
                 break;
         }
     } elseif ($event instanceof \GoProp\Events\PaymentCancelledEvent) {
         Session::set('payment_redirect_to', route('frontend.property.review', ['id' => $payment->order->property->id]));
     } elseif ($event instanceof \GoProp\Events\PaymentFailedEvent) {
         Session::set('payment_redirect_to', route('frontend.property.review', ['id' => $payment->order->property->id]));
     }
 }
コード例 #2
0
 public function postRedirect(Request $request)
 {
     $trx = array();
     $transidmerchant = explode('_', $request->input('TRANSIDMERCHANT'));
     $trx['amount'] = $request->input('AMOUNT');
     $trx['transaction_id'] = $transidmerchant[1];
     $trx['msc_transaction_id'] = $request->input('TRANSIDMERCHANT');
     $trx['status_code'] = $request->input('STATUSCODE');
     $existingTransactions = MyShortCart::getExistingTransactions($trx['transaction_id'], 'REQUEST', $trx['amount']);
     if (count($existingTransactions) < 1) {
         return 'Stop : Transaction Not Found';
     } else {
         if ($request->has('PAYMENTCODE')) {
             $trx['payment_code'] = $request->input('PAYMENTCODE');
         }
         $trx['result_message'] = $request->input('RESULT');
         $trx['payment_datetime'] = $request->input('TRANSDATE');
         $trx['payment_channel'] = $request->input('PTYPE');
         $trx['extra_info'] = $request->input('EXTRAINFO');
         $trx['ip_address'] = $request->ip();
         $trx['process_datetime'] = Carbon::now()->toDateTimeString();
         $trx['process_type'] = 'REDIRECT';
         if ($trx['status_code'] == "00" || strtolower($trx['result_message']) == 'success') {
             $trx['message'] = "Redirect process message come from MyShortCart. Transaction is Success";
             if (config('myshortcart.completed_event') !== false) {
                 $transactionData = ['method' => MyShortCart::getMachineName(), 'transaction_id' => $trx['transaction_id'], 'amount' => $trx['amount'], 'status' => 'success'];
                 $completedEvent = config('myshortcart.completed_event');
                 Event::fire(new $completedEvent($transactionData));
             }
         } else {
             if (strtolower($trx['payment_channel']) == "bank transfer" || strtolower($trx['payment_channel']) == "alfamart") {
                 $trx['message'] = "Redirect process message come from MyShortCart. Transaction is waiting for payment from ATM / ALFA Mart";
                 if (config('myshortcart.completed_event') !== false) {
                     $transactionData = ['method' => MyShortCart::getMachineName(), 'transaction_id' => $trx['transaction_id'], 'amount' => $trx['amount'], 'status' => 'success', 'payment_channel' => strtolower($trx['payment_channel'])];
                     $completedEvent = config('myshortcart.completed_event');
                     Event::fire(new $completedEvent($transactionData));
                 }
             } else {
                 $trx['message'] = "Redirect process message come from MyShortCart. Transaction is Failed";
                 if (config('myshortcart.failed_event') !== false) {
                     $transactionData = ['method' => MyShortCart::getMachineName(), 'transaction_id' => $trx['transaction_id'], 'amount' => $trx['amount'], 'status' => 'failed'];
                     $completedEvent = config('myshortcart.failed_event');
                     Event::fire(new $completedEvent($transactionData));
                 }
             }
         }
         MyShortCart::saveTransaction($trx);
         $redirect_url = Session::pull('payment_redirect_to');
         return redirect($redirect_url);
     }
     return 'Stop : Request Not Valid';
 }
コード例 #3
0
 public function getPropertyPayment($id)
 {
     $property = Property::findOrFail($id);
     $order = $property->order;
     $existingPayments = $order->payments;
     if ($existingPayments->count() < 1) {
         return redirect()->route('frontend.property.review', ['id' => $property->id]);
     }
     $payment_method = $existingPayments->first()->payment_method;
     switch ($payment_method) {
         case Payment::METHOD_DOKU_CREDIT_CARD:
             $payment = $existingPayments->first();
             //Building the required external form fields
             $user = Auth::user();
             $user->load(['profile']);
             $shared_key = config('myshortcart.shared_key');
             $msc_transaction_id = config('myshortcart.prefix') . '_' . $payment->id;
             foreach ($order->items as $item) {
                 $items[] = ['name' => $item->item_type == 'feature' ? trans('property.package.feature.' . $item->getItem()->code) : $item->item, 'price' => $item->net_price, 'quantity' => $item->quantity];
             }
             $orderData = ['ip_address' => \Illuminate\Support\Facades\Request::ip(), 'transaction_id' => $payment->id, 'msc_transaction_id' => $msc_transaction_id, 'amount' => $payment->total_amount, 'basket' => MyShortCart::formatBasket($items), 'words' => sha1(trim($payment->total_amount) . trim($shared_key) . trim($msc_transaction_id)), 'url' => route('frontend.property.payment', ['id' => $property->id]), 'customer_name' => $user->profile->first_name . ' ' . $user->profile->last_name, 'customer_email' => $user->email, 'customer_phone' => $user->profile->home_phone_number, 'customer_work_phone' => $user->profile->mobile_phone_number, 'customer_mobile_phone' => $user->profile->mobile_phone_number, 'customer_address' => trim(str_replace(["\r", "\n"], ' ', $user->profile->address)), 'customer_postal_code' => trim($user->profile->postal_code), 'customer_city' => $user->profile->city ? trim(AddressHelper::getAddressLabel($user->profile->city, 'city')) : '', 'customer_state' => $user->profile->province ? trim(AddressHelper::getAddressLabel($user->profile->province, 'province')) : '', 'customer_country' => 360, 'customer_birthday' => ''];
             $orderData += ['shipping_address' => $orderData['customer_address'], 'shipping_postal_code' => $orderData['customer_postal_code'], 'shipping_city' => $orderData['customer_city'], 'shipping_state' => $orderData['customer_state'], 'shipping_country' => $orderData['customer_country']];
             MyShortCart::saveRequestTransaction($orderData);
             return MyShortCart::renderForm($orderData);
             break;
         default:
             return redirect()->route('frontend.property.success', ['id' => $property->id]);
             break;
     }
 }