From 4c7fb2f6394460af883b7327918e1c8a35aa15fd Mon Sep 17 00:00:00 2001 From: "sillas.soares" Date: Thu, 12 Jun 2014 10:41:10 -0300 Subject: [PATCH] Add a incoming method --- examples.php | 1 + lib/Moip.php | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/examples.php b/examples.php index 69a3a76..44ec72a 100644 --- a/examples.php +++ b/examples.php @@ -79,6 +79,7 @@ function exampleAddParcel($example='1') { 'zipCode' => '01230-000', 'phone' => '(11)8888-8888'))); $moip->validate('Identification'); + $moip->setIncomingType('AVista'); if ($example == '1') $moip->addParcel('2', '12'); diff --git a/lib/Moip.php b/lib/Moip.php index 4b2f392..310abef 100644 --- a/lib/Moip.php +++ b/lib/Moip.php @@ -157,6 +157,13 @@ class Moip { * * @access public */ + protected $incoming_type; + /** + * @var string + */ + + protected $incoming_valid_types = ['AVista','Parcelado']; + public function __construct() { $this->setEnvironment(); @@ -631,6 +638,22 @@ public function addComission($reason, $receiver, $value, $percentageValue=false, return $this; } + /** + * Method setIncomingType() + * + * Add a Incoming method + * + * @param string $incoming Defauls as 'AVista' or can be setted as 'Parcelado' + */ + + public function setIncomingType($incoming_type = 'AVista') { + $this->incoming_type = $incoming_type; + } + + public function getIncomingType(){ + return in_array($this->incoming_type, $this->incoming_valid_types) ? $this->incoming_type : 'AVista'; + } + /** * Method addParcel() * @@ -659,7 +682,7 @@ public function addParcel($min, $max, $rate=null, $transfer=false) { else $this->setError('Error: Maximum amount can not be greater than 12.'); - $parcela->addChild('Recebimento', 'AVista'); + $parcela->addChild('Recebimento', $this->getIncomingType()); if ($transfer === false) { if (isset($rate)) {