定制 shopware/paypal-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

shopware/paypal-sdk

最新稳定版本:v1.6.1

Composer 安装命令:

composer require shopware/paypal-sdk

包简介

SDK to communicate with the PayPal API

README 文档

README

PayPal Logo

PayPal SDK for PHP

A PayPal PHP SDK that allows integration of PayPal services into PHP applications. This SDK provides a simple and easy-to-use interface for working with PayPal's REST APIs, making it easier to accept payments, handle PayPal-related tasks and errors.

Warning

Currently this SDK is an extraction of the implementation within Shopware's PayPal plugin. Only use cases and API responses used within the plugin are covered.

Quick start

Installation

You can install the SDK via Composer. Run the following command in your terminal:

composer require shopware/paypal-sdk

In addition, a PSR client implementation is needed. We recommend Guzzle HTTP or Symfony's HttpClient.

composer require guzzlehttp/psr7 php-http/guzzle7-adapter

The php-http/discovery package is used for this library to discover the PSR client implementation automatically. Have a look at their README to set the client implementation manually. Alternatively you can provide a gateway with a concrete client of your choice.

Usage (Simple)

use Shopware\PayPalSDK\Context\ApiContext;
use Shopware\PayPalSDK\Context\CredentialsOAuthContext;
use Shopware\PayPalSDK\Gateway\OrderGateway;
use Shopware\PayPalSDK\Struct\V2\Order;

$context = new ApiContext(
    new CredentialsOAuthContext('<clientId>', '<clientSecret>'),
    sandbox: true,
);

$orderGateway = new OrderGateway();

$toCreateOrder = new Order();
$toCreateOrder->setPaymentSource(...);
$createdOrder = $orderGateway->createOrder($toCreateOrder, $context);

$anotherOrder = $orderGateway->getOrder('<orderId>', $context);

Usage (Advanced)

use Shopware\PayPalSDK\Context\ApiContext;
use Shopware\PayPalSDK\Context\CredentialsOAuthContext;
use Shopware\PayPalSDK\Gateway\TokenGateway;
use Shopware\PayPalSDK\Gateway\OrderGateway;
use Shopware\PayPalSDK\Struct\V2\Order;

$context = new ApiContext(
    new CredentialsOAuthContext('<clientId>', '<clientSecret>'),
    sandbox: true,
    merchantId: '<merchantId>', // optional
    headers: ['some-additional-header' => 'value'], // optional
    queryParameters: ['filter' => 'value'], // optional
    thirdParty: false, // optional
)

$client = new Http\Adapter\Guzzle7\Client(new GuzzleHttp\Client([
    // some custom options like adding a logger middleware
]));

$tokenGateway = new TokenGateway($client);
$orderGateway = new OrderGateway($client, $tokenGateway);

$toCreateOrder = new Order();
$toCreateOrder->setPaymentSource(...);
$createdOrder = $orderGateway->createOrder($toCreateOrder, $context);

$anotherOrder = $orderGateway->getOrder('<orderId>', $context);

统计信息

  • 总下载量: 106.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固