1. Go to this page and download the library: Download yopay/yopay-php 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/ */
yopay / yopay-php example snippets
use YoPay\Client;
use YoPay\Config;
use YoPay\Dto\OrderRequest;
use YoPay\Dto\Payer;
$client = new Client(new Config(
baseUrl: 'https://pay.example.com',
mchId: getenv('YOPAY_MCH_ID'),
secretKey: getenv('YOPAY_SECRET_KEY'),
platformPublicKey: getenv('YOPAY_PLATFORM_PUBLIC_KEY'),
merchantPrivateKey: getenv('YOPAY_MERCHANT_PRIVATE_KEY'),
));
$response = $client->order(new OrderRequest(
merchantOrderNo: 'MO-202607130001',
amount: '20.000',
currencyCode: 'USD',
scene: 'qr',
payer: new Payer(
merchantUserId: 'payer-10001',
accountType: 3,
accountNo: 'openid-10001',
),
notifyUrl: getenv('YOPAY_NOTIFY_URL') ?: null,
));
echo $response->tradeNo;