Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
123 stars 134 forks source link

List a User's Transactions limit #542

Closed jeromebsr closed 2 years ago

jeromebsr commented 2 years ago

Hi there,

I try to get all user transactions but I only can get 10. Is there a limit ?

    /**
     * @return array
     */
    public function getUserTransactions(): array
    {
        return $this->loadApi()->Users->GetTransactions($this->getMangoPayUser()->Id);
    }

Capture d’écran 2022-02-07 145247

Thanks,

H4wKs commented 2 years ago

Hi @jeromebsr,

The MangoPay API return by default up to 10 results, you can read about this limitation here : https://docs.mangopay.com/guide/lists-pagination-management

If you give a look to the GetTransactions function you can see there are some options :

public function GetTransactions($userId, & $pagination = null, $filter = null, $sorting = null)

So to get for example the first 100 transactions, you can do :

$pagination = new \MangoPay\Pagination(1, 100);
$transaction = $mangoPayApi->Users->GetTransactions($mangoPayUserId, $pagination);

100 is the maximum item per page you can set, then you need to use the pagination per page.

Better late then never, I hope this help, if not it may help someone else :)

Cheers

jeromebsr commented 2 years ago

Hi ! Thanks for that :)

Can you help me on another issue ?

I would like to make the buyer pay the fees and not the seller, and by default it is the seller who will pay them, I can't charge the buyer's wallet.

Do you have an idea ? I've been around the doc and called mangopay but no one can help me with this.

H4wKs commented 2 years ago

I would just add the fee to the selling price (debited funds).

Exemple: Your seller sell a product for an amount of 20€ and you want to charge 10% fee for the platform. Fee are here equal to 2€ So debited fund = amount + fee = 22€ Buyer pay 22€, you get 2€ fee and seller get the 20€ which is the initial selling price so all the fee are supported by the buyer.

I made the example simple here. You need to calculate the fee to cover transaction fee + your margins, but you get the point.

jeromebsr commented 2 years ago

EDIT : Solved ! Thank you for your help !

H4wKs commented 2 years ago

EDIT : Solved ! Thank you for your help !

I was about to answer your message but I guess you figured it out :)

jeromebsr commented 2 years ago

EDIT : Solved ! Thank you for your help !

I was about to answer your message but I guess you figured it out :)

Yes indeed ! Just add the fee to the amount and that's it ! I was too focused on Fees object ^^

H4wKs commented 2 years ago

Yes indeed ! Just add the fee to the amount and that's it !

Exactly.

I was too focused on Fees object ^^

Sometime, we struggle more with the most easiest things, it's so simple that we just don't see it, happen to me all the time.