PHP code example of pagantis / orders-api-client

1. Go to this page and download the library: Download pagantis/orders-api-client 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/ */

    

pagantis / orders-api-client example snippets


composer 



//Create a OrdersApiClient object, for example:
$ordersApiClient = new OrdersApiClient($publicKey, $privateKey);

//Example: get an existing Order status:
$order = $ordersApiClient->getOrder($pagantisOrderId); //$pmOrderId is the id of the order
if ($order instanceof Pagantis\OrdersApiClient\Model\Order) {
    $orderStatus = $order->getStatus();
    echo $orderStatus;
}

// You can investigate the rest of the methods. And find all the documentation of the API here:
// https://developer.pagantis.com/api/




//Use the API Client to operate with the API
$orderApiClient = new Pagantis\OrdersApiClient\Client(
    $publicKey,
    $privateKey
);

//Create a Refund object and set the amounts:
$refund = new Pagantis\OrdersApiClient\Model\Order\Refund();
$refund
    ->setPromotedAmount(0)
    ->setTotalAmount(10)
;

//Then use the API client to generate a the refund:
$refundCreated = $apiClient->refundOrder($orderId, $refund);



//Use the API Client to operate with the API
$orderApiClient = new Pagantis\OrdersApiClient\Client(
    $publicKey,
    $privateKey
);

$order = new \Pagantis\OrdersApiClient\Model\Order();
$order
    ->setConfiguration($configurationObject)
    ->setShoppingCart($shoppingCartObject)
    ->setUser($userObject)
    ->setMetadata($metadataObject)
;

//Notice, Create and fill with information the 4 objects

//To see the JSON result of a order Object:
echo json_encode(
  $order->export(),
  JSON_PRETTY_PRINT |
  JSON_UNESCAPED_SLASHES |
  JSON_UNESCAPED_UNICODE
);

//Finally create the order by using the client:
$orderCreated = $orderApiClient->createOrder($order);



/*
 * The Order object is defined inside the library and is prepared for OOP.
 * The attributes work with GETTERS and SETTERS
 *
 * The Response is parsed within the Client and is transformed into a Previously Defined Object with
 * useful methods.
 */




//Use the API Client to operate with the API
$orderApiClient = new Pagantis\OrdersApiClient\Client(
    $publicKey,
    $privateKey
);

//By storing the Pagantis order ID, fetch back the updated order:
$order = $orderApiClient->getOrder($orderId);




//Use the API Client to operate with the API
$orderApiClient = new Pagantis\OrdersApiClient\Client(
    $publicKey,
    $privateKey
);

//Define the queryString parameters to filter:
$queryString = [
    'channel'       => 'online',
    'pageSize'      => 2,
    'page'          => 1,
    'status'        => Order::STATUS_CONFIRMED,
    'createdFrom'   => '2018-06-28T14:08:01',
    'createdTo'     => '2018-06-28T14:08:03',
];

$orders = $orderApiClient->listOrders($queryString);




//Use the API Client to operate with the API
$orderApiClient = new Pagantis\OrdersApiClient\Client(
    $publicKey,
    $privateKey
);

$order = $orderApiClient->confirmOrder($orderId);

/** @See https://github.com/pagantis/orders-api-client **/




//Use the API Client to operate with the API
$orderApiClient = new Pagantis\OrdersApiClient\Client(
    $publicKey,
    $privateKey
);

//Create a Refund object and set the amounts:
$refund = new Pagantis\OrdersApiClient\Model\Order\Refund();
$refund
    ->setPromotedAmount(0)
    ->setTotalAmount(10)
;

//Then use the API client to generate a the refund:
$refundCreated = $apiClient->refundOrder($orderId, $refund);