Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: paymentDo
- */
- ?>
- <?php
- require_once('nusoap/lib/nusoap.php');
- $merchantId = 'marcapropria';
- $authorizerId = $_POST['authorizerId'];
- $cardExpiryDate = $_POST['mes'] . $_POST['year'];
- $cardNumber = $_POST['cardNumber'];
- $cardSecurityCode = $_POST['cardSecurityCode'];
- $customerId = $_POST['customerCedula']; //$_POST['customerNacionalidad'] .
- $autoConfirmation = true;
- $installmentType = '4';
- $installments = '1';
- $amount = $_POST['amount'];
- echo "<pre>" var_dump($_POST); echo "</pre>"; die();
- $endpoint = 'https://esitef-homologacao.softwareexpress.com.br/e-sitef-hml/Payment2?wsdl';
- $wsdl = true;
- $proxyhost = false;
- $proxyport = false;
- $proxyusername = false;
- $proxypassword = false;
- $timeout = 0;
- $response_timeout = 300;
- $client = new nusoap_client($endpoint, $wsdl, $proxyhost, $proxyport, $proxyusername, $proxypassword, $timeout, $response_timeout);
- $err = $client->getError();
- if ($err) {
- echo '<h2>Error</h2><pre>' . $err . '</pre>';
- echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
- exit();
- }
- $transactionRequest = array('transactionRequest' => array
- (
- 'amount' => $amount,
- 'merchantId' => $merchantId,
- 'merchantUSN' => '19949576',
- 'orderId' => '19949576'
- ));
- $payment = $client->getProxy();
- $transactionResponse = $payment->beginTransaction($transactionRequest);
- $nit = $transactionResponse['transactionResponse']['nit'];
- $paymentRequest = array('paymentRequest' => array
- (
- 'authorizerId' => $authorizerId,
- 'autoConfirmation' => $autoConfirmation,
- 'cardExpiryDate' => $cardExpiryDate,
- 'cardNumber' => $cardNumber,
- 'cardSecurityCode' => $cardSecurityCode,
- 'customerId' => $customerId,
- 'installmentType' => $installmentType,
- 'installments' => $installments,
- 'nit' => $nit
- ));
- // Ejecutar doPayment
- $inicio = time();
- $result = $payment->doPayment($paymentRequest);
- $tiempo = time() - $inicio;
- // Revisar timeOut del doPayment
- if (($tiempo < 300)) {
- // Intentar hasta 3 veces getStatus
- $aunNo = true;
- $veces = 0;
- while ($aunNo && ($veces < 3)) {
- // Ejecutar getStatus
- $inicio = time();
- $merchantKey = '6837DECF88749CE639CD19A38EB4EEF2D8DB5A297159971C2492DA9146846B46';
- $getStatusRequest = array('merchantKey' => $merchantKey, 'nit' => $nit);
- $resultGetStatus = $payment->getStatus($getStatusRequest);
- // Revisar timeOut del getStatus
- $tiempo = time() - $inicio;
- if (!(($tiempo < 300))) {
- $aunNo = false;
- };
- $veces++;
- };
- if ($aunNo && ($veces != 3)) {
- // FATAL
- }else{
- // PROCESAR $resultGetStatus
- echo '<h2>Status</h2><pre>';
- print_r($resultGetStatus);
- echo '</pre>';
- };
- }else{
- // PROCESAR $result
- echo '<h2>Fault</h2><pre>';
- print_r($result);
- echo '</pre>';
- };
- echo '<h2>Status</h2><pre>';
- print_r($resultGetStatus);
- echo '</pre>';
- if ($client->fault) {
- echo '<h2>Fault</h2><pre>';
- print_r($result);
- echo '</pre>';
- } else {
- $err = $client->getError();
- if ($err) {
- echo '<h2>Error</h2><pre>' . $err . '</pre>';
- } else {
- echo '<h2>Resultado Transaccion</h2><pre>';
- echo $result['paymentResponse']['customerReceipt']
- echo "---------------------------------------<br>";
- echo $result['paymentResponse']['merchantReceipt']
- echo '</pre>';
- echo "<input type='button' name='imprimir' value='Imprimir' onclick='window.print();'>";
- }
- }
- echo '<h2>Request</h2><pre>' . htmlspecialchars($payment->request, ENT_QUOTES) . '</pre>';
- echo '<h2>Response</h2><pre>' . htmlspecialchars($payment->response, ENT_QUOTES) . '</pre>';
- echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement