简体   繁体   English

在 Codeigniter 中集成 PHP Paypal SDK RestAPI?

[英]Integrating PHP Paypal SDK RestAPI in Codeigniter?

I had download the PHP PayPal SDK here .我在这里下载了 PHP PayPal SDK。 Now trying to add the autoload and use use PayPal\\Rest\\ApiContext but it is continuously prompting error message.现在尝试添加自动加载并使用 use PayPal\\Rest\\ApiContext 但它不断提示错误消息。 sdk location -> /application/libraries/PayPal_PHP_SDK/

Error Message错误信息

在此处输入图片说明

I had a controller named PayPal.php我有一个名为PayPal.php的控制器

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

// require APPPATH . 'libraries/vendor/autoload.php';
require APPPATH . 'libraries/vendor/PayPal_PHP_SDK/autoload.php';

use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;

class Paypal extends CI_Controller {

public function __construct(){  
    parent::__construct();

    $this->load->library('session');        
    $this->load->helper(array('form', 'url'));
}

public function index() {

    // After Step 1
    $apiContext = new \PayPal\Rest\ApiContext(
            new \PayPal\Auth\OAuthTokenCredential(
                'AeH73iyUSw2E_A6VRzeiyxfxR8QL9wy09XUIj5rUp42Uh9s3sQbHQTv2UdbVSx8cFGGwaapxxxxxxxxx',     
// ClientID
                'ELEN6UgB4phJT2Onwk4GjQqYyEobN_Hd-eKWlZCYMxtucsc-ZavqmKHnRSvfAknM6pjBUOxxxxxxxxxx'      
// ClientSecret
            )
    );
    echo '<pre>';print_r($apiContext);exit; 

    echo "paypal";
}

I had tried by composer and direct download both but still facing same error message.我已经尝试过 Composer 和直接下载,但仍然面临相同的错误消息。 What am I missing, please guide your help will be appreciated.我错过了什么,请指导您的帮助将不胜感激。

While not related to your specific problem, the v1 PayPal-PHP-SDK is old and should not be used.虽然与您的具体问题无关,但 v1 PayPal-PHP-SDK 已经过时,不应使用。

Instead, use the v2 Checkout-PHP-SDK .相反,请使用 v2 Checkout-PHP-SDK


For the best user experience, combine with the front-end https://developer.paypal.com/demo/checkout/#/pattern/server为获得最佳用户体验,结合前端https://developer.paypal.com/demo/checkout/#/pattern/server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM