<?php require_once '../../src/Client.php'; require_once '../config.php'; $result = false; $errors = false; $action_request = false; $client = new VGS_Client($SPID_CREDENTIALS); $client->auth(); if ($_POST) { $action_request = true; $errors = array(); $data = array('requestReference' => '', 'clientReference' => '', 'paymentOptions' => '', 'purchaseFlow' => '', 'sellerUserId' => '', 'tag' => ''); $data = array_filter(array_intersect_key($_POST, $data)); $items = array(array('name' => $_POST['productName'], 'price' => $_POST['productPrice'])); $data['items'] = json_encode($items); if (!empty($data['sellerUserId'])) { $data['type'] = 2; } else { $data['type'] = 4; } $hash = $client->createHash($data); $data['hash'] = $hash; try { $result = $client->api("/user/{$_POST['userId']}/charge", 'POST', $data); } catch (VGS_Client_Exception $e) { $errors = $client->container['meta'] ?: ($client->container['error'] ?: $e->getMessage()); } } else { if (!empty($_GET['action'])) { $action_request = true;
<?php session_start(); require_once '../../src/Client.php'; require_once '../config.php'; $SPID_CREDENTIALS[VGS_Client::REDIRECT_URI] = "http://{$_SERVER['HTTP_HOST']}/examples/api"; $client = new VGS_Client($SPID_CREDENTIALS); if (isset($_GET['refresh']) || !(isset($_SESSION['sdk']) && isset($_SESSION['sdk']['access_token']))) { try { $_SESSION['sdk']['access_token'] = $client->auth(); } catch (VGS_Client_Exception $e) { print_r($e); exit; } if (isset($_GET['refresh'])) { header("Location: " . $SPID_CREDENTIALS[VGS_Client::REDIRECT_URI]); exit; } } $client->setAccessToken($_SESSION['sdk']['access_token']); if (empty($_GET['offset'])) { $offset = 0; } else { $offset = $_GET['offset']; } $limit = 5; ?> <div id="top"> </div> <?php /** * /api/users