public function test_getXML_IfThePayerIsSet_TheXmlGeneratorMustReturnItOnResponse()
 {
     $moip = new MoIP();
     $moip->setEnvironment('sandbox');
     $moip->setCredential(array('key' => 'KBJW7FOG1M5WV1J7KCFURVO4TMTVTTBSBM3ZNJW4', 'token' => 'PE8ZECRX4ZPV3OF7HRG136HEPDOOTNUB'));
     $moip->setUniqueID('teste9');
     $moip->setValue('100.30');
     $moip->setReason('Teste do MoIP-PHP');
     $moip->setPayer(array('nome' => 'Jose da Silva', 'email' => 'jose@silva.com', 'endereco' => array('logradouro' => 'Rua do Zé', 'numero' => '45', 'complemento' => 'z', 'cidade' => 'São Paulo', 'estado' => 'SP', 'pais' => 'BRA', 'cep' => '01230-000', 'telefone' => '1188888888')));
     $moip->validate();
     $xml = new SimpleXmlElement($moip->getXML());
     $this->assertTrue((string) $xml->InstrucaoUnica->Pagador->Nome == "Jose da Silva");
     $this->assertTrue((string) $xml->InstrucaoUnica->Pagador->EnderecoCobranca->Logradouro == "Rua do Zé");
 }
Example #2
0
    public function testVerificaSeXMLGeradoEhValidoQuandoParametrosBasicosForemPassados()
    {    
        //com forma de pagamento em boleto com instruções extra
        $current = new MoIP(); 
        $current->setUniqueID(123456)
            ->setReason('Pagamento de testes')
            ->setValue('12345')
            ->addPaymentWay('boleto',array('dias_expiracao'=>array('tipo'=>'Corridos','dias'=>5),
                'instrucoes'=>array('Nao receber apos o vencimento','Outra instrucao'))); 
        $xml = new SimpleXmlElement($current->getXML()); 



        $this->assertEquals((int)$xml->InstrucaoUnica->Boleto->DiasExpiracao,5);
        $this->assertEquals((string)$xml->InstrucaoUnica->Boleto->DiasExpiracao["Tipo"],"Corridos");
        $this->assertEquals((string)$xml->InstrucaoUnica->Boleto->Instrucao1,"Nao receber apos o vencimento");
        $this->assertEquals((string)$xml->InstrucaoUnica->Boleto->Instrucao2,"Outra instrucao");
    }
                fwrite($txt, "-----------------------------------\n");
                fwrite($txt, $name . "\n");
                fwrite($txt, print_r($var, true) . "\n");
                fclose($txt);
                //
            }
        } else {
            echo '<pre><b>' . $name . '</b><br>' . print_r($var, true) . '</pre>';
        }
    }
}
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/MoIP.php';
$errors = '';
$result = false;
$MoIP = new MoIP();
if ($_POST != "") {
    $result = "VERIFICADO";
    $id_var = explode('[', $_POST['id_transacao']);
    $id_var_explode = $id_var[1];
    $tmp = explode(']', $id_var_explode);
    $id_transacao_moip = $tmp[0];
    $id_moeda = Configuration::get('PS_CURRENCY_DEFAULT');
} else {
    $result = "FALHOU";
}
if ($result == 'VERIFICADO') {
    if (!isset($_POST['valor'])) {
        $errors .= $MoIP->getL('valor_moip');
    }
    if (!isset($_POST['status_pagamento'])) {
Example #4
0
<?php

if (!function_exists('log_var')) {
    function log_var($var, $name = '', $to_file = false)
    {
        if ($to_file == true) {
            $txt = @fopen('debug.txt', 'a');
            if ($txt) {
                fwrite($txt, "-----------------------------------\n");
                fwrite($txt, $name . "\n");
                fwrite($txt, print_r($var, true) . "\n");
                fclose($txt);
                //
            }
        } else {
            echo '<pre><b>' . $name . '</b><br>' . print_r($var, true) . '</pre>';
        }
    }
}
/* SSL Management */
$useSSL = true;
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../header.php';
include dirname(__FILE__) . '/MoIP.php';
if (!$cookie->isLogged()) {
    Tools::redirect('authentication.php?back=order.php');
}
$MoIP = new MoIP();
echo $MoIP->execPayment($cart);
log_var("cookie: " . $cookie->isLogged() . "\ncart: " . $MoIP->execPayment($cart), "payment.php", true);
include_once dirname(__FILE__) . '/../../footer.php';