PHPackages                             hieudmg/payway-api-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. hieudmg/payway-api-sdk

ActiveLibrary[Payment Processing](/categories/payments)

hieudmg/payway-api-sdk
======================

Payway api sdk

01PHP

Since Oct 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/hieudmg/Payway-PHP-sdk)[ Packagist](https://packagist.org/packages/hieudmg/payway-api-sdk)[ RSS](/packages/hieudmg-payway-api-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Payway PHP API wrapper
======================

[](#payway-php-api-wrapper)

Disclaimer
----------

[](#disclaimer)

This is base package I use for developing Payway payment plugin. It might be clumsy in there, but it just got the job done. If you have any suggestion, please open an issue.

Usage
-----

[](#usage)

You cannot use this package out of the box immediately. You must implement some function in order to make it work. That provide flexibility and framework-compatibility.

### Implement the abstract functions

[](#implement-the-abstract-functions)

You need to inherit AbstractPaywayApiWrapper class to use it. There are currently three functions need to be implemented:

```
protected abstract function getStoreUid();
protected abstract function getMerchantInformation();
protected abstract function makeRequest($url, $method, $idempotencyKey = '', $data = null, $additionalHeaders = null);
```

- `getStoreUid`: This function is used to get saved store unique identifier in your framework. Customer-related functionality needs this identifier to make saved customer in payway unique for each store. Think of using the plugin in two store with same merchant credentials, without this identifier a customer with id 11 can be missused by the other stores and cause confusion.
- `getMerchantInformation`: This function returns merchant information saved in the framework's database. It needs to return `PaywaySDK\Data\MerchantInformation` type.
- `makeRequest`: This function doing the request using the framework's implementation. Each framework requires a different way to make outbound requests. E.g: Magento 2 uses `Magento\Framework\HTTP\Client\Curl`, Wordpress uses `wp_remote_request`. The function must return an array - the decoded JSON response from Payway gateway. Don't forget to add necessary API headers and add idempotency key in response. An example of Wordpress implementation with retry on failure:

```
protected function makeRequest( $url, $method, $idempotencyKey = '', $data = null, $additionalHeaders = null ) {
    if ( ! is_array( $additionalHeaders ) ) {
        $additionalHeaders = [];
    }
    $headers = array_merge( $additionalHeaders, array(
        'Idempotency-Key' => $idempotencyKey,
        'Authorization'   => 'Basic ' . base64_encode( $this->getMerchantInformation()->getPrivateKey() ),
        'Content-Type'    => 'application/x-www-form-urlencoded'
    ) );

    if ( $method == METHOD_GET ) {
        $data = null;
    } elseif ( is_array( $data ) ) {
        $data = http_build_query( $data );
    } elseif ( ! is_string( $data ) ) {
        $data = null;
    }

    $result = array();

    for ( $retries = 0; $retries < 4; $retries ++ ) {
        if ( $retries > 0 ) {
            sleep( 20 );
        }

        $result = wp_remote_request( $url, array(
            'method'  => $method,
            'headers' => $headers,
            'body'    => $data,
            'timeout' => 5
        ) );

        if ( $result instanceof WP_Error ) {
            continue;
        } elseif ( $result['response']['code'] == 429 || $result['response']['code'] == 503 ) {
            continue;
        } elseif ( $result['response']['code'] > 200 && $result['response']['code'] < 299 || $result['response']['code'] == 422 ) {
            $result                   = json_decode( $result['body'], 1 );
            $result['idempotencyKey'] = $idempotencyKey;
            break;
        } else {
            unset( $result['cookies'] );
            unset( $result['http_response'] );
            break;
        }
    }

    return $result;
}
```

### Using the wrapper

[](#using-the-wrapper)

After implement abstract functions, you can use it. Example usage:

```
$api = new PaywayApiWrapper();
/** @var \PaywaySDK\Response\TransactionResponse $paymentResult */
$paymentResult = $api->takePayment( $paywayToken, $customerId, $orderTotal, $customerIpAddress );
if ($paymentResult && $paymentResult->isSuccess()) {
    // Process order here
} else {
    // Something went wrong, handle error here
}
```

Contribution
------------

[](#contribution)

If you found any problem and/or have idea of improvement, please open an issue.

Support me
----------

[](#support-me)

[![Buy Me A Coffee](https://camo.githubusercontent.com/453c655ef274c7b8e0a588d3625323361bc55b359f917f6c4d18cd850dd1fc70/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d76696f6c65742e706e67)](https://www.buymeacoffee.com/hieudmg)

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/31652bd8037c3d92f0ce39b33c7b4ab9d6a009148b3ea4a57e0662fa8d07c909?d=identicon)[hieudmg](/maintainers/hieudmg)

---

Top Contributors

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

---

Tags

paymentpaywayphp

### Embed Badge

![Health badge](/badges/hieudmg-payway-api-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/hieudmg-payway-api-sdk/health.svg)](https://phpackages.com/packages/hieudmg-payway-api-sdk)
```

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