PHPackages                             paypayopa/php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. paypayopa/php-sdk

ActiveLibrary[Payment Processing](/categories/payments)

paypayopa/php-sdk
=================

PHP SDK for PayPay Open Payment API

2.0.8(3w ago)18304.2k↓48.6%17[2 issues](https://github.com/paypay/paypayopa-sdk-php/issues)[13 PRs](https://github.com/paypay/paypayopa-sdk-php/pulls)3Apache-2.0PHPPHP &gt;=7.0.0CI failing

Since Aug 12Pushed 3w ago5 watchersCompare

[ Source](https://github.com/paypay/paypayopa-sdk-php)[ Packagist](https://packagist.org/packages/paypayopa/php-sdk)[ RSS](/packages/paypayopa-php-sdk/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (12)Versions (38)Used By (3)

Paypay SDK - PHP
================

[](#paypay-sdk---php)

[![License](https://camo.githubusercontent.com/5bb925a9c188422988450e4616881174b4622e187a79f3a40f2ad42b32b334ef/68747470733a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6170616368652d6f72616e67652e737667)](https://opensource.org/licenses/Apache-2.0)[![Packagist Version](https://camo.githubusercontent.com/d1b137ac1f7c66fea84016f9ca51fa206bd24f95c7bd6f1ffc8f32dfed42e623/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061797061796f70612f7068702d73646b)](https://packagist.org/packages/paypayopa/php-sdk)[![Build Status](https://camo.githubusercontent.com/2fe6a1015a9cc2ff8bf1dcfcbba1f1d0b6c0f62b4ce32d2969bbf4260dba4de1/68747470733a2f2f7472617669732d63692e6f72672f7061797061792f7061797061796f70612d73646b2d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/paypay/paypayopa-sdk-php)[![Coverage Status](https://camo.githubusercontent.com/8991ba8e77e6841275a5b260d9a6cadd51bb0f18cbc6a42995931c4b34b248df/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7061797061792f7061797061796f70612d73646b2d7068702f62616467652e737667)](https://coveralls.io/github/paypay/paypayopa-sdk-php)[![Maintainability](https://camo.githubusercontent.com/f8c1a8a6cf3b9372ba901fa7996c9e10cb3ba6f66e54b59ec33d3cafc2cb06d3/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f37663032306164383831366463396636346636662f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/paypay/paypayopa-sdk-php/maintainability)[![Black Duck Security Risk](https://camo.githubusercontent.com/d08871cc498a54098decba80524350b6eb64427130e3ca7f4774f8bd3d18d719/68747470733a2f2f636f70696c6f742e626c61636b6475636b736f6674776172652e636f6d2f6769746875622f7265706f732f7061797061792f7061797061796f70612d73646b2d7068702f6272616e636865732f6d61737465722f62616467652d7269736b2e737667)](https://copilot.blackducksoftware.com/github/repos/paypay/paypayopa-sdk-php/branches/master)[![FOSSA Status](https://camo.githubusercontent.com/89bd3eac57b4b00a7fb97a8caa12a0a73bfb68b873d5d1041857a862d3caf202/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532467061797061792532467061797061796f70612d73646b2d7068702e7376673f747970653d736869656c64)](https://app.fossa.com/projects/git%2Bgithub.com%2Fpaypay%2Fpaypayopa-sdk-php?ref=badge_shield)[![Quality Gate Status](https://camo.githubusercontent.com/6c11c32779566ad11b6d719f687a9129dcc1954021f4765059571aa6a104c834/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7061797061795f7061797061796f70612d73646b2d706870266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=paypay_paypayopa-sdk-php)[![Packagist Downloads](https://camo.githubusercontent.com/53b11c76e1236bb6d3415e737b2d44f7bb616c262a443ba8590184cbe3a81146/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7061797061796f70612f7068702d73646b)](https://packagist.org/packages/paypayopa/php-sdk)[![Codacy Badge](https://camo.githubusercontent.com/6758d7bb2841a878bc945303c96aaa6fb674b3d39ae33691453fcf89b0dde45b/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3464393831633533346261623466383339623534393239363266376630613538)](https://app.codacy.com/gh/paypay/paypayopa-sdk-php?utm_source=github.com&utm_medium=referral&utm_content=paypay/paypayopa-sdk-php&utm_campaign=Badge_Grade_Dashboard)[![BCH compliance](https://camo.githubusercontent.com/1a8e6c83eb18eadcd218414df05f383c1c812461dfcbf44ac23a4fbc59bf7904/68747470733a2f2f626574746572636f64656875622e636f6d2f656467652f62616467652f7061797061792f7061797061796f70612d73646b2d7068703f6272616e63683d6d6173746572)](https://bettercodehub.com/)

PHP Class for interacting with the Paypay API This is the quickest way to integrate PayPay payment services, primarily meant for merchants who wish to perform interactions with the Paypay API programmatically. With PayPay's OPA SDK, you can build a custom payment checkout process to suit your unique business needs and branding guidelines.

> **Note:** This SDK is provided to assist merchants in integrating with our APIs. While it remains available for use, ongoing maintenance is limited and updates may not be released regularly. Most new features and enhancements are introduced directly at the API level, and we recommend referring to the latest API documentation for the most up-to-date capabilities.

Integrating with PayPay's Open Payment API (OPA)
------------------------------------------------

[](#integrating-with-paypays-open-payment-api-opa)

Prerequisites
-------------

[](#prerequisites)

Before integrating with the SDK, run through this checklist:

- Understand the payment flow
- Sign up for a PayPay developer/merchant account
- Generate the API keys from the Developer Panel. Use the sandbox API keys to test out the integration

Minimum required software requirements
--------------------------------------

[](#minimum-required-software-requirements)

To use the Paypay OPA PHP SDK you need:

- A server compute environment (local machines, docker containers, VPS or dedicated servers, cloud infrastructure etc. )
- A web server to serve your API responses and html documents.
- PHP version 7.x interpreter to execute your backend code.
- Composer to manage your dependencies(recommended) or a release version from this repo to manually maintain your dependencies.

HMAC Signature Verification
---------------------------

[](#hmac-signature-verification)

Signature verification is a mandatory step to ensure that the callback is sent by PayPay and the payment is received from an authentic source.

### Generate a Signature

[](#generate-a-signature)

The PayPay signature, returned to you on successful payment, can be generated by your system and verified as follows:

- Start by hashing the body and content-type with MD5 algorithm
- - Note : If there is no request body, for instance, the HTTP GET method case, no need of generating MD5. Instead hash value is set as "empty".
- The value of authHeader is passed in HttpHeader. AUTHORIZATION. The authHeader will decode back to the data added and with the HTTP request object and based on data available for api-key in the system, we will recreate the SHA256("key", requestParams) which gives macData. This macData is verified against the value passed in the header.

For the complete step-by-step explanation refer the link [here](https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#tag/Api-Authentication)

### Composer

[](#composer)

To install the bindings via [Composer](http://getcomposer.org/), run the following command in your shell :

```
composer require paypayopa/php-sdk
```

Getting Started
---------------

[](#getting-started)

You need to setup your key and secret using the following:

```
include('PATH_TO_SDK_FOLDER/Client.php');

$client = new Client([
    'API_KEY' => 'YOUR_API_KEY',
    'API_SECRET'=>'YOUR_API_SECRET',
	'MERCHANT_ID'=>'YOUR_MERCHANT_ID'
]);
```

### \[Note:\] Setter chaining in request payload classes

[](#note-setter-chaining-in-request-payload-classes)

In the examples below methods are written one after the other for the sake of your understanding. However you can save a few keystrokes by chaining multiple setter functions like so:

```
use PayPay\OpenPaymentAPI\Models\CreateQrCodePayload;
$cqcp = new CreateQrCodePayload();
$cqcp->setMerchantPaymentId('Test123')->setRequestedAt()->setCodeType();
```

Dynamic QR Code
---------------

[](#dynamic-qr-code)

### Create a dynamic QR Code to receive payments.

[](#create-a-dynamic-qr-code-to-receive-payments)

```
use PayPay\OpenPaymentAPI\Models\CreateQrCodePayload;
use PayPay\OpenPaymentAPI\Models\OrderItem;
/*
.....initialize SDK
*/
// setup payment object
$CQCPayload = new CreateQrCodePayload();

// Set merchant pay identifier
$CQCPayload->setMerchantPaymentId("YOUR_TRANSACTION_ID");

// Log time of request
$CQCPayload->setRequestedAt();
// Indicate you want QR Code
$CQCPayload->setCodeType("ORDER_QR");

// Provide order details for invoicing
$OrderItems = [];
$OrderItems[] = (new OrderItem())
    ->setName('Cake')
    ->setQuantity(1)
    ->setUnitPrice(['amount' => 20, 'currency' => 'JPY']);
$CQCPayload->setOrderItems($OrderItems);

// Save Cart totals
$amount = [
    "amount" => 1,
    "currency" => "JPY"
];
$CQCPayload->setAmount($amount);
// Configure redirects
$CQCPayload->setRedirectType('WEB_LINK');
$CQCPayload->setRedirectUrl($_SERVER['SERVER_NAME']);

// Get data for QR code
$response = $client->code->createQRCode($CQCPayload);

$data = $response['data'];
```

```
For a list of params refer to the API guide :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/createQRCode

```

### Delete a particular Dynamic QR Code

[](#delete-a-particular-dynamic-qr-code)

```
/*
....initialize SDK
*/

$response =  $client->code->deleteQRCode('ID_OF_CODE');
$data = $response['data'];
```

### Fetch a particular QR CODE payment detail

[](#fetch-a-particular-qr-code-payment-detail)

```
/*
.....initialize SDK
*/

$response =  $client->code->getPaymentDetails('MERCHANT_PAYMENT_ID');
$data = $response['data'];
```

### Cancel a payment

[](#cancel-a-payment)

```
/*
.....initialize SDK
*/

$response =  $client->code->cancelPayment('MERCHANT_PAYMENT_ID');
$data = $response['data'];
```

### Get User Authorization URL

[](#get-user-authorization-url)

```
/*
.....initialize SDK
*/

use PayPay\OpenPaymentAPI\Models\AccountLinkPayload;
$payload = new AccountLinkPayload();
$payload
    ->setScopes(["direct_debit"])
    ->setRedirectUrl("https://merchant.domain/test/callback")
    ->setReferenceId(uniqid("TEST123"));
$resp = $client->user->createAccountLinkQrCode($payload);
$url=$resp['data']['linkQRCodeURL'];
echo $url.'   ';
$nonce = $payload->getNonce();
/*
.... store nonce for later integrity checks in session or DB
*/
```

### Decode user authorization from token

[](#decode-user-authorization-from-token)

The PayPay authorization system will redirect user back to your site with a JWT token in the `responseToken` URL parameter.

```
/*
.....initialize SDK
*/
$token = $_GET['responseToken'];
$authorization = $client->user->decodeUserAuth($token);
/*
...fetch stored nonce for integrity check
*/
$userAuthorizationId = false;
if ($authorization['result']==='succeeded' && $authorization['nonce']===$fetchedNonce){
    $userAuthorizationId = $authorization['userAuthorizationId'];
}
```

### Capture payment details

[](#capture-payment-details)

```
use PayPay\OpenPaymentAPI\Models\CapturePaymentAuthPayload;
/*
.....initialize SDK
*/
// setup payment object
$CAPayload = new CapturePaymentAuthPayload();

// Use the `merchantPaymentId` from a successful invocation of the create payment authorization API.
$CAPayload->setMerchantPaymentId("YOUR_TRANSACTION_ID");

$amount = [
    "amount" => 1,
    "currency" => "JPY"
];
$CAPayload->setAmount($amount);

// Set a unique value to identify this capture.
$CAPayload->setMerchantCaptureId("MERCHANT_CAPTURE_ID");

$CAPayload->setRequestedAt();
$CAPayload->setOrderDescription("ORDER_DESCRIPTION");
$response = $client->payment->capturePaymentAuth($CAPayload);

$data = $response['data'];
```

```
For a list of params refer to the API guide :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/capturePaymentAuth

```

### Fetch a particular Direct Debit payment detail

[](#fetch-a-particular-direct-debit-payment-detail)

```
/*
.....initialize SDK
*/

$response =  $client->payment->getPaymentDetails('MERCHANT_PAYMENT_ID');
$data = $response['data'];
```

### Revert payment

[](#revert-payment)

```
use PayPay\OpenPaymentAPI\Models\RevertAuthPayload;
/*
.....initialize SDK
*/
// setup payment object
$RAPayload = new RevertAuthPayload();
$RAPayload->setMerchantRevertId("UNIQUE_REVERT_ID");
$RAPayload->setPaymentId("MERCHANT_PAYMENT_ID");
$RAPayload->setRequestedAt();
$RAPayload->setReason("REASON_FOR_REFUND");

 $response = $client->payment->revertAuth($RAPayload);
```

```
For a list of params refer to the API guide :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/revertAuth

```

### Refund payment

[](#refund-payment)

```
use PayPay\OpenPaymentAPI\Models\RefundPaymentPayload;
/*
.....initialize SDK
*/

// setup payment object
$RPPayload = new RefundPaymentPayload();
$RPPayload->setMerchantRefundId('MERCHANT_REFUND_ID');
$RPPayload->setMerchantPaymentId('MERCHANT_PAYMENT_ID');
$amount = [
    "amount" => 1,
    "currency" => "JPY"
];
$RPPayload->setAmount($amount);
$RPPayload->setRequestedAt();
$RPPayload->setReason("Refunds test");
$response = $client->refund->refundPayment($RPPayload);
$data = $response['data'];
```

```
For a list of params refer to the API guide :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/refundPayment

```

### Fetch refund status and details

[](#fetch-refund-status-and-details)

```
/*
.....initialize SDK
*/
$response=$client->refund->getRefundDetails('UNIQUE_REFUND_ID');
$data = $response['data'];
```

```
For a list of params refer to the API guide :
https://www.paypay.ne.jp/opa/doc/v1.0/dynamicqrcode#operation/getRefundDetails

```

License
-------

[](#license)

[![FOSSA Status](https://camo.githubusercontent.com/1a9566eb40d1aa069592907f1c5a3b51ef96e33346907e2973ae1357e00e2017/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532467061797061792532467061797061796f70612d73646b2d7068702e7376673f747970653d6c61726765)](https://app.fossa.com/projects/git%2Bgithub.com%2Fpaypay%2Fpaypayopa-sdk-php?ref=badge_large)

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance93

Actively maintained with recent releases

Popularity46

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~81 days

Recently: every ~371 days

Total

27

Last Release

21d ago

Major Versions

0.9.2 → 1.0.02021-01-22

1.0.5 → 2.0.02021-10-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/066e548d8e32e637a1393c01f4047f13ea588d852b7628ff99feb1a89557452a?d=identicon)[paypay](/maintainers/paypay)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (113 commits)")[![paypay-ayas](https://avatars.githubusercontent.com/u/63552995?v=4)](https://github.com/paypay-ayas "paypay-ayas (113 commits)")[![curtisfennerpaypay](https://avatars.githubusercontent.com/u/85128697?v=4)](https://github.com/curtisfennerpaypay "curtisfennerpaypay (57 commits)")[![ashraf-km](https://avatars.githubusercontent.com/u/73993781?v=4)](https://github.com/ashraf-km "ashraf-km (41 commits)")[![sunaoka](https://avatars.githubusercontent.com/u/105845?v=4)](https://github.com/sunaoka "sunaoka (19 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (18 commits)")[![javidlulu](https://avatars.githubusercontent.com/u/64267505?v=4)](https://github.com/javidlulu "javidlulu (14 commits)")[![chao-chang-paypay](https://avatars.githubusercontent.com/u/52404151?v=4)](https://github.com/chao-chang-paypay "chao-chang-paypay (6 commits)")[![ash-paypay](https://avatars.githubusercontent.com/u/117263481?v=4)](https://github.com/ash-paypay "ash-paypay (4 commits)")[![navin-math](https://avatars.githubusercontent.com/u/47411102?v=4)](https://github.com/navin-math "navin-math (4 commits)")[![sanmai](https://avatars.githubusercontent.com/u/139488?v=4)](https://github.com/sanmai "sanmai (2 commits)")[![mike-traff-paypay](https://avatars.githubusercontent.com/u/52951742?v=4)](https://github.com/mike-traff-paypay "mike-traff-paypay (1 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")[![kishore-paypay](https://avatars.githubusercontent.com/u/97159124?v=4)](https://github.com/kishore-paypay "kishore-paypay (1 commits)")

---

Tags

paypaypaypayopapaypaysdkphpqrcodeqrpaymentjapanpaypayopa

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/paypayopa-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/paypayopa-php-sdk/health.svg)](https://phpackages.com/packages/paypayopa-php-sdk)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

744284.3k34](/packages/civicrm-civicrm-core)[shetabit/multipay

PHP Payment Gateway Integration Package

293355.3k4](/packages/shetabit-multipay)[cybersource/rest-client-php

Client SDK for CyberSource REST APIs

40930.1k6](/packages/cybersource-rest-client-php)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

41352.5k4](/packages/bitpay-sdk)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4849.3k](/packages/sebdesign-laravel-viva-payments)[kilylabs/qr-payment-php

Генерация QR-кодов для оплаты на базе ГОСТ Р 56042-2014 для PHP

1318.8k](/packages/kilylabs-qr-payment-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
