PHPackages                             winpay/core - 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. winpay/core

ActiveLibrary

winpay/core
===========

Winpay Core - Framework agnostic payment gateway library

1.0.0(yesterday)001MITPHPPHP ^8.1

Since Jun 9Pushed yesterdayCompare

[ Source](https://github.com/Winpay-Integration/core-php)[ Packagist](https://packagist.org/packages/winpay/core)[ RSS](/packages/winpay-core/feed)WikiDiscussions main Synced today

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

Winpay Core — PHP Library Framework-Agnostic
============================================

[](#winpay-core--php-library-framework-agnostic)

Library inti buat integrasi Winpay Payment Gateway. Bisa dibungkus framework apa aja (Laravel, Symfony, Yii, dll).

Requirements
------------

[](#requirements)

- PHP ^8.1
- PSR-18 (HTTP Client)
- PSR-17 (HTTP Factory)
- ext-openssl

Arsitektur
----------

[](#arsitektur)

```
WinpayClient
 ├── ConfigInterface         (credential, endpoint, kunci)
 ├── HttpClient              (SNAP: signing RSA-SHA256)
 │    └── Signer             (sign & verify pake merchant private key)
 ├── CheckoutClient          (Checkout Page: signing HMAC-SHA256)
 ├── SnapContext             (grup semua channel SNAP)
 │    ├── VirtualAccountSnap → VirtualAccountService
 │    ├── QrisSnap           → QrisService
 │    ├── EwalletSnap        → EwalletService
 │    ├── CreditCardSnap     → CreditCardService
 │    ├── RetailSnap         → RetailService
 │    ├── ReportSnap         → ReportService
 │    └── CheckoutSnap       → CheckoutService
 └── class Service           (definisi endpoint, tanpa logika HTTP)

```

### Dua Skema Auth yang Beda

[](#dua-skema-auth-yang-beda)

SkemaHeaderAlgoritmaDipake buat**SNAP**`X-TIMESTAMP`, `X-SIGNATURE`, `X-PARTNER-ID`, `X-EXTERNAL-ID`, `CHANNEL-ID`RSA-SHA256 (`openssl_sign`)VA, QRIS, eWallet, CC, Retail, Report**Checkout**`X-Winpay-Timestamp`, `X-Winpay-Signature`, `X-Winpay-Key`HMAC-SHA256 (`hash_hmac`)Checkout PageContract (buat yang mau bikin wrapper)
--------------------------------------

[](#contract-buat-yang-mau-bikin-wrapper)

Ini yang perlu diimplement biar bisa bikin wrapper framework sendiri:

### `ConfigInterface`

[](#configinterface)

```
interface ConfigInterface
{
    public function getPartnerId(): string;
    public function getMerchantPrivateKey(): string;
    public function getChannelId(): string;
    public function getBaseUrl(): string;
    public function getWinpayPublicKey(): ?string;
    public function get(string $key, mixed $default = null): mixed;
    public function set(string $key, mixed $value): void;
    public function all(): array;
}
```

Key yang dipake library:

- `partner_id`, `merchant_private_key`, `channel_id`, `base_url`, `winpay_public_key`
- `checkout_key`, `checkout_secret_key`, `checkout_base_url`
- `timeout` (default 30), `verify_ssl` (default true)

### `HttpClientInterface`

[](#httpclientinterface)

```
interface HttpClientInterface
{
    public function request(string $method, string $endpoint, ?array $body = null): WinpayResponse;
}
```

Cara Pake dari Wrapper
----------------------

[](#cara-pake-dari-wrapper)

```
use Winpay\Core\WinpayClient;

// Langsung lempar array (otomatis pake WinpayConfig)
$client = new WinpayClient([
    'partner_id'          => 'your_partner_id',
    'merchant_private_key' => '-----BEGIN PRIVATE KEY-----\n...',
    'channel_id'          => 'WEB',
    'base_url'            => 'https://sandbox-api.bmstaging.id/snap',
    'winpay_public_key'   => '-----BEGIN PUBLIC KEY-----\n...',
    'checkout_key'        => 'your_checkout_key',
    'checkout_secret_key' => 'your_checkout_secret_key',
    'checkout_base_url'   => 'https://sandbox-checkout.winpay.id',
]);

// SNAP channel (RSA-SHA256)
$client->snap()->va()->create($payload);
$client->snap()->va()->inquiry($payload);
$client->snap()->va()->status($payload);
$client->snap()->va()->delete($payload);

$client->snap()->qris()->create($payload);
$client->snap()->qris()->status($payload);
$client->snap()->qris()->cancel($payload);

$client->snap()->ewallet()->create($payload);
$client->snap()->ewallet()->status($payload);
$client->snap()->ewallet()->cancel($payload);

$client->snap()->creditCard()->create($payload);
$client->snap()->creditCard()->status($payload);
$client->snap()->creditCard()->cancel($payload);

$client->snap()->retail()->create($payload);
$client->snap()->retail()->status($payload);
$client->snap()->retail()->cancel($payload);

$client->snap()->report()->balance($payload);
$client->snap()->report()->history($payload);
$client->snap()->report()->statement($payload);

// Checkout Page (HMAC-SHA256)
$client->snap()->checkout()->create($payload);
$client->snap()->checkout()->find($id);
$client->snap()->checkout()->findByRef($merchantRef);
$client->snap()->checkout()->update($id, $payload);
$client->snap()->checkout()->delete($id);
$client->snap()->checkout()->deleteByRef($merchantRef);

// Verifikasi callback (SNAP RSA signature)
$verified = $client->verifyCallback('POST', '/callback/path', $body, $timestamp, $signature);
```

Bisa juga pake custom `ConfigInterface` dan PSR-18/PSR-17 bikinan sendiri:

```
$client = new WinpayClient(
    config: $myConfig,                        // ConfigInterface
    httpClient: $psr18Client,                 // ClientInterface
    requestFactory: $psr17RequestFactory,     // RequestFactoryInterface
    streamFactory: $psr17StreamFactory,       // StreamFactoryInterface
    onRequest: $callback,                     // ?callable (buat logging/monitoring)
    userAgent: 'my-wrapper/1.0',              // string
);
```

### Callback `onRequest`

[](#callback-onrequest)

Duluan dipanggil sebelum tiap request HTTP. Dapet method, URL, body, headers, dan string-to-sign:

```
$onRequest = function (
    string $method,
    string $url,
    ?array $body,
    array $headers,
    string $stringToSign,
): void {
    // Catet atau monitor request
};
$client = new WinpayClient(config: [...], onRequest: $onRequest);
```

Response
--------

[](#response)

Semua method service balikin `WinpayResponse`:

PropertyTypeDeskripsi`responseCode``?string`misal `"2002700"``responseMessage``?string`misal `"Successful"``httpStatusCode``int`misal `200``data``array`Full response dari server`isSuccess()``bool``true` kalo 2xx`get(key, default)``mixed`Akses data pake keyAlur Signature SNAP
-------------------

[](#alur-signature-snap)

```
hash('sha256', json_encode($body))
        ↓
strtoupper($method) . ':' . $endpoint . ':' . $hash . ':' . $timestamp
        ↓
openssl_sign($stringToSign, $signature, $privateKey, OPENSSL_ALGO_SHA256)
        ↓
base64_encode($signature) → header X-SIGNATURE

```

Alur Signature Checkout
-----------------------

[](#alur-signature-checkout)

```
hash_hmac('sha256', $timestamp, $secretKey)
        ↓
Hasilnya → header X-Winpay-Signature

```

Enum
----

[](#enum)

`VaChannel`, `VaType`, `EwalletChannel`, `RetailChannel`, `TransactionStatus` — semuanya backed string enum.

Exception
---------

[](#exception)

ExceptionKapan kepake`WinpayException`Config error, jaringan error, JSON nggak valid`HttpException`Response 4xx/5xx (extends `WinpayException`)Testing
-------

[](#testing)

```
php vendor/bin/phpunit
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

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

---

Top Contributors

[![rizkymiff](https://avatars.githubusercontent.com/u/41412734?v=4)](https://github.com/rizkymiff "rizkymiff (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/winpay-core/health.svg)

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B3.7k](/packages/guzzlehttp-psr7)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35729.6k2](/packages/telnyx-telnyx-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

84735.1k](/packages/flow-php-flow)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)

PHPackages © 2026

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