PHP code example of sunaoka / laravel-paypayopa-sdk-php

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

    

sunaoka / laravel-paypayopa-sdk-php example snippets




return [
    'api_key' => env('PAYPAY_API_KEY'),
    'api_secret' => env('PAYPAY_API_SECRET'),
    'merchant_id' => env('PAYPAY_MERCHANT_ID'),
    'production_mode' => (bool) env('PAYPAY_PRODUCTION_MODE', false),
];

use PayPay\OpenPaymentAPI\Models\CreateQrCodePayload;

$payload = new CreateQrCodePayload();
$payload->setMerchantPaymentId('merchant_id');
$payload->setCodeType('ORDER_QR');

$response = \PayPay::code()->createQRCode($payload);

use GuzzleHttp\Psr7\Response;
use PayPay\OpenPaymentAPI\Models\CreateQrCodePayload;

$fakeResponse = [
    'resultInfo' => [
        'code' => 'SUCCESS',
        'message' => 'Success',
        'codeId' => '08100001',
    ],
    'data' => [
        'codeId' => '04-ABCDEFGHIJKLMNOP',
        'url' => 'https://example.com/00000000ABCDEFGHIJKLMNOP',
        'expiryDate' => 1719965100,
        'merchantPaymentId' => 'Merchant Payment ID',
        'amount' => [
            'amount' => 1000,
            'currency' => 'JPY',
        ],
        'orderDescription' => 'Description',
        'orderItems' => [[
            'name' => 'Item Name',
            'quantity' => 1000,
            'unit_price' => [
                'amount' => 1,
                'currency' => 'JPY',
            ],
        ]],
        'codeType' => 'ORDER_QR',
        'requestedAt' => 1719964800,
        'redirectType' => 'WEB_LINK',
        'isAuthorization' => false,
        'deeplink' => 'paypay://payment?link_key=https%3A%2F%2Fexample.com%2F00000000ABCDEFGHIJKLMNOP',
    ],
];

\PayPay::fake([
    new Response(201, body: json_encode($fakeResponse, JSON_THROW_ON_ERROR)),
]);

$payload = new CreateQrCodePayload();
$payload->setMerchantPaymentId('merchant_id');
$payload->setCodeType('ORDER_QR');

$response = \PayPay::code()->createQRCode($payload);
bash
php artisan vendor:publish --tag=paypay-config