{"id":28409250,"url":"https://github.com/paymentwall/paymentwall-php","last_synced_at":"2025-06-25T00:31:20.942Z","repository":{"id":57036816,"uuid":"13505191","full_name":"paymentwall/paymentwall-php","owner":"paymentwall","description":"Paymentwall PHP Library","archived":false,"fork":false,"pushed_at":"2024-01-31T07:11:43.000Z","size":399,"stargazers_count":83,"open_issues_count":5,"forks_count":48,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-06-09T04:35:22.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://paymentwall.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paymentwall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2013-10-11T17:34:02.000Z","updated_at":"2025-02-12T11:23:28.000Z","dependencies_parsed_at":"2022-08-23T21:00:13.236Z","dependency_job_id":"58a1ae74-9466-4e5a-8c7d-9249d6d6ee35","html_url":"https://github.com/paymentwall/paymentwall-php","commit_stats":{"total_commits":126,"total_committers":26,"mean_commits":4.846153846153846,"dds":0.7698412698412699,"last_synced_commit":"040cbd3aecafe25af35568590f78b6cef4b72015"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/paymentwall/paymentwall-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paymentwall%2Fpaymentwall-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paymentwall%2Fpaymentwall-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paymentwall%2Fpaymentwall-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paymentwall%2Fpaymentwall-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paymentwall","download_url":"https://codeload.github.com/paymentwall/paymentwall-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paymentwall%2Fpaymentwall-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261782125,"owners_count":23208901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-02T06:17:56.297Z","updated_at":"2025-06-25T00:31:20.932Z","avatar_url":"https://github.com/paymentwall.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About Paymentwall\n[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. \nMerchants 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. \n\nTo sign up for a Paymentwall Merchant Account, [click here](http://paymentwall.com/signup/merchant?source=gh).\n\n# Paymentwall PHP Library\nThis 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).\n\nTo 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.\nTo open your merchant account and set up an application, you can [sign up here](http://paymentwall.com/signup/merchant?source=gh).\n\n# Installation\nTo install the library in your environment, you have several options:\n\n1. Download ZIP Archive:\n   - Download the [ZIP archive](https://github.com/paymentwall/paymentwall-php/archive/master.zip).\n   - Unzip it.\n   - Place it into your project\n\n2. Git Clone:\n   - Use the following command to clone the repository: \n   \u003ccode\u003egit clone git@github.com:paymentwall/paymentwall-php.git\u003c/code\u003e\n\n3. Composer: \n   - \u003ccode\u003ecomposer require paymentwall/paymentwall-php\u003c/code\u003e\n\nThen use a code sample below.\n\n# Code Samples \n\n## Digital Goods API\n\n#### Initializing Paymentwall\nUsing Paymentwall PHP Library:\n```php\nrequire_once('/path/to/paymentwall-php/lib/paymentwall.php');\nPaymentwall_Config::getInstance()-\u003eset([\n    'api_type' =\u003e Paymentwall_Config::API_GOODS,\n    'public_key' =\u003e 'YOUR_PROJECT_KEY',\n    'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n```\n\n#### Widget Call\n[Web API details](http://www.paymentwall.com/en/documentation/Digital-Goods-API/710#paymentwall_widget_call_flexible_widget_call)\n\nThe 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.\n\n```php\n$widget = new Paymentwall_Widget(\n\t'user40012',   // id of the end-user who's making the payment\n\t'pw',          // widget code, e.g. pw; can be picked inside of your merchant account\n\t[         // product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty\n\t\tnew Paymentwall_Product(\n\t\t\t'product301',                           // id of the product in your system\n\t\t\t9.99,                                   // price\n\t\t\t'USD',                                  // currency code\n\t\t\t'Gold Membership',                      // product name\n\t\t\tPaymentwall_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\n\t\t\t1,                                      // duration is 1\n\t\t\tPaymentwall_Product::PERIOD_TYPE_MONTH, //               month\n\t\t\ttrue                                    // recurring\n\t\t)\n  \t],\n\t['email' =\u003e 'user@hostname.com']           // additional parameters\n);\necho $widget-\u003egetHtmlCode();\n```\n\n#### Pingback Processing\n\nThe 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:\n```php\nrequire_once('/path/to/paymentwall-php/lib/paymentwall.php');\nPaymentwall_Config::getInstance()-\u003eset([\n    'api_type' =\u003e Paymentwall_Config::API_GOODS,\n    'public_key' =\u003e 'YOUR_PROJECT_KEY',\n    'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n\n$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);\nif ($pingback-\u003evalidate(true)) {\n  $productId = $pingback-\u003egetProduct()-\u003egetId();\n  if ($pingback-\u003eisDeliverable()) {\n  // deliver the product\n  } else if ($pingback-\u003eisCancelable()) {\n  // withdraw the product\n  } else if ($pingback-\u003eisUnderReview()) {\n  // set \"pending\" status to order  \n  }\n  echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent\n} else {\n  echo $pingback-\u003egetErrorSummary();\n}\n```\n\n## Virtual Currency API\n\n#### Initializing Paymentwall\nUsing Paymentwall PHP Library:\n```php\nrequire_once('/path/to/paymentwall-php/lib/paymentwall.php');\nPaymentwall_Config::getInstance()-\u003eset([\n    'api_type' =\u003e Paymentwall_Config::API_VC,\n    'public_key' =\u003e 'YOUR_PROJECT_KEY',\n    'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n```\n\n#### Widget Call\n```php\n$widget = new Paymentwall_Widget(\n\t'user40012', // id of the end-user who's making the payment\n\t'p1_1',      // widget code, e.g. p1; can be picked inside of your merchant account\n\t[],     // array of products - leave blank for Virtual Currency API\n\t['email' =\u003e 'user@hostname.com'] // additional parameters\n);\necho $widget-\u003egetHtmlCode();\n```\n\n#### Pingback Processing\n\n```php\nrequire_once('/path/to/paymentwall-php/lib/paymentwall.php');\nPaymentwall_Config::getInstance()-\u003eset([\n    'api_type' =\u003e Paymentwall_Config::API_VC,\n    'public_key' =\u003e 'YOUR_PROJECT_KEY',\n    'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n\n$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);\nif ($pingback-\u003evalidate(true)) {\n  $virtualCurrency = $pingback-\u003egetVirtualCurrencyAmount();\n  if ($pingback-\u003eisDeliverable()) {\n  // deliver the virtual currency\n  } else if ($pingback-\u003eisCancelable()) {\n  // withdraw the virtual currency\n  } else if ($pingback-\u003eisUnderReview()) {\n  // set \"pending\" status to order\n  }\n  echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent\n} else {\n  echo $pingback-\u003egetErrorSummary();\n}\n```\n\n## Cart API\n\n#### Initializing Paymentwall\nUsing Paymentwall PHP Library:\n```php\nrequire_once('/path/to/paymentwall-php/lib/paymentwall.php');\nPaymentwall_Config::getInstance()-\u003eset([\n    'api_type' =\u003e Paymentwall_Config::API_CART,\n    'public_key' =\u003e 'YOUR_PROJECT_KEY',\n    'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n```\n\n#### Widget Call\nStored products call example (when products are stored in Paymentwall):  \n```php\n$widget = new Paymentwall_Widget(\n\t'user40012', // id of the end-user who's making the payment\n\t'p1_1',      // widget code, e.g. p1; can be picked inside of your merchant account,\n\t[\n\t\tnew Paymentwall_Product('product301', 3.33, 'EUR'), // first product in cart\n\t\tnew Paymentwall_Product('product607', 7.77, 'EUR')  // second product in cart\n\t],\n\t['email' =\u003e 'user@hostname.com'] // additional params\n);\necho $widget-\u003egetHtmlCode();\n```\n\nNon-stored products call example (when products are not stored in Paymentwall):\n\n```php\n$widget = new Paymentwall_Widget(\n\t'user40012', // id of the end-user who's making the payment\n\t'p1_1',      // widget code, e.g. p1; can be picked inside of your merchant account,\n\t[\n\t\tnew Paymentwall_Product('product301', 3.33, 'EUR', 'Product 1'), // first product in cart\n\t\tnew Paymentwall_Product('product607', 7.77, 'EUR', 'Product 2')  // second product in cart\n\t],\n\t['email' =\u003e 'user@hostname.com', 'flexible_cart_api' =\u003e 1] // additional params\n);\necho $widget-\u003egetHtmlCode();\n```\n\n#### Pingback Processing\n\n```php\nrequire_once('/path/to/paymentwall-php/lib/paymentwall.php');\nPaymentwall_Config::getInstance()-\u003eset([\n    'api_type' =\u003e Paymentwall_Config::API_CART,\n    'public_key' =\u003e 'YOUR_PROJECT_KEY',\n    'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n\n$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);\nif ($pingback-\u003evalidate(true)) {\n  $products = $pingback-\u003egetProducts();\n  if ($pingback-\u003eisDeliverable()) {\n  // deliver products from the cart\n  } else if ($pingback-\u003eisCancelable()) {\n  // withdraw products from the cart\n  } else if ($pingback-\u003eisUnderReview()) {\n  // set \"pending\" status to order\n  } \n  echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent\n} else {\n  echo $pingback-\u003egetErrorSummary();\n}\n```\n\n## Brick\n\n#### Initializing Paymentwall\n```php\nPaymentwall_Config::getInstance()-\u003eset([\n\t'public_key' =\u003e 'YOUR_PUBLIC_KEY',\n\t'private_key' =\u003e 'YOUR_PRIVATE_KEY'\n]);\n```\n\n#### Create a one-time token\n```php\n$tokenModel = new Paymentwall_OneTimeToken();\n$token =  $tokenModel-\u003ecreate([\n\t'public_key' =\u003e Paymentwall_Config::getInstance()-\u003egetPublicKey(),\n\t'card[number]' =\u003e '4242424242424242',\n\t'card[exp_month]' =\u003e '11',\n\t'card[exp_year]' =\u003e '19',\n\t'card[cvv]' =\u003e '123'\n]);\n// send token to charge via $token-\u003egetToken();\n```\n\n#### Charge\n```php\n$charge = new Paymentwall_Charge();\n$charge-\u003ecreate([\n\t// if generated via backend\n\t//'token' =\u003e $token-\u003egetToken(),\n\t// if generated via brick.js\n\t'token' =\u003e $_POST['brick_token'],\n\t'email' =\u003e $_POST['email'],\n\t'currency' =\u003e 'USD',\n\t'amount' =\u003e 10,\n\t'fingerprint' =\u003e $_POST['brick_fingerprint'],\n\t'description' =\u003e 'Order #123'\n]);\n\n$response = $charge-\u003egetPublicData();\n\nif ($charge-\u003eisSuccessful()) {\n\tif ($charge-\u003eisCaptured()) {\n\t\t// deliver s product\n\t} elseif ($charge-\u003eisUnderReview()) {\n\t\t// decide on risk charge\n\t}\n} else {\n\t$errors = json_decode($response, true);\n\techo $errors['error']['code'];\n\techo $errors['error']['message'];\n}\n\necho $response; // need for JS communication\n```\n\n#### Charge - refund\n\n```php\n$charge = new Paymentwall_Charge('CHARGE_ID');\n$charge-\u003erefund();\n\necho $charge-\u003eisRefunded();\n```\n\n#### Subscription\n\n```php\n$subscription = new Paymentwall_Subscription();\n$subscription-\u003ecreate([\n\t// if generated via backend\n\t//'token' =\u003e $token-\u003egetToken(),\n\t// if generated via brick.js\n\t'token' =\u003e $_POST['brick_token'],\n\t'email' =\u003e $_POST['email'],\n\t'currency' =\u003e 'USD',\n\t'amount' =\u003e 10,\n\t'fingerprint' =\u003e $_POST['brick_fingerprint'],\n\t'plan' =\u003e 'product_123',\n\t'description' =\u003e 'Order #123',\n\t'period' =\u003e 'week',\n\t'period_duration' =\u003e 2,\n\t// if trial, add following parameters\n\t'trial[amount]' =\u003e 1,\n\t'trial[currency]' =\u003e 'USD',\n\t'trial[period]'   =\u003e 'month',\n\t'trial[period_duration]' =\u003e 1\n]);\n\necho $subscription-\u003egetId();\n```\n\n#### Subscription - cancel\n\n```php\n$subscription = new Paymentwall_Subscription('SUBSCRIPTION_ID');\n$subscription-\u003ecancel();\n\necho $subscription-\u003eisActive();\n```\n\n### Signature calculation - Widget\n\n```php\n$widgetSignatureModel = new Paymentwall_Signature_Widget();\necho $widgetSignatureModel-\u003ecalculate(\n\t[], // widget params\n\t2 // signature version\n);\n```\n\n### Signature calculation - Pingback\n\n```php\n$pingbackSignatureModel = new Paymentwall_Signature_Pingback();\necho $pingbackSignatureModel-\u003ecalculate(\n\t[], // pingback params\n\t1 // signature version\n);\n```\n\n## Mobiamo\n\n#### Initializing Paymentwall\n```php\nPaymentwall_Config::getInstance()-\u003eset([\n\t'public_key' =\u003e 'YOUR_PROJECT_KEY',\n\t'private_key' =\u003e 'YOUR_SECRET_KEY'\n]);\n```\n\n#### Get a token\n```php\n$model = new Paymentwall_Mobiamo();\n$tokenParams = [\n\t'uid' =\u003e 'test'\n]\n$response = $model-\u003egetToken($tokenParams);\nif (!empty($response['success'])) {\n\t//store this token and expire time (default is 86400s) to use in all next requests\n\t//example of success response: \n\t\t[\n\t\t\t'success' =\u003e 1, \n\t\t\t'token' =\u003e 'randomString', \n\t\t\t'expire_time' =\u003e 86400\n\t\t]\n\tvar_dump($response['token']);\n\tvar_dump($response['expire_time']);\n} else {\n\tvar_dump($response['error']);\n\tvar_dump($response['code']);\n}\n```\n\n#### Init payment\n```php\n$model = new Paymentwall_Mobiamo();\n$initParams = [\n\t'uid' =\u003e 'test', \n\t'amount' =\u003e 1, \n\t'currency' =\u003e 'GBP', //currency of payment in ISO 4217 format\n\t'country' =\u003e 'GB', //country of payment in ISO alpha-2 format\n\t'product_id' =\u003e 123, //product id of payment\n\t'product_name' =\u003e 'test_product_name', //product name of payment\n\t'msisdn' =\u003e '447821677123', //optional - phone number of user in internaltional format\n\t'carrier' =\u003e '19', //mandatory in some countries - Given id of user's operator\n\t'mcc' =\u003e '262', //optional - mobile country code of user\n\t'mnc' =\u003e '007', //optional - mobile netword code of user\n\t'is_recurring' =\u003e 1, //optional and only available in some countries - value: 1/0 - determine if this payment is recurring subscription\n\t'period' =\u003e 'd', //mandatory if is_recurring = 1 - value: d (day) - w (week) - m (month) - period of the recurring\n\t'period_value' =\u003e 1 //mandatory if is_recurring = 1 - value: positive number - value of the recurring period\n];\n//token returned from get token step above\n$response = $model-\u003einitPayment($token, $initParams);\nif (!empty($response['success'])) {\n\t/** example of success response: \n\t\t[\n\t\t\t'success' =\u003e true,\n\t\t\t'ref' =\u003e 'w118678712', //reference id of payment.\n\t\t\t'flow' =\u003e '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\n\t\t\t'price' =\u003e [\n\t\t\t\t'amount' =\u003e 1,\n\t\t\t\t'currency' =\u003e 'GBP',\n\t\t\t\t'formatted' =\u003e 'GBP 1.00',\n\t\t\t\t'carriers' =\u003e [\n\t\t\t\t\t  0 =\u003e [\n\t\t\t\t\t    'id' =\u003e 19,\n\t\t\t\t\t    'name' =\u003e 'O2',\n\t\t\t\t\t  ],\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t'instructions' =\u003e [\n\t\t\t\t'keyword' =\u003e 'test_keyword', //return if flow = code/pinless - sms message content for user to send\n\t\t\t\t'shortcode' =\u003e '123456', //return if flow = code/pinless - the number user should send message to\n\t\t\t\t'redirect_url' =\u003e 'http://google.com' //return if flow = redirect - url user should be redirected to\n\t\t\t]\n\t\t\t'product_name' =\u003e 'test_product_name',\n\t\t]\n\t*/\n\t//Store the parameter ref\n} else {\n\tvar_dump($response['error']);\n\tvar_dump($response['code']);\n}\n```\n\n#### Process payment (Use this request if previous response has flow = code/msisdn)\n```php\n$model = new Paymentwall_Mobiamo();\n$processParams = [\n\t'uid' =\u003e 'test', \n\t'ref' =\u003e 'w118678712', //reference id returned from init request \n\t'flow' =\u003e 'code', //flow returned from init request\n\t'data' =\u003e 'ABCDEF' //value can be: code user received after sending message / phone number of user\n];\n//token returned from get token step above\n$response = $model-\u003eprocessPayment($token, $processParams);\nif (!empty($response['success'])) {\n\t/** example of success response: \n\t\t[\n\t\t\t'success' =\u003e true,\n\t\t\t'flow' =\u003e '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 / \t\t\t\n\t\t\t'instructions' =\u003e [\n\t\t\t\t'keyword' =\u003e 'test_keyword', //return if flow = code/pinless - sms message content for user to send\n\t\t\t\t'shortcode' =\u003e '123456', //return if flow = code/pinless - the number user should send message to\n\t\t\t\t'redirect_url' =\u003e 'http://google.com' //return if flow = redirect - url user should be redirected to\n\t\t\t]\n\t\t]\n\t*/\n} else {\n\tvar_dump($response['error']);\n\tvar_dump($response['code']);\n}\n```\n\n#### Get payment info\n```php\n$model = new Paymentwall_Mobiamo();\n$getPaymentParams = [\n\t'uid' =\u003e 'test', \n\t'ref' =\u003e 'w118678712', //reference id returned from init request \n];\n//token returned from get token step above\n$response = $model-\u003eprocessPayment($token, $getPaymentParams);\nif (!empty($response['success'])) {\n\t/** example of success response: \n\t\t[\n\t\t\t'success' =\u003e true,\n\t\t\t'completed' =\u003e true, //value: true/false - indicate this payment was already successfull or not\n\t\t\t'amount' =\u003e 1,\n\t\t\t'currency' =\u003e \"GBP\",\n\t\t\t'country' =\u003e \"GB\",\n\t\t\t'product_name' =\u003e \"test_product_name\",\n\t\t\t'msisdn' =\u003e \"447821677123\",\n\t\t\t'ref' =\u003e \"w118678712\"\n\t\t]\n\t*/\n} else {\n\tvar_dump($response['error']);\n\tvar_dump($response['code']);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaymentwall%2Fpaymentwall-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaymentwall%2Fpaymentwall-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaymentwall%2Fpaymentwall-php/lists"}