0
votes

I am creating a WordPress plugin, and trying to pull payments details from stripe API done via third party. I have tried everything mention in this code but I am not able to pull data of Payments from stripe.

enter image description here

I need to fetch payment details from stripe API

https://stripe.com/docs/api/transfers?lang=php

I have tried payouts \Stripe\Payout::all() but getting empty object

Here is my code:

namespace wpmember;

class WPMember
{
    public function __construct()
    {       
        add_action( 'admin_menu', array($this, 'wpdocs_register_my_custom_menu_page') );                                         
    }


    public function wpdocs_register_my_custom_menu_page() 
    {
        add_menu_page(
            'Custom Menu Title',
            'custom menu',
            'manage_options',
            'custom-menu',
            $this->connect_stripe()
        );

    }

    public function connect_stripe()    
    {            
        require ( PLUGIN_DIR . 'vendor/autoload.php');  
        //echo PLUGIN_DIR . 'vendor/autoload.php';
        \Stripe\Stripe::setApiKey("xxxx");
        \Stripe\Stripe::setApiKey("xxxx");      

        $customers = \Stripe\Customer::all(["limit" => 3]);
        $products  = \Stripe\Product::all(["limit" => 3]);
        $subscriptions = \Stripe\Subscription::all(['limit'=>3]);
        $orders = \Stripe\Order::all(["limit" => 3]);
        $allpayouts = \Stripe\Payout::all(["limit" => 3]);
        $paymentIntent = \Stripe\PaymentIntent::all(["limit" => 3]);
        //$payout = \Stripe\Payout::retrieve($allpayouts->data[0]->id);
        $invoice = \Stripe\Invoice::all(["limit" => 3]);        

        echo "<pre>";
        print_r($subscriptions);
        echo "</pre>";
    }   


}
2
it would be great if you update your question with the error description you're getting now - Alexey
There is no error, I need to pull transaction/payment data as shown in image. Hope you read my question carefully. - Hemant Kumar
heh :) I hope you read my comment carefully. If there is no error you're getting the expected results, so what's the question? - Alexey
@alexey I have added some more info for your clarity. - Hemant Kumar

2 Answers

0
votes

You seem to be fetching Payouts which are according to the Stripe API reference are the transfers from your Stripe account to your bank account. Which do not seem to be Charges object you showed on your screenshot or Transfer objects that could be fetched with \Stripe\Transfer::all().

0
votes

Here you can get the payment details:

require ( PLUGIN_DIR . 'vendor/autoload.php');    
\Stripe\Stripe::setApiKey("pk_test_VNbKcUGTqFIlyfIwFgizNx8h");
\Stripe\Stripe::setApiKey("sk_test_7VbuCbiZsDZjDHHlOtHeCqo7");         

$charges = \Stripe\Charge::all(["limit" => 3]);
print_r($charges);