GithubHelp home page GithubHelp logo

adaptiveaccounts-sdk-php's Introduction

PayPal PHP Adaptive Accounts SDK

Prerequisites

PayPal's PHP Adaptive Accounts SDK requires

  • PHP 5.2 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) or by running a custom installation script provided with the SDK.

If using composer, run composer update from the samples folder. Otherwise, run install.php from adaptiveaccounts-sdk-php/samples directory

   
    cd samples   
    curl  https://raw.github.com/paypal/adaptiveaccounts-sdk-php/stable/samples/install.php | php    
        OR        
    php install.php

Using the SDK

To use the SDK,

  • Create a composer.json file with the following contents.
{
    "name": "me/shopping-cart-app",
    "require": {
        "paypal/adaptiveaccounts-sdk-php":"v2.4.101"
    }
}
  • Install the SDK as a dependency using composer or the install.php script.
  • Require vendor/autoload.php OR PPBootStrap.php in your application depending on whether you used composer or the custom installer.
  • Choose how you would like to configure the SDK - You can either
    • Create a sdk_config.ini file and set the PP_CONFIG_PATH constant to point to the directory where this file exists OR
    • Create a hashmap containing configuration parameters and pass it to the service object.
  • 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 and registers the classloader
    require("PPBootStrap.php");

  	$createAccountRequest = new CreateAccountRequest($requestEnvelope, $name, $address, $preferredLanguageCode);
	$createAccountRequest->accountType = $accountType;
	......

	$service  = new AdaptiveAccountsService();
	$response = $service->CreateAccount($createAccountRequest);	 
	if($strtoupper($response->responseEnvelope->ack) == 'SUCCESS') {
		// Success
	}

Authentication

The SDK provides multiple ways to authenticate your API call.

	$service  = new AdaptiveAccountsService();
	
	// Use the default account (the first account) configured in sdk_config.ini
	$response = $service->CreateAccount($createAccountRequest);	

	// Use a specific account configured in sdk_config.inig
	$response = $service->CreateAccount($createAccountRequest, '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 = $service->CreateAccount($createAccountRequest, $cred);	

SDK Configuration

The SDK allows you to configure the following parameters

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

You can configure the SDK via the sdk_config.ini file.

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

Alternatively, 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 AdaptiveAccountsService($config);

Please refer to the sample config file provided with this bundle.

Instant Payment Notification (IPN)

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

Links

adaptiveaccounts-sdk-php's People

Contributors

aydiv avatar ganeshx avatar johnj avatar kumaravel-jayakumar avatar lathavairamani avatar lvairamani avatar siddick avatar tkanta avatar

Watchers

 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.