-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
44 lines (32 loc) · 1.03 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once __DIR__ . '/vendor/autoload.php';
use SytxLabs\PayPal\Enums\PayPalItemCategory;
use SytxLabs\PayPal\Models\DTO\Payee;
use SytxLabs\PayPal\Models\DTO\Product;
$config = [
'mode' => 'sandbox',
'client_id' => null,
'client_secret' => null,
'success_route' => 'http://localhost/success',
];
$paypal = new \SytxLabs\PayPal\Services\PayPalOrder($config);
$paypal->addProduct(Product::fromArray([
'name' => 'Test',
'unitPrice' => 5.0,
'quantity' => 1,
'currencyCode' => 'USD',
'description' => 'test',
'url' => 'http://localhost/product/2',
'category' => PayPalItemCategory::DIGITAL_GOODS,
'imageUrl' => null,
'upc' => null,
'payee' => new Payee('[email protected]', null, 'test'),
'shipping' => null,
]));
// $paypal->createOrder();
//
// $paypal->approveOrderRedirect();
// After approving the order, you can get the order id from the url and use it to capture the order
$paypal->getOrderFormId('8A105823UT346431A');
$paypal->captureOrder();
$paypal->getOrderStatus();