Esempio n. 1
0
 public function prepayment()
 {
     $params = ['cards' => [], 'selectedCard' => ['payment_id' => '-1', 'card_pan' => trans('pay.prepayment.new_card')]];
     $api = new Api();
     $customerId = $api->id();
     $cards = PaymentCloud::getCustomersCards($customerId);
     $cPan = [];
     foreach ($cards as $card) {
         $cPan[] = $card['card_pan'];
         $params['cards'][] = ['payment_id' => $card['payment_id'], 'card_pan' => $card['card_pan']];
     }
     if (count($cPan) > 0) {
         /*$lastPay = PaymentCloud::getLastPay($customerId);
           if ($lastPay && in_array($lastPay['card_pan'], $cPan)) {
               $params['selectedCard'] = [
                   'payment_id' => $lastPay['payment_id'],
                   'card_pan' => $lastPay['card_pan']
               ];
           }
           else {*/
         $lastAddedCard = PaymentCloud::lastAddedCard($customerId);
         if ($lastAddedCard) {
             $params['selectedCard'] = ['payment_id' => $lastAddedCard['payment_id'], 'card_pan' => $lastAddedCard['card_pan']];
         }
         //}
     }
     return View::make('ac::prepayment', $params);
 }