Git Product home page Git Product logo

buttonmanager-sdk-php's Introduction

PayPal PHP ButtonManager SDK

Migrating from 3.x to 4.x

We have made a change to 4.x to make it compatible with other PayPal Classic SDKs.

  • Change references from \PayPal\Service\PayPalAPIInterfaceServiceService to \PayPal\Service\ButtonManagerService.

Support

Please contact PayPal Technical Support for any live or account issues.

Prerequisites

PayPal's PHP ButtonManager SDK requires:

  • PHP 5.3 and above
  • curl/openssl PHP extensions

Running the sample

To run the bundled sample, first copy the samples folder to your web server root. You will then need to install the SDK as a dependency using either composer (PHP v5.3+ only).

run composer update from the samples folder.

Using the SDK

To use the SDK,

  • Create a composer.json file with the following contents.
{
    "name": "me/shopping-cart-app",
    "require": {
        "paypal/buttonmanager-sdk-php": "4.*"
    }
}
  • Install the SDK as a dependency using composer.
  • Require vendor/autoload.php in your application.
  • Choose how you would like to configure the SDK - You can either:
    • Create a hashmap containing configuration parameters and pass it to the service object, OR
    • Create a sdk_config.ini file and set the PP_CONFIG_PATH constant to point to the directory where this file exists.
  • Instantiate a service wrapper object and a request object as per your project's needs.
  • Invoke the appropriate method on the service object.

For example,

    // Sets config file path(if config file is used) and registers the classloader
    require("PPBootStrap.php");
    
    use PayPal\PayPalAPI\BMButtonSearchReq;
    use PayPal\PayPalAPI\BMButtonSearchRequestType;
    use PayPal\Service\ButtonManagerService;
    
    // Array containing credentials and confiuration parameters. (not required if config file is used)
    $config = array(
       'mode' => 'sandbox',
       'acct1.UserName' => 'jb-us-seller_api1.paypal.com',
       'acct1.Password' => 'WX4WTU3S8MY44S7F',
       "acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy"
       .....
    );
    
    $buttonSearchReq = new BMButtonSearchReq();
    $buttonSearchReq->BMButtonSearchRequest = new BMButtonSearchRequestType();
    ......
    
    $buttonManagerService = new ButtonManagerService($config);
    $buttonSearchResponse = $buttonManagerService->BMButtonSearch($buttonSearchReq);
    
    if(strtoupper($buttonSearchResponse->Ack) == 'SUCCESS') {
        // Success
    }

Authentication

The SDK provides multiple ways to authenticate your API call.

    use PayPal\Auth\PPCertificateCredential;
    use PayPal\Auth\PPTokenAuthorization;
    
    $buttonManagerService = new ButtonManagerService($config);
    
    // Use the default account (the first account) configured in sdk_config.ini
    $response = $buttonManagerService->BMButtonSearch($buttonSearchReq);
    
    // Use a specific account configured in sdk_config.ini
    $response = $buttonManagerService->BMButtonSearch($buttonSearchReq, 'jb-us-seller_api1.paypal.com');	
    
    // Pass in a dynamically created API credential object
    $cred = new PPCertificateCredential("username", "password", "path-to-pem-file");
    $cred->setThirdPartyAuthorization(new PPTokenAuthorization("accessToken", "tokenSecret"));
    $response = $buttonManagerService->BMButtonSearch($buttonSearchReq, $cred);

SDK Configuration

The SDK allows you to configure the following parameters:

  • Integration mode (sandbox/live)
  • (Multiple) API account credentials
  • HTTP connection parameters
  • Logging

Dynamic configuration values can be set by passing a map of credential and config values (if config map is passed the config file is ignored)

    $config = array(
       'mode' => 'sandbox',
       'acct1.UserName' => 'jb-us-seller_api1.paypal.com',
       'acct1.Password' => 'WX4WTU3S8MY44S7F'
       .....
    );
    $service  = new ButtonManagerService($config); 

Alternatively, you can configure the SDK via the sdk_config.ini file.

    define('PP_CONFIG_PATH', '/directory/that/contains/sdk_config.ini');
    $service  = new ButtonManagerService();

You can refer full list of configuration parameters in wiki page.

Instant Payment Notification (IPN)

Please refer to the IPN-README in 'samples/IPN' directory

POODLE Update

  • Because of the Poodle vulnerability, PayPal has disabled SSLv3.
  • To enable TLS encryption, the changes were made to PPHttpConfig.php in SDK Core to use a cipher list specific to TLS encryption.
    /**
     * Some default options for curl
     * These are typically overridden by PPConnectionManager
     */
    public static $DEFAULT_CURL_OPTS = array(
        CURLOPT_SSLVERSION => 1,
        CURLOPT_CONNECTTIMEOUT => 10,
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_TIMEOUT        => 60,   // maximum number of seconds to allow cURL functions to execute
        CURLOPT_USERAGENT      => 'PayPal-PHP-SDK',
        CURLOPT_HTTPHEADER     => array(),
        CURLOPT_SSL_VERIFYHOST => 2,
        CURLOPT_SSL_VERIFYPEER => 1,
        CURLOPT_SSL_CIPHER_LIST => 'TLSv1',
    );
  • There are two primary changes done to curl options:
    • CURLOPT_SSLVERSION is set to 1 . See here for more information
    • CURLOPT_SSL_CIPHER_LIST was set to TLSv1, See here for more information

Links

buttonmanager-sdk-php's People

Contributors

aydiv avatar braebot avatar braintreeps avatar ganeshx avatar jaypatel512 avatar johnj avatar kumaravel-jayakumar avatar lathavairamani avatar lvairamani avatar prannamalai avatar siddick avatar tkanta avatar xiaoleih41 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.