1. Go to this page and download the library: Download shopware/paypal-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shopware / paypal-sdk example snippets
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);
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);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.