Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Enabled EC Parameters support
Browse files Browse the repository at this point in the history
- Updated Api to enabled EC Parameters
- Updated Tests
- Updated Logging Manager
- Added a feature to do validation on accessors.
  • Loading branch information
japatel committed Oct 10, 2014
1 parent 4592938 commit 61a52e4
Show file tree
Hide file tree
Showing 99 changed files with 9,177 additions and 3,638 deletions.
62 changes: 49 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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](https://github.com/paypal/rest-api-sdk-python/wiki/Existing-Issues-and-Unavailable%5CUpcoming-features) for the REST APIs. (which the sdks are based on)**
> **Before starting to use the sdk, please be aware of the [existing issues and currently unavailable or upcoming features](https://github.com/paypal/rest-api-sdk-python/wiki/Existing-Issues-and-Unavailable%5CUpcoming-features) for the REST APIs. (which the sdks are based on)**
## Prerequisites

Expand All @@ -14,7 +14,7 @@ This repository contains PayPal's PHP SDK and samples for REST API.
## Installation

### - Using Composer
[**composer**](https://getcomposer.org/) is the recommended way to install the SDK. To use the SDK with project, add the following dependency to your application's composer.json and run `composer update --no-dev` to fetch the SDK.
[**composer**](https://getcomposer.org/) is the recommended way to install the SDK. To use the SDK with project, add the following dependency to your application's composer.json and run `composer update --no-dev` to fetch the SDK.

You can download composer using instructions on [Composer Official Website.](https://getcomposer.org/download/)

Expand All @@ -34,28 +34,28 @@ The resultant sample *composer.json* would look like this:
```php
{
...

"name": "sample/website",
"require": {
"paypal/rest-api-sdk-php" : "*"
}

...
}
```

### - Direct Download (without using Composer)

If you do not want to use composer, you can grab the SDK zip that contains Paypal PHP Rest API SDK with all its dependencies with it.
If you do not want to use composer, you can grab the SDK zip that contains Paypal PHP Rest API SDK with all its dependencies with it.

#### Steps to Install :
- Download zip archive with desired version from our [Releases](https://github.com/paypal/rest-api-sdk-php/releases). Each release will have a `direct-download-*.zip` that contains PHP Rest API SDK and its dependencies.

- Unzip and copy vendor directory inside your project, e.g. project root directory.

- If your application has a bootstrap/autoload file, you should add
- If your application has a bootstrap/autoload file, you should add
`include '<vendor directory location>/vendor/autoload.php'` in it. The location of the `<vendor directory>` should be replaced based on where you downloaded **vendor** directory in your application.

- This *autoload.php* file registers a custom autoloader that can autoload the PayPal SDK files, that allows you to access PHP SDK system in your application.

## Running the sample
Expand All @@ -64,11 +64,11 @@ If you do not want to use composer, you can grab the SDK zip that contains Paypa
* Samples have dependency on the sdk and you can use [`composer`](http://getcomposer.org) 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.
* Optionally, update the bootstrap.php file with your own client Id and client secret, that you could find from the [developer portal](https://developer.paypal.com)
* 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
To write an app that uses the SDK

* Update your project's composer.json file, and add dependency on PHP Rest API SDK by running `composer require paypal/rest-api-sdk-php:*` 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.
Expand All @@ -78,16 +78,16 @@ To write an app that uses the SDK
```
* Obtain your clientId and client secret from the [developer portal](https://developer.paypal.com). 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.

```php

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


$apiContext = new ApiContext(new OAuthTokenCredential('<clientId>', '<clientSecret>'));

$payment = new Payment();

$payment->setIntent("Sale");
Expand Down Expand Up @@ -117,6 +117,42 @@ There are two kinds of tests that we include in our sdk package. Unit tests, and
* It executes the tests with configuration stored in `phpunit.integration.xml` file.
* The configurations could be changed from `tests\sdk_config.ini` file.

## Developer Notes

### API Model Constructor

You can intialize the API objects by passing JSON string or Array representation of object to the constructor. E.g.:

```
$obj = new SimpleClass('{"name":"test","description":"description"}');
$obj->getName();
$obj->getDescription();
```

### Accessor Validation

We recently introduced a validation to determine if Model Object contains all the appropriate accessors (Getters and Setters) when converted from json response that we receive from Server.

This validation could be configured by updating the configuration settings in your sdk_config.ini file

Please visit our [sample sdk_config.ini](https://github.com/paypal/rest-api-sdk-php/blob/master/sample/sdk_config.ini)
```
;Validation Configuration
[validation]
; If validation is set to strict, the PPModel would make sure that
; there are proper accessors (Getters and Setters) for each model
; objects. Accepted value is
; 'log' : logs the error message to logger only (default)
; 'strict' : throws a php notice message
; 'disable' : disable the validation
validation.level=strict
```

The warning message would be logged into your PayPal.log file, for e.g.:
```
PayPal\Validation\ModelAccessorValidator: WARNING: Missing Accessor: PayPal\Api\Payment:setFirstName . Please let us know by creating an issue at https://github.com/paypal/rest-api-sdk-php/issues
```

## Contributing

* If you find solution to an [issue/improvements](https://github.com/paypal/rest-api-sdk-php/issues) in sdk that would be helpful to everyone, feel free to send us a pull request.
Expand Down
Loading

0 comments on commit 61a52e4

Please sign in to comment.