Code Monkey home page Code Monkey logo

rest-api-sdk-php's Introduction

REST API SDK for PHP

Build Status Coverage Status Latest Stable Version Total Downloads

This repository contains PayPal's PHP SDK and samples for REST API.

Before starting to use the sdk, please be aware of the existing issues and currently unavailable or upcoming features for the REST APIs. (which the sdks are based on)

Prerequisites

  • PHP 5.3 or above
  • curl, json & openssl extensions must be enabled
  • composer for fetching dependencies (See http://getcomposer.org)

Running the sample

  • Clone the repo and navigate to the samples folder.
  • Samples have dependency on the sdk and you can use Composer to get the dependencies. Ensure that you have composer installed on your machine, navigate to the samples folder and run 'composer update --no-dev' to fetch the SDK.
  • In case you cannot install composer on your machine, you can also fetch the SDK bundle from https://github.com/paypal/sdk-packages/raw/gh-pages/rest-api-sdk/php/rest-api-sdk-php-0.7.1.zip and unzip the bundle in to the samples folder.
  • Optionally, update the bootstrap.php file with your own client Id and client secret.
  • Run any of the samples in the 'samples' folder to see what the APIs can do.

Usage

To write an app that uses the SDK

  • Copy the composer.json file from the sample folder over to your project and run 'composer update --no-dev' to fetch all dependencies.
  • Copy the sample configuration file sdk_config.ini to a location of your choice and let the SDK know your config path using the following define directive.
    define('PP_CONFIG_PATH', /path/to/your/sdk_config.ini);
  • Obtain your clientId and client secret from the developer portal. You will use them to create a OAuthTokenCredential object.
  • Now you are all set to make your first API call. Create a resource object as per your need and call the relevant operation or invoke one of the static methods on your resource class.
    $apiContext = new ApiContext(new OAuthTokenCredential('<clientId>', '<clientSecret>'));
		
    $payment = new Payment();

    $payment->setIntent("Sale");

    ...

    $payment->create($apiContext);

      *OR*

    $payment = Payment::get('payment_id', $apiContext);

SDK Configuration

The samples in this repo pick the SDK configuration from the sdk_config.ini file. If you do not want to use an ini file or want to pick your configuration dynamically, you can use the $apiContext->setConfig() method to pass in the configuration as a hashmap. See the sample/bootstrap.php file for an example.

Contributing

More help

Bitdeli Badge

rest-api-sdk-php's People

Contributors

aydiv avatar ganeshx avatar prannamalai avatar avidas avatar siddick avatar lathavairamani avatar lvairamani avatar richardpq avatar brendo avatar kryogenic avatar sundbry avatar diemuzi avatar

Watchers

James Cloos avatar Andrei Avădănei avatar  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.