amsgames / laravel-shop

Laravel shop package
MIT License
483 stars 166 forks source link

Ability to list users their old transactions [enhancement][help wanted][question] #24

Closed OzanKurt closed 8 years ago

OzanKurt commented 8 years ago
        $apiContext = new ApiContext(new OAuthTokenCredential(
            config('services.paypal.client_id'),
            config('services.paypal.secret')
        ));

        if (!config('services.paypal.sandbox'))
            $apiContext->setConfig(['mode' => 'live']);

        $transactions = collect();

        foreach (auth()->user()->orders as $order) {
            $transactions = $transactions->merge($order->transactions()->where('detail', 'Success')->get());
        }

        foreach ($transactions as $transaction) {
            $payments[] = Payment::get($transaction->transaction_id, $apiContext)->toArray();
        }

This following code allows me to get all the payments done by the user but somehow their items are always empty. Do you have any idea about why this is happening?

amsgames commented 8 years ago

Items are linked to orders not transactions. Access the items through the order variable. On Dec 2, 2015 12:13 PM, "Ozan Kurt" notifications@github.com wrote:

    $apiContext = new ApiContext(new OAuthTokenCredential(            config('services.paypal.client_id'),            config('services.paypal.secret')        ));        if (!config('services.paypal.sandbox'))            $apiContext->setConfig(['mode' => 'live']);        $transactions = collect();        foreach (auth()->user()->orders as $order) {            $transactions = $transactions->merge($order->transactions()->where('detail', 'Success')->get());        }        foreach ($transactions as $transaction) {            $payments[] = Payment::get($transaction->transaction_id, $apiContext)->toArray();        }

This following code allows me to get all the payments done by the user but somehow their items are always empty.

— Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/24.

OzanKurt commented 8 years ago

Awesome! Thanks a lot mate