PHP code example of points-app / points-sdk

1. Go to this page and download the library: Download points-app/points-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/ */

    

points-app / points-sdk example snippets




declare(strict_types=1);

e PointsApp\Points\Enums\PaymentMethod;

$points = new Client([
    'private_key' => env('POINTS_PRIVATE_KEY'),
    'public_key'  => env('POINTS_PUBLIC_KEY'),
    'base_url'    => env('POINTS_BASE_URL', 'https://business.papp.sa'),
    'timeout'     => 30,
    'retries'     => 3,
]);

$checkoutUrl = $points->orders()->createCheckout([
    'phone_number' => '0555123456',
    'name' => 'Customer Name',
    'total_price' => 150.50,
    'order_number' => 'SHOP-1001',
    'products' => [
        [
            'product_name' => 'T-Shirt',
            'product_price' => 150.50,
            'quantity' => 1,
        ],
    ],
]);

$order = $points->orders()->authorize('550e8400-e29b-41d4-a716-446655440000');
$order = $points->orders()->capture($order->uuid);
$order = $points->orders()->complete($order->uuid, PaymentMethod::Visa);

use PointsApp\Points\Webhooks\WebhookHandler;

$handler = new WebhookHandler('your_webhook_secret');
$event = $handler->parse($rawPayload, $secretHeader, $eventHeader);