Created
May 7, 2013 14:08
-
-
Save Sigmus/5532830 to your computer and use it in GitHub Desktop.
Parcelas Moip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Method addParcel() | |
* | |
* Allows to add a order to parceling. | |
* | |
* @param int $min The minimum number of parcels. | |
* @param int $max The maximum number of parcels. | |
* @param float $rate The percentual value of rates | |
* @param boolean $transfer "true" defines the amount of interest charged by MoIP installment to be paid by the payer | |
* @return Moip | |
* @access public | |
*/ | |
public function addParcel($min, $max, $rate=null, $transfer=false) { | |
if (!isset($this->xml->InstrucaoUnica->Parcelamentos)) { | |
$this->xml->InstrucaoUnica->addChild('Parcelamentos'); | |
} | |
$parcela = $this->xml->InstrucaoUnica->Parcelamentos->addChild('Parcelamento'); | |
if (is_numeric($min) && $min <= 12) | |
$parcela->addChild('MinimoParcelas', $min); | |
else | |
$this->setError('Error: Minimum parcel can not be greater than 12.'); | |
if (is_numeric($max) && $max <= 12) | |
$parcela->addChild('MaximoParcelas', $max); | |
else | |
$this->setError('Error: Maximum amount can not be greater than 12.'); | |
$parcela->addChild('Recebimento', 'AVista'); | |
if ($transfer === false) { | |
if (isset($rate)) { | |
if (is_numeric($rate)) | |
$parcela->addChild('Juros', $rate); | |
else | |
$this->setError('Error: Rate must be numeric'); | |
} | |
}else { | |
if (is_bool($transfer)) | |
$parcela->addChild('Repassar', $transfer); | |
else | |
$this->setError('Error: Transfer must be boolean'); | |
} | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment