/** * @param array() $items * @param array() $buyer * @param array() $creditCard * @param string $cardType * * @return object */ private function processSoap($items, $buyer, $creditCard, $cardType) { $provider = $this->apiPrefix . $cardType; $subject = ''; $message = ''; if ($this->dineromail_api_debug) { // this is a debug environment //to debug dineromail API, we use the credit card select //to map success/fail values to pass to the transaction_id //field, which dineromail API uses switch ($cardType) { case 'VISA': // OK $merchantTransactionId = '1'; break; case 'MASTER': // DENIED $merchantTransactionId = '2'; break; case 'AMEX': // ERROR $merchantTransactionId = '3'; break; default: // ERROR $merchantTransactionId = '4'; break; } } else { $merchantTransactionId = $this->paymentBridge->getOrderId() . '#' . date('Ymdhis'); } $uniqueMessageId = date('Ymdhis') . str_pad(rand(0, 999), 3, '0', STR_PAD_LEFT); $stringItems = ''; $soapItems = array(); foreach ($items as &$item) { /* UGLY HACK NEEDED UNTIL PAYMENTBRIDGE HIERARCHY WILL BE REFACTORED */ $item['Amount'] = number_format($item['Amount'] / 100, 2, '.', ''); $stringItems .= $item['Amount'] . $item['Code'] . $item['Currency'] . $item['Description'] . $item['Name'] . $item['Quantity']; $soapItems[] = $this->soapVar($item, 'Item'); } $stringBuyer = $buyer['Name'] . $buyer['LastName'] . $buyer['Email'] . $buyer['Address'] . $buyer['Phone'] . $buyer['Country'] . $buyer['City']; $stringCreditCard = $creditCard['Installment'] . $creditCard['CreditCardNumber'] . $creditCard['Holder'] . $creditCard['ExpirationDate'] . $creditCard['SecurityCode'] . $creditCard['DocumentNumber'] . $creditCard['Address'] . $creditCard['AddressNumber'] . $creditCard['AddressComplement'] . $creditCard['ZipCode'] . $creditCard['Neighborhood'] . $creditCard['City'] . $creditCard['State'] . $creditCard['Country']; $cadena = $merchantTransactionId . $uniqueMessageId . $stringItems . $stringBuyer . $stringCreditCard . $provider . $subject . $message . $this->apiPassword; $hash = MD5($cadena); $client = new \SoapClient($this->wsdl, array('trace' => 1, 'exceptions' => 1)); $soapCredentials = $this->soapVar(array('APIUserName' => $this->apiUserName, 'APIPassword' => $this->apiPassword), 'APICredential'); $soapBuyer = $this->soapVar($buyer, 'Buyer'); $soapCreditCard = $this->soapVar($creditCard, 'CreditCard'); $request = array('Credential' => $soapCredentials, 'Crypt' => false, 'MerchantTransactionId' => $merchantTransactionId, 'Items' => $soapItems, 'Buyer' => $soapBuyer, 'Provider' => $provider, 'CreditCard' => $soapCreditCard, 'Subject' => $subject, 'Message' => $message, 'UniqueMessageId' => $uniqueMessageId, 'Hash' => $hash); $this->logger->addInfo('Request Send DineromailApi' . 'processTransaction Response', $request); return $client->DoPAymentWithCreditCard($request)->DoPaymentWithCreditCardResult; }