<?php
    require_once 'vendor/autoload.php';
    \Stripe\Stripe::setApiKey('sk_test_51KsrHuBlb1fJ8sQqxGnHRYsTGLT3CxARKehORde2VXbzHayJL7ZBhouGYo4U8r6u6Io0lRudqZJcHMSe6IZjqF6v00X25Kpqb9');
    
    $stripe = new \Stripe\StripeClient('sk_test_51KsrHuBlb1fJ8sQqxGnHRYsTGLT3CxARKehORde2VXbzHayJL7ZBhouGYo4U8r6u6Io0lRudqZJcHMSe6IZjqF6v00X25Kpqb9');

    /*$customerNew = $stripe->customers->create([
      'email' => 'pgcrurom@gmail.com',
      'name' => 'Pablo Cruz'
    ]);*/


    $customer = $stripe->customers->search([
        'query' => 'name:\'Pablo\'',
      ]);

    $payment_intent = $stripe->paymentIntents->retrieve('pi_3NsUxNBlb1fJ8sQq3KLnFO7a');

    /*$paymentNew = $stripe->paymentMethods->attach(
      'pm_1NTwkjBlb1fJ8sQqzjESiYuG',
      ['customer' => 'cus_OGUAREba1SnrgZ']
    );*/



    $balance_transaction_id = $payment_intent->charges->data[0]->balance_transaction;
    $balance_transaction = \Stripe\BalanceTransaction::retrieve($balance_transaction_id);

    error_log(print_r(json_encode($balance_transaction), TRUE)); 
    
    echo "El monto de comisión es de : " . ($balance_transaction->fee / 100);
?>