예제 #1
0
 /**
  * @param $mert_id
  * @param Request $request
  *
  * Handle Gateway Response
  *
  * @return mixed
  */
 private function handleTransactionResponse($mert_id, Request $request)
 {
     $data = $request->all();
     $origin = $request->header('origin');
     switch ($origin) {
         case str_contains($origin, 'gtbank'):
             $result = GTPay::receiveTransactionResponse($data, $mert_id);
             break;
         case str_contains($origin, 'voguepay'):
             $result = VoguePay::receiveTransactionResponse($data, $mert_id);
             break;
         case str_contains($origin, 'simplepay'):
             $result = SimplePay::receiveTransactionResponse($data, $mert_id);
             break;
         case str_contains($origin, 'cashenvoy'):
             $result = CashEnvoy::receiveTransactionResponse($data, $mert_id);
             break;
         case str_contains($origin, 'webpay'):
             $result = WebPay::receiveTransactionResponse($data, $mert_id);
             break;
         default:
             $result = $this->paymentGateway->receiveTransactionResponse($data, $mert_id);
             break;
     }
     /*********************************
      * $result contains all information regarding the transaction, This would be a perfect
      * place to leverage Events to Do Whatever eg. Send an Invoice, Notify admin of
      * failed transactions, confirm if total is the same so you can rest easy etc.
      * You could do your normal Procedural Approach As Well, If You are not so comfortable with
      * Events. To Use The Events, Uncomment the Call, create the method and write your implementation
      *********************************/
     // $this->handleNextStepsUsingEvents($result);
     return $result;
 }