1. Go to this page and download the library: Download paymentwall/paymentwall-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$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
[ // 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
)
],
['email' => '[email protected]'] // additional parameters
);
echo $widget->getHtmlCode();
Paymentwall_Config::getInstance()->set([
'api_type' => Paymentwall_Config::API_GOODS,
'public_key' => 'YOUR_PROJECT_KEY',
'private_key' => 'YOUR_SECRET_KEY'
]);
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate(true)) {
$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();
}
$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 of products - leave blank for Virtual Currency API
['email' => '[email protected]'] // additional parameters
);
echo $widget->getHtmlCode();
Paymentwall_Config::getInstance()->set([
'api_type' => Paymentwall_Config::API_VC,
'public_key' => 'YOUR_PROJECT_KEY',
'private_key' => 'YOUR_SECRET_KEY'
]);
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate(true)) {
$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();
}
$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,
[
new Paymentwall_Product('product301', 3.33, 'EUR'), // first product in cart
new Paymentwall_Product('product607', 7.77, 'EUR') // second product in cart
],
['email' => '[email protected]'] // additional params
);
echo $widget->getHtmlCode();
$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,
[
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
],
['email' => '[email protected]', 'flexible_cart_api' => 1] // additional params
);
echo $widget->getHtmlCode();
Paymentwall_Config::getInstance()->set([
'api_type' => Paymentwall_Config::API_CART,
'public_key' => 'YOUR_PROJECT_KEY',
'private_key' => 'YOUR_SECRET_KEY'
]);
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate(true)) {
$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();
}
$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']);
}
$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']);
}
$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
$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']);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.