InvalidArgumentException 空号无效 laravel omnipay paypal 集成

问题描述

使用 omnipay 将 paypal 集成到我的 Web 应用程序,我遇到此错误 invalidargumentexception Empty number is invalid 当我尝试将 project_id 保存在付款表中时出现错误。 下面是我的代码。对于 paypal 正在使用的两个函数。请任何人帮助我一直坚持使用此代码一周,我想将 project_id 保存在付款表中,以便我可以使用它来创建之间的关系两个表既是付款表又是项目表 这是我的 PaymentController 当我在 payment_success 函数添加这部分 'items' => array( array( 'project_id' => $project->project_id ),), 时,出现上述错误

    public function charge(Request $request,$id)
    {
        $project = Project::findOrFail($request->id);
        if($request->input('submit'))
        {
            //$project = new Project();
            $project = Project::findOrFail($request->id);
            $project->update(['user_name' => (Auth::user()->name)]);
            $project->update(['invoice_id' => (null)]);
            $project->update(['payment_status' => ('initialised')]);
            $project->save();
            try {

          
                $response = $this->gateway->purchase(array(

                    'amount' => $project->amount,'items' => array(
                        array(
                            'project_id' => $project->project_id
                        ),'project_id' => $project->project_id,'currency' => env('PAYPAL_CURRENCY'),'returnUrl' => url('paymentsuccess'),'cancelUrl' => url('paymenterror'),))->send();
           
                if ($response->isRedirect()) {
                    $response->redirect(); // this will automatically forward the customer
                } else {
                    // not successful
                    return $response->getMessage();
                }
            } catch(Exception $e) {
                return $e->getMessage();
            }
        }
    }


    public function payment_success(Request $request)
    {
        $project = Session::get('id');
        $paymentId = Session::get('paypalPaymentId');

        // Once the transaction has been approved,we need to complete it.
        if ($request->input('paymentId') && $request->input('PayerID'))
        {
            $transaction = $this->gateway->completePurchase(array(
                'payer_id'             => $request->input('PayerID'),'transactionReference' => $request->input('paymentId'),));
            $response = $transaction->send();
            # Payment is processing but may still fail due e.g to insufficient funds
             //$project = Project::find($id);
          
            if ($response->isSuccessful())
            {
                // The customer has successfully paid.
                $arr_body = $response->getData();
          
                // Insert transaction data into the database
                $isPaymentExist = Payment::where('payment_id',$arr_body['id'])->first();
          
                if(!$isPaymentExist)
                {
                    $payment = new Payment;
                    $payment->payment_id = $arr_body['id'];
                    $payment->user_name = Auth::user()->name;
                    $payment->session_id = Auth::user()->session_id;
                    $payment->project_id = $arr_body['project_id'];
                    $payment->payer_id = $arr_body['payer']['payer_info']['payer_id'];
                    $payment->payer_email = $arr_body['payer']['payer_info']['email'];
                    $payment->amount = $arr_body['transactions'][0]['amount']['total'];
                    $payment->currency = env('PAYPAL_CURRENCY');
                    $payment->payment_status = $arr_body['state'];
                    $payment->save();
                }
                return redirect('/client/projects')->with('success','Payment is successful. Your transaction id is: '. $arr_body['id']);
            } else {
                //return $response->getMessage();
                 return Redirect::to('/client/projects')->$response->getMessage();
            }
        } else {
            //return 'Transaction is declined';
            return redirect('/client/projects')->with('success','Transaction is declined');
        }
    }
  

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...