PHPackages                             nicepay/php-nicepay - 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. nicepay/php-nicepay

ActiveLibrary[Payment Processing](/categories/payments)

nicepay/php-nicepay
===================

PHP Library for Nicepay Payment API.

v1.1.2(10mo ago)036711MITPHPPHP ^7.4 || ^8.0

Since Dec 2Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/nicepay-dev/php-nicepay)[ Packagist](https://packagist.org/packages/nicepay/php-nicepay)[ RSS](/packages/nicepay-php-nicepay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (1)

PHP - NICEPAY
=============

[](#php---nicepay)

NICEPAY ❤️PHP!

This is the Official PHP API client/library for NICEPAY Payment API. Visit [PHP Library](https://github.com/nicepay-dev/java-nicepay). More information about the product and see documentation at [NICEPAY Docs](https://docs.nicepay.co.id/) for more technical details.

This library provides access to Nicepay BI SNAP and V2 APIs for backend use.

This library currently supports the following payment methods:

### SNAP Version:

[](#snap-version)

- **Snap**
    - Get Access Token
- **Virtual Account**:
    - Generate Virtual Account
    - Inquiry Status
    - Cancel
- **Ewallet**:
    - Payment
    - Inquiry Status
    - Refund
- **QRIS**:
    - Generate QRIS
    - Inquiry Status
    - Refund
- **Payout**:
    - Registration
    - Approve
    - Inquiry Status
    - Check Balance
    - Cancel
    - Reject

### V2 Version:

[](#v2-version)

- **Virtual Account, Convenience Store, Payloan, Qris**:
    - Registration
    - Inquiry Status
    - Cancel
- **Debit/Credit Card, E-Wallet**
    - Registration
    - Inquiry Status
    - Cancel
    - Payment
- **Payout**
    - Registration
    - Approve
    - Inquiry Status
    - Check Balance
    - Cancel
    - Reject

### Additional Function

[](#additional-function)

- **Helper**
    - Verify Signature Sha256

1. Installation
---------------

[](#1-installation)

### 1.1 Manual Install

[](#11-manual-install)

You can clone or [download](https://github.com/nicepay-dev/nativephp-nicepay) our source code, then import the folder manually into your project.

### 1.2 Manual Install with Github link

[](#12-manual-install-with-github-link)

Add the repository details on your project composer.json

```
{
  "require": {
        "nicepay/nicepay-php": "dev-master"
    },
  "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/nicepay-dev/php-nicepay"
        }
    ],
}
```

Run **composer install** if it’s your first time or **composer update nicepay/nicepay-php** to update that specific package.

### 1.2 Install with Composer

[](#12-install-with-composer)

If you are using [Composer](https://getcomposer.org), install the library via the Composer CLI:

```
composer require nicepay/php-nicepay
```

This will download and install the package, along with its dependencies, into your project. Make sure Composer is properly set up before running this command.

2. Usage
--------

[](#2-usage)

### 2.1 Client Initialization and Configuration

[](#21-client-initialization-and-configuration)

Get your Credentials from [Nicepay Dashboard](https://bo.nicepay.co.id/)Initialize Nicepay Config

> **WARNING:** Credentials used here are for testing purposes only.

```
$timestamp = Helper::getFormattedDate();

$config = NICEPay::builder()
            ->setIsProduction(false) //
            ->setPrivateKey('MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAInJe1G22R2fMchIE6BjtYRqyMj6lurP/zq6vy79WaiGKt0Fxs4q3Ab4ifmOXd97ynS5f0JRfIqakXDcV/e2rx9bFdsS2HORY7o5At7D5E3tkyNM9smI/7dk8d3O0fyeZyrmPMySghzgkR3oMEDW1TCD5q63Hh/oq0LKZ/4Jjcb9AgMBAAECgYA4Boz2NPsjaE+9uFECrohoR2NNFVe4Msr8/mIuoSWLuMJFDMxBmHvO+dBggNr6vEMeIy7zsF6LnT32PiImv0mFRY5fRD5iLAAlIdh8ux9NXDIHgyera/PW4nyMaz2uC67MRm7uhCTKfDAJK7LXqrNVDlIBFdweH5uzmrPBn77foQJBAMPCnCzR9vIfqbk7gQaA0hVnXL3qBQPMmHaeIk0BMAfXTVq37PUfryo+80XXgEP1mN/e7f10GDUPFiVw6Wfwz38CQQC0L+xoxraftGnwFcVN1cK/MwqGS+DYNXnddo7Hu3+RShUjCz5E5NzVWH5yHu0E0Zt3sdYD2t7u7HSr9wn96OeDAkEApzB6eb0JD1kDd3PeilNTGXyhtIE9rzT5sbT0zpeJEelL44LaGa/pxkblNm0K2v/ShMC8uY6Bbi9oVqnMbj04uQJAJDIgTmfkla5bPZRR/zG6nkf1jEa/0w7i/R7szaiXlqsIFfMTPimvRtgxBmG6ASbOETxTHpEgCWTMhyLoCe54WwJATmPDSXk4APUQNvX5rr5OSfGWEOo67cKBvp5Wst+tpvc6AbIJeiRFlKF4fXYTb6HtiuulgwQNePuvlzlt2Q8hqQ==')
            ->setClientSecret('33F49GnCMS1mFYlGXisbUDzVf2ATWCl9k3R++d5hDd3Frmuos/XLx8XhXpe+LDYAbpGKZYSwtlyyLOtS/8aD7A==')
            ->setPartnerId('IONPAYTEST')
            ->setExternalID("randUniqueId1234")
            ->setTimestamp($timestamp)
            ->isRetryFlag(true) // default false
            ->setRetryCount(4) // default 1
            ->build();
```

### 2.2 Featured services

[](#22-featured-services)

### 2.2.1 Snap Version

[](#221-snap-version)

Snap is Nicepay existing tool to help merchant charge customers using a mobile-friendly, in-page, no-redirect checkout facilities. [Using snap is simple](https://docs.Nicepay.com/en/snap/overview).

Available methods for Snap

#### 2.2.1.1 Get Access Token

[](#2211-get-access-token)

```
        $tokenBody = AccessToken::builder()
            ->setGrantType('client_credentials')
            ->setAdditionalInfo([])
            ->build();

        $snap = new Snap($config); // check 2.1 to set up $config

        try {
            $response = $snap->requestSnapAccessToken($tokenBody);

            // Get access token
            $accessToken = $response->getAccessToken();

        } catch (NicepayError $e) {
            $this->fail("Exception thrown: " . $e->getMessage());
        }
```

#### 2.2.1.2 Generate VA

[](#2212-generate-va)

```
$parameter = VirtualAccount::builder()
            ->setPartnerServiceId("")
            ->setCustomerNo("")
            ->setVirtualAccountNo("")
            ->setVirtualAccountName("Nicepay PHP Test")
            ->setTrxId("ordNo" . $timestamp)
            ->setTotalAmount('10000.00', 'IDR')
            ->setAdditionalInfo([
                'bankCd' => 'BMRI',
                'goodsNm' => 'Test',
                'dbProcessUrl' => 'https://nicepay.co.id/',
            ])
            ->build();

        $accessToken = ""; // Check 2.2.1.1 for step to get access token
        $snapVAService = new SnapVAService($config);

        try {
        $response = $snapVAService->generateVA($parameter, $accessToken);
        } catch (NicepayError $e) {
            $this->fail("Exception thrown: " . $e->getMessage());
        }
```

### 2.2.2 Non-Snap Version (V2)

[](#222-non-snap-version-v2)

#### 2.2.2.1 Generate VA

[](#2221-generate-va)

```
$timestamp = Helper::getFormattedTimestampV2();

        $config = NICEPay::builder()
            ->setIsProduction(false)
            ->setRetryFlag(true)
            ->setRetryCount(4)
            ->build();

        $reffNo = "ordNo".$timestamp;
        $amount = "100";
        $virtualAccountBuilder = VirtualAccount::builder();

        // For Merchant token setter the args is (TIMESTAMP, IMID, REFFNO, AMOUNT, MERCHANT_KEY)
        $parameter = $virtualAccountBuilder
            ->setTimeStamp($timestamp)
            ->setIMid("IONPAYTEST")
            ->setPayMethod("02")
            ->setCurrency("IDR")
            ->setBankCd("CENA")
            ->setAmt("100")
            ->setReferenceNo($reffNo)
            ->setMerchantToken($timestamp, "IONPAYTEST", $reffNo, $amount, "")
            ->setVacctValidDt("20251004")
            ->setVacctValidTm("101010")
            ->setMerFixAcctId("")
            ->setDbProcessUrl("https://webhook.site/7c2d47f6-557b-4b85-b91a-ad3b6182b10c")
            ->setGoodsNm("Test VA V2 PHP")
            ->setCartData("{}")
            ->setBillingNm("Nicepay php native")
            ->setBillingPhone("081534567890")
            ->setBillingEmail("nicepay@example.com")
            ->setBillingAddr("Jln. Raya Kasablanka Kav.88")
            ->setBillingCity("South Jakarta")
            ->setBillingState("DKI Jakarta")
            ->setBillingPostCd("15119")
            ->setBillingCountry("Indonesia")
            ->build();

        $v2VaService = new V2VAService($config);

        try {
        $response = $v2VaService->registration($parameter);

        } catch (NicepayError $e) {
            $this->assertTrue(true, "Exmessage: ception thrown: " . $e->getMessage());
        }
```

#### 2.2.2.2 Payment Card

[](#2222-payment-card)

```
        $config = NICEPay::builder()
            ->setIsProduction(false) // Dev
            ->build();

        $parameter = Card::builder()
        ->timeStamp($timestamp)
        ->iMid($iMid)
        ->tXid($tXid) // tXid transaction to do payment process
        ->referenceNo($referenceNo)
        ->merchantToken($timestamp, $iMid, $referenceNo, $amount, $merchantKey)
        ->cardNo(TestConst::$CARD_NO) // CARD DATA
        ->cardExpYymm(TestConst::$CARD_EXP_YYMM) // CARD DATA
        ->cardCvv(TestConst::$CARD_CVV) // CARD DATA
        ->cardHolderNm("Nicepay test")
        ->callBackUrl("https://x.com")
        ->build();

        try {

            $cardService = new V2CardService($config);
            $response = $cardService->payment($parameter);

        } catch (Exception $exception) {

        }
```

The response will contain the HTML content, which should be rendered and processed on your front-end for the 3DS (3D Secure) flow.

Sample HTML Response for 3DS Flow

Here’s an example of the HTML response your front-end should handle. It contains an iframe for 3DS authentication, with the form automatically submitting to the 3DS method URL.

```

		body {min-width: 100%; height: auto; min-height: 500px; overflow: none; border: none; background: url("/nicepay/images/rotate.gif") no-repeat center;

			       var e=document.getElementById("initiate3dsSimpleRedirectForm"); if (e) { e.submit(); if (e.parentNode !== null) { e.parentNode.removeChild(e); } }

		function getBrowserInfo() {
			document.mpgsAuthFrm.browser.value = navigator.userAgent;
			document.mpgsAuthFrm.browserJavaEnabled.value = window.navigator.javaEnabled() === true ? 'true' : 'false';
			document.mpgsAuthFrm.browserJavascriptEnabled.value = "1";
			document.mpgsAuthFrm.browserLanguage.value = navigator.language;
			document.mpgsAuthFrm.browserScreenColorDepth.value = screen.colorDepth;
			document.mpgsAuthFrm.browserScreenHeight.value = screen.height;
			document.mpgsAuthFrm.browserScreenWidth.value = screen.width;
			document.mpgsAuthFrm.browserTimeZone.value = new Date().getTimezoneOffset();
			document.mpgsAuthFrm.submit();
		}

```

##### Front-End Integration

[](#front-end-integration)

1. When the front-end receives the responseHtml, render it as an HTML page.
2. The page will automatically post to the 3DS method URL, redirecting the user to a page where they can enter the OTP sent to their registered device.
3. After completing the 3DS flow, the user is redirected back to your callback URL.

Expected Result :

Once the user completes the 3DS authentication, they will be redirected to your defined callbackUrl, where you can process the result.

### 2.2.3 Additional Function

[](#223-additional-function)

#### Verify Signature Sha256

[](#verify-signature-sha256)

import :

```
use Nicepay\utils\Helper;
```

Code :

```
$signatureString = "VoxMPjbcV9pro4YyHGQgoRj4rDVJgYk2Ecxn+95B90w47Wnabtco35BfhGpR7a5RukUNnAdeOEBNczSFk4B9uYyu3jc+ceX+Dvz5OYSgSnw5CiMHtGiVnTAqCM/yHZ2MRpIEqekBc4BWMLVtexSWp0YEJjLyo9dZPrSkSbyLVuD7jkUbvmEpVdvK0uK15xb8jueCcDA6LYVXHkq/OMggS1/5mrLNriBhCGLuR7M7hBUJbhpOXSJJEy7XyfItTBA+3MRC2FLcvUpMDrn/wz1uH1+b9A6FP7mG0bRSBOm2BTLyf+xJR5+cdd88RhF70tNQdQxhqr4okVo3IFqlCz2FFg==";
$dataString = "TNICEVA023|2024-08-19T17:12:40+07:00";
$publicKeyString = TestConst::$PUBLIC_KEY;

$isVerify = Helper::verifySHA256RSA($dataString, $publicKeyString, $signatureString);
```

3. Examples
-----------

[](#3-examples)

Integration test are available

- [Virtual Account Sample Functional Test](test/NicepayVirtualAccountTest.php)
- [E-Wallet Sample Functional Test](test/NicepayEwalletTest.php)
- [QRIS Sample Functional Test](test/NicepayQrisTest.php)
- [Payout Sample Functional Test](test/NicepayPayoutTest.php)
- [Card Sample Functional Test](test/NicepayCardTest.php)
- [Convenience Store Sample Functional Test](test/NicepayCVSTest.php)
- [Inquiry Status Sample Functional Test](test/NicepayInquiryStatusTest.php)
- [Cancel / Refund Sample Functional Test](test/NicepayCancelTest.php)

Running in Local Development
----------------------------

[](#running-in-local-development)

To run the library in a local environment, follow these steps:

1. Create a `.env` file in your project root: ```
    APP_ENV=local
    ```
2. Load the .env file at the start of your project (e.g., in index.php):

```
use Nicepay\utils\EnvLoader;

EnvLoader::load(__DIR__ . '/.env');
```

3. Verify the environment variable is set:

```
if (getenv('APP_ENV') === 'local') {
    echo "Running in local environment";
}
```

**By default, if no .env file is loaded, the library will assume it is running in a production environment.**

Get help
--------

[](#get-help)

- [Nicepay Docs](https://docs.nicepay.co.id/)
- [Nicepay Dashboard ](https://bo.nicepay.co.id/)
- [SNAP documentation](http://snap-docs.Nicepay.com)
- Can't find answer you looking for? email to

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance53

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

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 ~70 days

Total

4

Last Release

323d ago

PHP version history (2 changes)v1.0.0PHP ^8.3

v1.1.2PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d059f8f033fa21e1a70ac37cda8f9f02587419f95136babbcaad95580c0d7f82?d=identicon)[nicepayintegration](/maintainers/nicepayintegration)

---

Top Contributors

[![iFazarillah](https://avatars.githubusercontent.com/u/102897548?v=4)](https://github.com/iFazarillah "iFazarillah (16 commits)")[![AbuDhafir](https://avatars.githubusercontent.com/u/107015141?v=4)](https://github.com/AbuDhafir "AbuDhafir (3 commits)")[![SonnyImmanuelHutabarat](https://avatars.githubusercontent.com/u/209723092?v=4)](https://github.com/SonnyImmanuelHutabarat "SonnyImmanuelHutabarat (3 commits)")[![aryaadhm](https://avatars.githubusercontent.com/u/124257972?v=4)](https://github.com/aryaadhm "aryaadhm (1 commits)")[![nicepay-dev](https://avatars.githubusercontent.com/u/64513674?v=4)](https://github.com/nicepay-dev "nicepay-dev (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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