PHP code example of univapay / univapay-sdk-migrate

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

    

univapay / univapay-sdk-migrate example snippets


// before
use Univapay\UnivapayClient;
use Univapay\Resources\Authentication\AppJWT;
use Money\Money;

$storeAppToken = AppJWT::createToken('token', 'secret');
$client = new UnivapayClient($storeAppToken);
$charge = $client->createToken($paymentMethod)->createCharge(Money::USD(1000))->awaitResult();

// after
use Univapay\Compat\UnivapayClient;
use Univapay\Compat\Resources\Authentication\AppJWT;
use Money\Money;

$storeAppToken = AppJWT::createToken('token', 'secret');
$client = new UnivapayClient($storeAppToken);
$charge = $client->createToken($paymentMethod)->createCharge(Money::USD(1000))->awaitResult();
json
{
  "version": 1,
  "exitCode": 0,
  "unsupported": [
    { "file": "src/Billing/TransferSync.php", "line": 42, "feature": "getTransfer", "verified": true }
  ],
  "internalApi": [
    { "file": "src/Http/RetryHandler.php", "line": 17, "feature": "Requests\\HttpRequester" }
  ],
  "networkException": [
    { "file": "src/Http/RetryHandler.php", "line": 29, "feature": "WpOrg\\Requests\\Exception" }
  ],
  "residualReferences": [
    { "file": "config/services.yaml", "line": 8, "text": "class: Univapay\\Resources\\Charge" }
  ],
  "deadImports": [
    { "file": "src/Legacy/Facade.php", "line": 3, "import": "Univapay\\Client" }
  ]
}