vincentchacha / e-wallet

Wallet project based on laravel. The project is integrated with stripe for card payments and paypal APIs. It is 90% complete with features including deposits send money with cool ui. Clone the project and start your wallet system asap. cheers
91 stars 69 forks source link

I got this error sir, please help #3

Open heyharii opened 6 years ago

heyharii commented 6 years ago
    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 commented 6 years ago

Hi, thr part of inserting to database from $transaction = new Transactions() has got a bug, i will try to update the code soonest. You can also comment that part and use the paypals recommended way of using getters i.e. getAmount()

On Mar 17, 2018 3:15 AM, "haariiii" notifications@github.com wrote:

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"

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vincentchacha/e-wallet/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AMqjFZoOQtvd0jDAIzEWPJsLzV6WJuMiks5tfFWkgaJpZM4SulpP .