<?php require_once __DIR__ . '/../../AvangateJsonrpcClient.php'; use AvangateJsonrpcClient as Client; /** * Initialize client */ Client::setBaseUrl('https://api.avangate.com/rpc/3.0/'); Client::setCredentials('APITEST', 'SECRET_KEY'); /** * Prepare call - get a non-empty product code */ $productListing = Client::searchProducts(['Limit' => 1, 'Enabled' => true, 'Types' => ['REGULAR']]); if (empty($productListing)) { die('No enabled products were found.'); } $productCode = $productListing[0]->ProductCode; if (empty($productCode)) { die('Choose a product with a valid product code'); } /** * Prepare call - prepare order object */ $order = ['Items' => [0 => ['Code' => $productCode, 'Quantity' => 1]], 'BillingDetails' => ['FirstName' => 'John', 'LastName' => 'Doe', 'Email' => '*****@*****.**', 'CountryCode' => 'RO'], 'PaymentDetails' => ['Type' => 'CC', 'Currency' => 'EUR', 'PaymentMethod' => ['CardType' => 'visa', 'CardNumber' => '4111111111111111', 'CCID' => '123', 'ExpirationMonth' => '10', 'ExpirationYear' => '2020', 'HolderName' => 'John Doe']]]; $responsePlaceOrder = Client::placeOrder($order); echo json_encode($responsePlaceOrder, JSON_PRETTY_PRINT); // output: // // { // "RefNo": "11331111", // "OrderNo": 0,