简体   繁体   中英

Integrating PHP Paypal SDK RestAPI in Codeigniter?

I had download the PHP PayPal SDK here . Now trying to add the autoload and use use PayPal\\Rest\\ApiContext but it is continuously prompting error message. sdk location -> /application/libraries/PayPal_PHP_SDK/

Error Message

在此处输入图片说明

I had a controller named 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. 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.

Instead, use the v2 Checkout-PHP-SDK .


For the best user experience, combine with the front-end https://developer.paypal.com/demo/checkout/#/pattern/server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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