السبت، 23 مايو 2015

خطأ في اضافة بايبال الى الموقع

اخواني احاول اضافة خاصية الدفع بالبايبال في الموقع لكن اواجه مشكلة وهي خطأ يظهر لي بعد جلب token

في البداية جربت الارسال الكود يوقوم بارسال المعلومات بشكل عادي للبايبال ويظهرها مع token

http://ift.tt/1Ar1TLx

ثم اضيف كود التحقق

public function paymentStatus()

    {
        $payment_id = Session::get('paypal_payment_id');

        Session::forget('paypal_payment_id');

        if(empty(Input::get('PayerID')) || empty(Input::get('token')))
        {
            return "Operation failed";
        }

        $payment = Payment::get($payment_id, $this->_api_context);
        $execution = new PaymentExecution();
        $execution->setPayerId(Input::get('PayerID'));


        $result = $payment->execute($execution, $this->_api_context);

        if($result->getState() == 'approved')
                {
                    return 'Payment was successfull , we Thank you for that';
                }
        else {
            return "Operation failed";
        }
    }

واضيف كود التالي لدالة pay

$amount = new Amount();

        $amount->setCurrency('EUR')
        ->setTotal(Input::get('budget'));

        $transaction = new Transaction();
        $transaction->setAmount($amount)
                    ->setItemList($item_list)
                    ->setDescription('This is just a demo transaction');

        $redirect_url = new RedirectUrls();
        $redirect_url->setReturnUrl(URL::route('paymentStatus'))
                     ->setCancelUrl(URL::route('paymentStatus'));

        $payment = new Payment();
        $payment->setIntent('sale')
                ->setPayer($payer)
                ->setRedirectUrls($redirect_url)
                ->setTransactions(array($transaction));

        try {
                    $payment->create($this->_api_context);
                } catch (\PayPal\Exception\PPConnectionException $ex) {
                    if (\Config::get('app.debug')) {
                        echo "Exception: " . $ex->getMessage() . PHP_EOL;
                        $err_data = json_decode($ex->getData(), true);
                        exit;
                    } else {
                        die('Some error occur, sorry for inconvenient');
                    }
                }

                foreach($payment->getLinks() as $link) {
                    if($link->getRel() == 'approval_url') {
                        $redirect_url = $link->getHref();
                        break;
                    }
                }

                // add payment ID to session
                Session::put('paypal_payment_id', $payment->getId());

                if(isset($redirect_url)) {
                    // redirect to paypal
                    return Redirect::away($redirect_url);
                }

                return Redirect::route('original.route')
                    ->with('error', 'Unknown error occurred');
    }

ولكن يبقى نفس العرض ولا يغير لصفحة الدفع الخاصة بالبايبال

هل من احد لديه الحل



from حسوب I/O - الأكثر شيوعاً http://ift.tt/1HCu5uH

ليست هناك تعليقات:

إرسال تعليق

دائماً، رأيكم يهمنا،