Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I got this error sir, please help #3

Open
heyharii opened this issue Mar 17, 2018 · 1 comment
Open

I got this error sir, please help #3

heyharii opened this issue Mar 17, 2018 · 1 comment

Comments

@heyharii
Copy link

    if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
        \Session::put('error','Payment failed');
        return Redirect::route('paywithpaypal');
    }
    $payment = Payment::get($payment_id, $this->_api_context);
    /** PaymentExecution object includes information necessary **/
    /** to execute a PayPal account payment. **/
    /** The payer_id is added to the request query parameters **/
    /** when the user is redirected from paypal back to your site **/
    $execution = new PaymentExecution();
    $execution->setPayerId(Input::get('PayerID'));
    /**Execute the payment **/
    $result = $payment->execute($execution, $this->_api_context);
    /** dd($result);exit; /** DEBUG RESULT, remove it later **/
    if ($result->getState() == 'approved') { 
        // dd($result);

        $transactions=new Transactions();
        // $transactions->id=$result->id;
        $transactions->amount=$result->transactions[0]->amount[0]->total;
        $transactions->sender=$result->payer[0]->payer_info[0]->email;
        $transactions->type=$result->payer[0]->payment_method;
        $transactions->currency=$result->transactions[0]->amount[0]->currency;
        $transactions->description=$result->transactions[0]->description;
        $transactions->fee='0';
        $transactions->client_id=1;
        $transactions->status=$result->state;
        $transactions->receiver=$result->transactions[0]->payee[0]->email;

        $transactions->Save();



        /** it's all right **/
        /** Here Write your database logic like that insert record or value in database if you want **/

        \Session::put('success','Payment success');
        return Redirect::route('paywithpaypal');
    }
    \Session::put('error','Payment failed');

Arguments
"Cannot use object of type PayPal\Api\Amount as array"

@vincentchacha
Copy link
Owner

vincentchacha commented Mar 17, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants