Skip to content

Commit

Permalink
update complementos pago
Browse files Browse the repository at this point in the history
  • Loading branch information
gogl92 committed Jul 13, 2018
1 parent c61a14f commit 15c1744
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Facturacom33.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use inquid\facturacom\models\Serie;
use yii\base\Model;
use yii\db\ActiveRecord;
use yii\helpers\Json;

class Facturacom33 extends HttpClientV3
{
Expand Down Expand Up @@ -165,7 +166,7 @@ public function createFactura33($factura)
}
return new Error(500, $factura->getErrors());
}

/**
* @param $data
* @return Error|\yii\httpclient\Response
Expand All @@ -174,7 +175,7 @@ public function createComplementoPago($data)
{
$this->API_VERSION = 'api/v3';
try {
return $this->sendRequest('post', 'cfdi33/complemento/pagos/create', $data);
return $this->sendRequestPlainJson('post', 'cfdi33/complemento/pagos/create', $data);
} catch (\Exception $exception) {
return new Error(500, $exception->getMessage());
}
Expand Down
21 changes: 21 additions & 0 deletions src/HttpClientV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected function sendRequest($method, $path, $data = null)
{
$client = new Client(['baseUrl' => $this->getUrl() . '/' . $path]);
$request = $client->createRequest();

if ($data) {
$request->setData($data);
}
Expand All @@ -72,6 +73,26 @@ protected function sendRequest($method, $path, $data = null)
return $request->send();
}

/**
* @param string $method
* @param string $path
* @param null|array $data
* @return \yii\httpclient\Response
*/
protected function sendRequestPlainJson($method, $path, $data = null)
{
$client = new Client(['baseUrl' => $this->getUrl() . '/' . $path]);
$request = $client->createRequest();
$request->setFormat(Client::FORMAT_JSON);
if ($data) {
$request->setContent($data);
}
$request->setHeaders($this->getHeaders());
$request->setMethod($method);
$request->setOptions($this->_options);
return $request->send();
}

/**
* @param \yii\httpclient\Response $response
* @param string $className
Expand Down
73 changes: 73 additions & 0 deletions src/models/ComplementoPago.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* Created by PhpStorm.
* User: gogl92
* Date: 15/06/18
* Time: 01:13 PM
*/

namespace inquid\facturacom\models;


use yii\base\Model;

class ComplementoPago extends Model
{
/**
* @var string $TipoCfdi
*/
public $TipoCfdi;
/**
* @var string $NumOrder
*/
public $NumOrder;
/**
* @var boolean $EnviarCorreo
*/
public $EnviarCorreo;
/**
* @var double $Version
*/
public $Version;
/**
* @var string $Serie
*/
public $Serie;
/**
* @var string $Fecha
*/
public $Fecha;
/**
* @var string $Folio
*/
public $Folio;
/**
* @var float $SubTotal
*/
public $SubTotal;
/**
* @var float $Total
*/
public $Total;
/**
* @var string $Moneda
*/
public $Moneda;
/**
* @var string $UsoCFDI
*/
public $UsoCFDI;

/**
* @var array $Receptor
*/
public $Receptor = [
"ResidenciaFiscal" => "",
"NumRegIdTrib"=>"",
"UID" => ""
];
/**
* @var Conceptos $Conceptos
*/
public $Conceptos = [];
}

0 comments on commit 15c1744

Please sign in to comment.