PayU::$isTest = false; $startTime = date('Y-m-d H:i:s'); Environment::setPaymentsCustomUrl("https://stg.api.payulatam.com/payments-api/4.0/service.cgi"); // Queries URL Environment::setReportsCustomUrl("https://stg.api.payulatam.com/reports-api/4.0/service.cgi"); // Subscriptions for recurring payments URL Environment::setSubscriptionsCustomUrl("https://stg.api.payulatam.com/payments-api/rest/v4.3/"); // Environment::setPaymentsCustomUrl("https://api.payulatam.com/payments-api/4.0/service.cgi"); // // Queries URL // Environment::setReportsCustomUrl("https://api.payulatam.com/reports-api/4.0/service.cgi"); // // Subscriptions for recurring payments URL // Environment::setSubscriptionsCustomUrl("https://api.payulatam.com/payments-api/rest/v4.3/"); $reference_code = 'comprame_test_10000171'; $parameters = array(PayUParameters::REFERENCE_CODE => $reference_code); //query by ReferenceCode $order = PayUReports::getOrderDetailByReferenceCode($parameters); //query by TRANSACTION_ID,must set TRANSACTION_ID // $order = PayUReports::getTransactionResponse($parameters); if ($order) { echo "-----------------------------------<br>"; foreach ($order as $_order) { // var_dump($_order); echo $_order->id . "<br>"; echo $_order->accountId . "<br>"; echo $_order->status . "<br>"; echo $_order->referenceCode . "<br>"; echo $_order->description . "<br>"; echo "-------------------------------------------------------------<br>"; } $endTime = date("Y-m-d H:i:s"); $content = 'startTime:' . $startTime . '-----endTime:' . $endTime . PHP_EOL;
<?php /** * 查询Payu PING */ require_once 'payulib/PayU.php'; PayU::$apiKey = "6u39nqhq8ftd0hlvnjfs66eh8c"; PayU::$merchantId = "500238"; PayU::$apiLogin = "******"; PayU::$language = SupportedLanguages::ES; PayU::$isTest = true; $startTime = date('Y-m-d H:i:s'); Environment::setPaymentsCustomUrl("https://stg.api.payulatam.com/payments-api/4.0/service.cgi"); // Queries URL Environment::setReportsCustomUrl("https://stg.api.payulatam.com/reports-api/4.0/service.cgi"); // Subscriptions for recurring payments URL Environment::setSubscriptionsCustomUrl("https://stg.api.payulatam.com/payments-api/rest/v4.3/"); $response = PayUReports::doPing(); echo $response->code; $endTime = date("Y-m-d H:i:s"); $content = 'startTime:' . $startTime . '-----endTime:' . $endTime . PHP_EOL; $content .= json_encode($response) . PHP_EOL; $handle = fopen('logs/ping.log', "a+"); $str = fwrite($handle, $content); fclose($handle);
private function orderVerify($value) { $response = new stdClass(); if (empty($value)) { $response->status = "Empty Value"; $response->status_code = 201; } else { $response->status_code = 202; } require_once 'plugin/payu_sdk/PayU.php'; Environment::setPaymentsCustomUrl("https://api.payulatam.com/payments-api/4.0/service.cgi"); Environment::setReportsCustomUrl("https://api.payulatam.com/reports-api/4.0/service.cgi"); Environment::setSubscriptionsCustomUrl("https://api.payulatam.com/payments-api/rest/v4.3/"); $commerce = $this->getDataCommerce(); PayU::$apiKey = $commerce->data['APIKEY']; // apiKey. PayU::$apiLogin = $commerce->data['APILOGIN']; // apiLogin. PayU::$merchantId = $commerce->data['MERCHANTID']; // Id de Comercio. PayU::$language = SupportedLanguages::ES; //Seleccione el idioma. PayU::$isTest = true; //Dejarlo True cuando sean pruebas. $transaction = new stdClass(); // Código de referencia de la orden. $parameters = array(PayUParameters::REFERENCE_CODE => $value); $response_payu = PayUReports::getOrderDetailByReferenceCode($parameters); foreach ($response_payu as $order) { $order->accountId; $order->status; $order->referenceCode; $order->additionalValues->TX_VALUE->value; $order->additionalValues->TX_TAX->value; if ($order->buyer) { $order->buyer->emailAddress; $order->buyer->fullName; } $transactions = $order->transactions; foreach ($transactions as $transaction) { $transaction->type; $transaction->transactionResponse->state; $transaction->transactionResponse->paymentNetworkResponseCode; $transaction->transactionResponse->trazabilityCode; $transaction->transactionResponse->responseCode; if ($transaction->payer) { $transaction->payer->fullName; $transaction->payer->emailAddress; } } } $result = $this->updateDataCommerceByReference($value, $transaction); $response->answer = $transaction; $response->status_code = 200; $response->status = $result->status; return $response; }
PayU::$language = SupportedLanguages::ES; PayU::$isTest = false; $startTime = date('Y-m-d H:i:s'); // Environment::setPaymentsCustomUrl("https://stg.api.payulatam.com/payments-api/4.0/service.cgi"); // // Queries URL // Environment::setReportsCustomUrl("https://stg.api.payulatam.com/reports-api/4.0/service.cgi"); // // Subscriptions for recurring payments URL // Environment::setSubscriptionsCustomUrl("https://stg.api.payulatam.com/payments-api/rest/v4.3/"); Environment::setPaymentsCustomUrl("https://api.payulatam.com/payments-api/4.0/service.cgi"); // Queries URL Environment::setReportsCustomUrl("https://api.payulatam.com/reports-api/4.0/service.cgi"); // Subscriptions for recurring payments URL Environment::setSubscriptionsCustomUrl("https://api.payulatam.com/payments-api/rest/v4.3/"); $transaction_id = 'afd826c9-1825-436e-ba7c-09010848ef51'; $parameters = array(PayUParameters::TRANSACTION_ID => $transaction_id); $response = PayUReports::getTransactionResponse($parameters); //query by ReferenceCode // $order = PayUReports::getOrderDetailByReferenceCode($parameters); //query by TRANSACTION_ID,must set TRANSACTION_ID // $order = PayUReports::getTransactionResponse($parameters); if ($response) { var_dump($response); $endTime = date("Y-m-d H:i:s"); $content = 'startTime:' . $startTime . '-----endTime:' . $endTime . PHP_EOL; $content .= json_encode($response) . PHP_EOL; $handle = fopen('logs/queryTransactionId.php', "a+"); $str = fwrite($handle, $content); fclose($handle); } else { echo 'ERROR'; }