laravel paypal支付整合

时间:2016-03-24 07:52:17

标签: php laravel paypal

laravel composer.json文件添加require

"paypal/rest-api-sdk-php": "*"

之后我更新了composer,然后是route.php文件

 Route::get('payment', 'PaypalPaymentController@getPaymentStatus');

PaypalPaymentController.php

<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\ExecutePayment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\Transaction;

class PaypalPaymentController extends Controller
{   
    private $_apiContext;
    public function __construct()
    {
        // setup PayPal api context
        $paypal_conf = Config::get('paypal_payment');
        $this->_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
        $this->_api_context->setConfig($paypal_conf['settings']);
   }
    public function getPaymentStatus()
    { echo "success";exit;
    }
}

paypal_payment.php

<?php

return array(
    // set your paypal credential
    'client_id' => 'AU7H2ny1QyVJCgkb2-fashll2vi2TzzomIoR_xU5NhHoxdOsqZ9WIX5yxRZsi0qUvQ-NS2u4dWvwcmIm',
    'secret' => 'ENDTVkcg9qV1cKUjb3zVtlZpzkdf4do-ogOxOEpUa25AGljctawwCcCZphN8PmJfIcWbgEvvSuOlOZ41',

    /**
     * SDK configuration 
     */
    'settings' => array(
        /**
         * Available option 'sandbox' or 'live'
         */
        'mode' => 'sandbox',

        /**
         * Specify the max request time in seconds
         */
        'http.ConnectionTimeOut' => 30,

        /**
         * Whether want to log to a file
         */
        'log.LogEnabled' => true,

        /**
         * Specify the file that want to write on
         */
        'log.FileName' => storage_path() . '/logs/paypal.log',

        /**
         * Available option 'FINE', 'INFO', 'WARN' or 'ERROR'
         *
         * Logging is most verbose in the 'FINE' level and decreases as you
         * proceed towards ERROR
         */
        'log.LogLevel' => 'FINE'
    ),
);

但我在控制台中收到状态码:(500内部服务器错误)

我是laravel paypalment的新手。什么是我的代码的错误需要更新app.php文件????

0 个答案:

没有答案