PHPackages                             geekk/paymentwall-php - 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. [API Development](/categories/api)
4. /
5. geekk/paymentwall-php

ActiveLibrary[API Development](/categories/api)

geekk/paymentwall-php
=====================

Paymentwall PHP Library. Paymentwall is the leading digital payments platform for globally monetizing digital goods and services.

2.2.3(2y ago)011.0k↓42.9%MITPHPPHP &gt;=5.2

Since Sep 6Pushed 2y agoCompare

[ Source](https://github.com/geekk-net/paymentwall-php)[ Packagist](https://packagist.org/packages/geekk/paymentwall-php)[ Docs](https://www.paymentwall.com/?source=gh)[ RSS](/packages/geekk-paymentwall-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

About Paymentwall
=================

[](#about-paymentwall)

**IMPORTANT! It is forked from paymentwall/paymentwall-php**

[Paymentwall](http://paymentwall.com/?source=gh) is the leading digital payments platform for globally monetizing digital goods and services. Paymentwall assists game publishers, dating sites, rewards sites, SaaS companies and many other verticals to monetize their digital content and services. Merchants can plugin Paymentwall's API to accept payments from over 100 different methods including credit cards, debit cards, bank transfers, SMS/Mobile payments, prepaid cards, eWallets, landline payments and others.

To sign up for a Paymentwall Merchant Account, [click here](http://paymentwall.com/signup/merchant?source=gh).

Paymentwall PHP Library
=======================

[](#paymentwall-php-library)

This library allows developers to use [Paymentwall APIs](http://paymentwall.com/en/documentation/API-Documentation/722?source=gh) (Virtual Currency, Digital Goods featuring recurring billing, and Virtual Cart).

To use Paymentwall, all you need to do is to sign up for a Paymentwall Merchant Account so you can setup an Application designed for your site. To open your merchant account and set up an application, you can [sign up here](http://paymentwall.com/signup/merchant?source=gh).

Installation
============

[](#installation)

To install the library in your environment, you can download the [ZIP archive](https://github.com/paymentwall/paymentwall-php/archive/master.zip), unzip it and place into your project.

Alternatively, you can run:

`git clone git://github.com/paymentwall/paymentwall-php.git`

Then use a code sample below.

Code Samples
============

[](#code-samples)

Digital Goods API
-----------------

[](#digital-goods-api)

#### Initializing Paymentwall

[](#initializing-paymentwall)

Using Paymentwall PHP Library v2:

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Config::getInstance()->set(array(
    'api_type' => Paymentwall_Config::API_GOODS,
    'public_key' => 'YOUR_PUBLIC_KEY',
    'private_key' => 'YOUR_PRIVATE_KEY'
));
```

Using Paymentwall PHP Library v1 (deprecated in v2):

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
```

#### Widget Call

[](#widget-call)

[Web API details](http://www.paymentwall.com/en/documentation/Digital-Goods-API/710#paymentwall_widget_call_flexible_widget_call)

The widget is a payment page hosted by Paymentwall that embeds the entire payment flow: selecting the payment method, completing the billing details, and providing customer support via the Help section. You can redirect the users to this page or embed it via iframe. Below is an example that renders an iframe with Paymentwall Widget.

```
$widget = new Paymentwall_Widget(
	'user40012',   // id of the end-user who's making the payment
	'pw',          // widget code, e.g. pw; can be picked inside of your merchant account
	array(         // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
		new Paymentwall_Product(
			'product301',                           // id of the product in your system
			9.99,                                   // price
			'USD',                                  // currency code
			'Gold Membership',                      // product name
			Paymentwall_Product::TYPE_SUBSCRIPTION, // this is a time-based product; for one-time products, use Paymentwall_Product::TYPE_FIXED and omit the following 3 array elements
			1,                                      // duration is 1
			Paymentwall_Product::PERIOD_TYPE_MONTH, //               month
			true                                    // recurring
		)
  	),
	array('email' => 'user@hostname.com')           // additional parameters
);
echo $widget->getHtmlCode();
```

#### Pingback Processing

[](#pingback-processing)

The Pingback is a webhook notifying about a payment being made. Pingbacks are sent via HTTP/HTTPS to your servers. To process pingbacks use the following code:

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate()) {
  $productId = $pingback->getProduct()->getId();
  if ($pingback->isDeliverable()) {
  // deliver the product
  } else if ($pingback->isCancelable()) {
  // withdraw the product
  } else if ($pingback->isUnderReview()) {
  // set "pending" status to order
  }
  echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
} else {
  echo $pingback->getErrorSummary();
}
```

Virtual Currency API
--------------------

[](#virtual-currency-api)

#### Initializing Paymentwall

[](#initializing-paymentwall-1)

Using Paymentwall PHP Library v2:

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Config::getInstance()->set(array(
    'api_type' => Paymentwall_Config::API_VC,
    'public_key' => 'YOUR_PUBLIC_KEY',
    'private_key' => 'YOUR_PRIVATE_KEY'
));
```

Using Paymentwall PHP Library v1 (deprecated in v2):

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
Paymentwall_Base::setAppKey('YOUR_PUBLIC_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
```

#### Widget Call

[](#widget-call-1)

```
$widget = new Paymentwall_Widget(
	'user40012', // id of the end-user who's making the payment
	'p1_1',      // widget code, e.g. p1; can be picked inside of your merchant account
	array(),     // array of products - leave blank for Virtual Currency API
	array('email' => 'user@hostname.com') // additional parameters
);
echo $widget->getHtmlCode();
```

#### Pingback Processing

[](#pingback-processing-1)

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate()) {
  $virtualCurrency = $pingback->getVirtualCurrencyAmount();
  if ($pingback->isDeliverable()) {
  // deliver the virtual currency
  } else if ($pingback->isCancelable()) {
  // withdraw the virtual currency
  } else if ($pingback->isUnderReview()) {
  // set "pending" status to order
  }
  echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
} else {
  echo $pingback->getErrorSummary();
}
```

Cart API
--------

[](#cart-api)

#### Initializing Paymentwall

[](#initializing-paymentwall-2)

Using Paymentwall PHP Library v2:

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Config::getInstance()->set(array(
    'api_type' => Paymentwall_Config::API_CART,
    'public_key' => 'YOUR_PUBLIC_KEY',
    'private_key' => 'YOUR_PRIVATE_KEY'
));
```

Using Paymentwall PHP Library v1 (deprecated in v2):

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
```

#### Widget Call

[](#widget-call-2)

Stored products call example (when products are stored in Paymentwall):

```
$widget = new Paymentwall_Widget(
	'user40012', // id of the end-user who's making the payment
	'p1_1',      // widget code, e.g. p1; can be picked inside of your merchant account,
	array(
		new Paymentwall_Product('product301', 3.33, 'EUR'), // first product in cart
		new Paymentwall_Product('product607', 7.77, 'EUR')  // second product in cart
	),
	array('email' => 'user@hostname.com') // additional params
);
echo $widget->getHtmlCode();
```

Non-stored products call example (when products are not stored in Paymentwall):

```
$widget = new Paymentwall_Widget(
	'user40012', // id of the end-user who's making the payment
	'p1_1',      // widget code, e.g. p1; can be picked inside of your merchant account,
	array(
		new Paymentwall_Product('product301', 3.33, 'EUR', 'Product 1'), // first product in cart
		new Paymentwall_Product('product607', 7.77, 'EUR', 'Product 2')  // second product in cart
	),
	array('email' => 'user@hostname.com', 'flexible_cart_api' => 1) // additional params
);
echo $widget->getHtmlCode();
```

#### Pingback Processing

[](#pingback-processing-2)

```
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_CART);
Paymentwall_Base::setAppKey('YOUR_APPLICATION_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate()) {
  $products = $pingback->getProducts();
  if ($pingback->isDeliverable()) {
  // deliver products from the cart
  } else if ($pingback->isCancelable()) {
  // withdraw products from the cart
  } else if ($pingback->isUnderReview()) {
  // set "pending" status to order
  }
  echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
} else {
  echo $pingback->getErrorSummary();
}
```

Brick
-----

[](#brick)

#### Initializing Paymentwall

[](#initializing-paymentwall-3)

```
Paymentwall_Config::getInstance()->set(array(
	'public_key' => 'YOUR_PUBLIC_KEY',
	'private_key' => 'YOUR_PRIVATE_KEY'
));
```

#### Create a one-time token

[](#create-a-one-time-token)

```
$tokenModel = new Paymentwall_OneTimeToken();
$token =  $tokenModel->create(array(
	'public_key' => Paymentwall_Config::getInstance()->getPublicKey(),
	'card[number]' => '4242424242424242',
	'card[exp_month]' => '11',
	'card[exp_year]' => '19',
	'card[cvv]' => '123'
));
// send token to charge via $token->getToken();
```

#### Charge

[](#charge)

```
$charge = new Paymentwall_Charge();
$charge->create(array(
	// if generated via backend
	//'token' => $token->getToken(),
	// if generated via brick.js
	'token' => $_POST['brick_token'],
	'email' => $_POST['email'],
	'currency' => 'USD',
	'amount' => 10,
	'fingerprint' => $_POST['brick_fingerprint'],
	'description' => 'Order #123'
));

$response = $charge->getPublicData();

if ($charge->isSuccessful()) {
	if ($charge->isCaptured()) {
		// deliver s product
	} elseif ($charge->isUnderReview()) {
		// decide on risk charge
	}
} else {
	$errors = json_decode($response, true);
	echo $errors['error']['code'];
	echo $errors['error']['message'];
}

echo $response; // need for JS communication
```

#### Charge - refund

[](#charge---refund)

```
$charge = new Paymentwall_Charge('CHARGE_ID');
$charge->refund();

echo $charge->isRefunded();
```

#### Subscription

[](#subscription)

```
$subscription = new Paymentwall_Subscription();
$subscription->create(array(
	// if generated via backend
	//'token' => $token->getToken(),
	// if generated via brick.js
	'token' => $_POST['brick_token'],
	'email' => $_POST['email'],
	'currency' => 'USD',
	'amount' => 10,
	'fingerprint' => $_POST['brick_fingerprint'],
	'plan' => 'product_123',
	'description' => 'Order #123',
	'period' => 'week',
	'period_duration' => 2,
	// if trial, add following parameters
	'trial[amount]' => 1,
	'trial[currency]' => 'USD',
	'trial[period]'   => 'month',
	'trial[period_duration]' => 1
));

echo $subscription->getId();
```

#### Subscription - cancel

[](#subscription---cancel)

```
$subscription = new Paymentwall_Subscription('SUBSCRIPTION_ID');
$subscription->cancel();

echo $subscription->isActive();
```

### Signature calculation - Widget

[](#signature-calculation---widget)

```
$widgetSignatureModel = new Paymentwall_Signature_Widget();
echo $widgetSignatureModel->calculate(
	array(), // widget params
	2 // signature version
);
```

### Signature calculation - Pingback

[](#signature-calculation---pingback)

```
$pingbackSignatureModel = new Paymentwall_Signature_Pingback();
echo $pingbackSignatureModel->calculate(
	array(), // pingback params
	1 // signature version
);
```

Mobiamo
-------

[](#mobiamo)

#### Initializing Paymentwall

[](#initializing-paymentwall-4)

```
Paymentwall_Config::getInstance()->set(array(
	'public_key' => 'YOUR_PUBLIC_KEY',
	'private_key' => 'YOUR_PRIVATE_KEY'
));
```

#### Get a token

[](#get-a-token)

```
$model = new Paymentwall_Mobiamo();
$tokenParams = [
	'uid' => 'test'
]
$response = $model->getToken($tokenParams);
if (!empty($response['success'])) {
	//store this token and expire time (default is 86400s) to use in all next requests
	//example of success response:
		[
			'success' => 1,
			'token' => 'randomString',
			'expire_time' => 86400
		]
	var_dump($response['token']);
	var_dump($response['expire_time']);
} else {
	var_dump($response['error']);
	var_dump($response['code']);
}
```

#### Init payment

[](#init-payment)

```
$model = new Paymentwall_Mobiamo();
$initParams = [
	'uid' => 'test',
	'amount' => 1,
	'currency' => 'GBP', //currency of payment in ISO 4217 format
	'country' => 'GB', //country of payment in ISO alpha-2 format
	'product_id' => 123, //product id of payment
	'product_name' => 'test_product_name', //product name of payment
	'msisdn' => '447821677123', //optional - phone number of user in internaltional format
	'carrier' => '19', //mandatory in some countries - Given id of user's operator
	'mcc' => '262', //optional - mobile country code of user
	'mnc' => '007', //optional - mobile netword code of user
	'is_recurring' => 1, //optional and only available in some countries - value: 1/0 - determine if this payment is recurring subscription
	'period' => 'd', //mandatory if is_recurring = 1 - value: d (day) - w (week) - m (month) - period of the recurring
	'period_value' => 1 //mandatory if is_recurring = 1 - value: positive number - value of the recurring period
];
//token returned from get token step above
$response = $model->initPayment($token, $initParams);
if (!empty($response['success'])) {
	/** example of success response:
		[
			'success' => true,
			'ref' => 'w118678712', //reference id of payment.
			'flow' => 'code', //next flow of this payment. values can be: code/pinless - user send sms contain keyword to shortcode in instructions/ msisdn - user input phone number / redirect - redirect user to redirect_url in intructions
			'price' => [
				'amount' => 1,
				'currency' => 'GBP',
				'formatted' => 'GBP 1.00',
				'carriers' => [
					  0 => [
					    'id' => 19,
					    'name' => 'O2',
					  ],
					],
				],
			'instructions' => [
				'keyword' => 'test_keyword', //return if flow = code/pinless - sms message content for user to send
				'shortcode' => '123456', //return if flow = code/pinless - the number user should send message to
				'redirect_url' => 'http://google.com' //return if flow = redirect - url user should be redirected to
			]
			'product_name' => 'test_product_name',
		]
	*/
	//Store the parameter ref
} else {
	var_dump($response['error']);
	var_dump($response['code']);
}
```

#### Process payment (Use this request if previous response has flow = code/msisdn)

[](#process-payment-use-this-request-if-previous-response-has-flow--codemsisdn)

```
$model = new Paymentwall_Mobiamo();
$processParams = [
	'uid' => 'test',
	'ref' => 'w118678712', //reference id returned from init request
	'flow' => 'code', //flow returned from init request
	'data' => 'ABCDEF' //value can be: code user received after sending message / phone number of user
];
//token returned from get token step above
$response = $model->processPayment($token, $processParams);
if (!empty($response['success'])) {
	/** example of success response:
		[
			'success' => true,
			'flow' => 'redirect', //Only return if this payment requires next processing step. values can be: code - user send keyword to shortcode in instructions/ msisdn - user input phone number / redirect - redirect user to redirect_url in intructions /
			'instructions' => [
				'keyword' => 'test_keyword', //return if flow = code/pinless - sms message content for user to send
				'shortcode' => '123456', //return if flow = code/pinless - the number user should send message to
				'redirect_url' => 'http://google.com' //return if flow = redirect - url user should be redirected to
			]
		]
	*/
} else {
	var_dump($response['error']);
	var_dump($response['code']);
}
```

#### Get payment info

[](#get-payment-info)

```
$model = new Paymentwall_Mobiamo();
$getPaymentParams = [
	'uid' => 'test',
	'ref' => 'w118678712', //reference id returned from init request
];
//token returned from get token step above
$response = $model->processPayment($token, $getPaymentParams);
if (!empty($response['success'])) {
	/** example of success response:
		[
			'success' => true,
			'completed' => true, //value: true/false - indicate this payment was already successfull or not
			'amount' => 1,
			'currency' => "GBP",
			'country' => "GB",
			'product_name' => "test_product_name",
			'msisdn' => "447821677123",
			'ref' => "w118678712"
		]
	*/
} else {
	var_dump($response['error']);
	var_dump($response['code']);
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

986d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5d036db1914a24e650265fabd3566b0218090e02a210bf7fa5dc0c1023463c5?d=identicon)[geekk-net](/maintainers/geekk-net)

---

Top Contributors

[![paymentwall-dev](https://avatars.githubusercontent.com/u/5776624?v=4)](https://github.com/paymentwall-dev "paymentwall-dev (34 commits)")[![ivan-kovalyov](https://avatars.githubusercontent.com/u/5666840?v=4)](https://github.com/ivan-kovalyov "ivan-kovalyov (20 commits)")[![hdolinski](https://avatars.githubusercontent.com/u/8227024?v=4)](https://github.com/hdolinski "hdolinski (7 commits)")[![LiangNex](https://avatars.githubusercontent.com/u/15099503?v=4)](https://github.com/LiangNex "LiangNex (7 commits)")[![masonpham](https://avatars.githubusercontent.com/u/25503855?v=4)](https://github.com/masonpham "masonpham (6 commits)")[![geekk-net](https://avatars.githubusercontent.com/u/74247579?v=4)](https://github.com/geekk-net "geekk-net (3 commits)")[![petervupw](https://avatars.githubusercontent.com/u/25734037?v=4)](https://github.com/petervupw "petervupw (3 commits)")[![liufanhhh](https://avatars.githubusercontent.com/u/8143638?v=4)](https://github.com/liufanhhh "liufanhhh (3 commits)")[![delatbabel](https://avatars.githubusercontent.com/u/2335362?v=4)](https://github.com/delatbabel "delatbabel (3 commits)")[![yeexel](https://avatars.githubusercontent.com/u/2012693?v=4)](https://github.com/yeexel "yeexel (1 commits)")[![dwsVad](https://avatars.githubusercontent.com/u/5735923?v=4)](https://github.com/dwsVad "dwsVad (1 commits)")[![dzungtran](https://avatars.githubusercontent.com/u/6998801?v=4)](https://github.com/dzungtran "dzungtran (1 commits)")[![KAMAELUA](https://avatars.githubusercontent.com/u/3611515?v=4)](https://github.com/KAMAELUA "KAMAELUA (1 commits)")[![sevastyanovio](https://avatars.githubusercontent.com/u/1830504?v=4)](https://github.com/sevastyanovio "sevastyanovio (1 commits)")[![timurbakarov](https://avatars.githubusercontent.com/u/542526?v=4)](https://github.com/timurbakarov "timurbakarov (1 commits)")[![tridungpham](https://avatars.githubusercontent.com/u/621525?v=4)](https://github.com/tridungpham "tridungpham (1 commits)")[![anthonyincube8](https://avatars.githubusercontent.com/u/10609949?v=4)](https://github.com/anthonyincube8 "anthonyincube8 (1 commits)")

---

Tags

apipayment processingpaymentspaymentwallrecurring billingcredit cardscarrier billingalternative paymentsmonetization

###  Code Quality

TestsBehat

### Embed Badge

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

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

###  Alternatives

[paymentwall/paymentwall-php

Paymentwall PHP Library. Paymentwall is the leading digital payments platform for globally monetizing digital goods and services.

86797.2k5](/packages/paymentwall-paymentwall-php)[transbank/transbank-sdk

Transbank SDK

62626.4k12](/packages/transbank-transbank-sdk)[invoiced/invoiced

Invoiced PHP Library

14117.1k](/packages/invoiced-invoiced)[everypay/everypay-php

1742.0k](/packages/everypay-everypay-php)

PHPackages © 2026

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