public static function create($params) { $requestConfirmPayment = new RequestConfirmPayment(); if (!is_int($params['client_id'])) { throw new TypeException('Cliente Id must be a numeric value'); } $requestConfirmPayment->setClientId($params['client_id']); if (!is_int($params['user_id'])) { throw new TypeException('Usuario Id must be a numeric value'); } $requestConfirmPayment->setUserId($params['user_id']); if (!is_int($params['company_id'])) { throw new TypeException('Empresa Id must be a numeric value'); } $requestConfirmPayment->setCompanyId($params['company_id']); if (!is_array($params['card'])) { throw new TypeException('Tarjeta must be an array'); } $requestConfirmPayment->setCard($params['card']); if (!is_array($params['tickets_to_confirm'])) { throw new TypeException('Tickets must be an array of tickets'); } foreach ($params['tickets_to_confirm'] as $ticket) { if (!$ticket instanceof Ticket) { throw new TypeException('Tickets must be an array of tickets'); } } $requestConfirmPayment->setTicketsToConfirm($params['tickets_to_confirm']); if (!is_bool($params['is_return'])) { throw new TypeException('Es Regreso must be a boolean'); } $requestConfirmPayment->setIsReturnTicket($params['is_return']); return $requestConfirmPayment; }
/** * Called in the checkout with you press "Confirmar" button. * @param RequestConfirmPayment $requestConfirmPayment * @return array * @throws RequestException */ public function confirmPayment(RequestConfirmPayment $requestConfirmPayment) { $service_type = 'confirmarVentaTarjeta'; $tickets_to_confirm = $requestConfirmPayment->getTicketsToConfirm(); $formattedTicketsToConfirm = $this->prepareTicketsToConfirm($tickets_to_confirm); $service_params = array('in0' => $requestConfirmPayment->getClientId(), 'in1' => $requestConfirmPayment->getUserId(), 'in2' => $requestConfirmPayment->getCompanyId(), 'in3' => $requestConfirmPayment->getCard(), 'in4' => $formattedTicketsToConfirm, 'in5' => $requestConfirmPayment->getIsReturnTicket(), 'in6' => $this->usuario, 'in7' => $this->password); $soap_param = array('confirmarVentaTarjeta' => $service_params); $soap_response = $this->callSoapServiceByType($service_type, $soap_param); if (isset($this->logger)) { $this->logger->addNotice(print_r($service_params, true)); $this->logger->addNotice(print_r($soap_response, true)); } $responseArray = $this->normalizePaymentConfirmationToArray($soap_response->out->Boleto); if ($this->verifyTicketsWereConfirmed($responseArray) == false) { throw new RequestException('Payment of ticket cannot be confirmed with bus line'); } $ticketsToConfirm = $requestConfirmPayment->getTicketsToConfirm(); $confirmedTickets = $this->assignTicketNumberToTicketsInArray($ticketsToConfirm, $responseArray); return $confirmedTickets; }