Looking to hire Laravel developers? Try LaraJobs

laravel-paypayopa-sdk-php maintained by sunaoka

Description
PayPay's Open Payment API Service Provider for Laravel
Author
Last update
2026/06/22 02:46 (dev-develop)
License
Links
Downloads
150
Tags

Comments
comments powered by Disqus

PayPay's Open Payment API Service Provider for Laravel

Latest Stable Version License PHP from Packagist Laravel Test codecov


Installation

composer require sunaoka/laravel-paypayopa-sdk-php

Configurations

php artisan vendor:publish --tag=paypay-config

The settings can be found in the generated config/paypay.php configuration file.

<?php

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),
];

Usage

use PayPay\OpenPaymentAPI\Models\CreateQrCodePayload;

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

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

Testing

You may use the PayPay facade's fake method to apply the mock handler.

For more information on mock handlers, please refer to the Testing Guzzle Clients.

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);