承接 kurilovvo/rest-api-sdk-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kurilovvo/rest-api-sdk-php

Composer 安装命令:

composer require kurilovvo/rest-api-sdk-php

包简介

PayPal's PHP SDK for REST APIs

README 文档

README

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

Installation

- Using Composer

composer 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.

Prerequisites

Steps to Install :

Currently, Paypal PHP Rest API SDK is available at https://packagist.org. To use it in your project, you need to include it as a dependency in your project composer.json file. It can be done in two ways :

  • Running composer require paypal/rest-api-sdk-php:* command on your project root location (where project composer.json is located.)

  • Or, manually editing composer.json file require field, and adding "paypal\rest-api-sdk-php" : "*" inside it.

The resultant sample composer.json would look like this:

{
  ...

  "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.

Steps to Install :

  • Download zip archive with desired version from our 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 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

  • 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 root 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
  • 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

  • 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.
    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.
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");

    ...

    $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.

Testing

There are two kinds of tests that we include in our sdk package. Unit tests, and Integration Tests.

  • Unit Tests
    • Unit tests can be executed by running this command phpunit at Paypal SDK root location.
    • It executes the tests with configuration stored in phpunit.xml file.
  • Integration Tests
    • Integration tests make curl requests to sandbox environments by default. It would test both unit as well as integration tests. To execute, run this command phpunit -c phpunit.integration.xml at Paypal SDK root location.
    • 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

;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 in sdk that would be helpful to everyone, feel free to send us a pull request.
  • The ideal approach to create a fix would be to fork the repository, create a branch in your repository, and make a pull request out of it.
  • It is desirable if there is enough comments/documentation and Tests included in the pull request.
  • For general idea of contribution, please follow the guidelines mentioned here.

More help

kurilovvo/rest-api-sdk-php 适用场景与选型建议

kurilovvo/rest-api-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 152 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rest」 「payments」 「sdk」 「paypal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kurilovvo/rest-api-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kurilovvo/rest-api-sdk-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 kurilovvo/rest-api-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 152
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1156
  • 开发语言: PHP

其他信息

  • 授权协议: Apache2
  • 更新时间: 2023-09-29