#About Paymentwall Paymentwall 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.
#Paymentwall .NET Library This library allows developers to use Paymentwall APIs (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.
This library is a third party conversion of Paymentwall's paymentwall-php library, under the MIT license.
#Installation To install the library in your environment, you can download the ZIP archive, unzip it and add a reference to Libs\PaymentWallApoc.DLL into your project.
Alternatively, you can run:
git clone git://github.com/jsylvan/paymentwall-net/paymentwall-net.git
Then use a code sample below.
#Projects
##paymentwall-net-Logging ##paymentwall-net-Logging-Tests This project logs every transaction sent to the database. The purpose of this project is to keep an internal record of all monetary transactions. This can be used to verify all money is actually is actually accounted for.
While the sample application uses a Microsoft SQL database, any database supported by ADO.NET and Entity Framework 6 should work.
##paymentwall-net ##paymentwall-net-Logging-Tests This is a sample MVC application that purchases virtual currency from paymentwall.
##paymentwall-net-goods-api ##paymentwall-net-goods-api-tests This project contains code required to contact the paymentwall services and initialize a transactions.
##paymentwall-net-goods-pingback ##paymentwall-net-goods-pingback-tests This project contains the webservice that paymentwall calls upon a sucessful payment. It uses SignalR to communicate with other machines on the network.
##paymentwall-net-goods-admin ##paymentwall-net-goods-admin-tests This project contains a sample administrative panel that can be used to manage payments as well as view the interal transaction trail.
#Code Samples
##Digital Goods API
####Configuring Web.Config (Client)
<appSettings>
<add key="PaymentWallAppKey" value="YOUR_APPLICATION_KEY" /> <!-- available in your Paymentwall merchant area -->
<!-- Do not share this key with the outside world, including public source control -->
<add key="PaymentWallSecretKey" value="YOUR_SECRET_KEY" /> <!-- available in your Paymentwall merchant area -->
<!-- Do not share this key with the outside world, including public source control -->
<add key="PaymentWallPostBackURL" value="YOUR_PUBLIC_IIS_LOCATION/payWallPostBack" />
<!-- Do not share this key with the outside world, including public source control -->
<appSettings>
####Configuring Web.Config (PostBack)
<appSettings>
<add key="PaymentWallAppKey" value="YOUR_APPLICATION_KEY" /> <!-- available in your Paymentwall merchant area -->
<!-- Do not share this key with the outside world, including public source control -->
<add key="PaymentWallSecretKey" value="YOUR_SECRET_KEY" /> <!-- available in your Paymentwall merchant area -->
<!-- Do not share this key with the outside world, including public source control -->
<appSettings>####Widget Call Web API details
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.
var 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 = // 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
)}]
);
//TODO: Update this
widget.array('email' => 'user@hostname.com') // additional parameters
);
in Razor
//Controller:
ViewBag.Widget = widget;
//Razor
@Html.Raw(ViewBag.Widget)
####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:
$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
}
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
} else {
echo $pingback->getErrorSummary();
}####Real Time Updates
When a payment is proessed the system will send a SignalR message, signifying the status of a payment. Any web application that is associated with the user's status (such as current virtual currency) can be updated in real time using SignalR calls.
##Virtual Currency API
####Initializing Paymentwall
require_once('/path/to/paymentwall-php/lib/paymentwall.php');
Paymentwall_Base::setApiType(Paymentwall_Base::API_VC);
Paymentwall_Base::setAppKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
Paymentwall_Base::setSecretKey('YOUR_SECRET_KEY'); // available in your Paymentwall merchant area
####Widget Call
$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 = 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 virual currency
}
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
} else {
echo $pingback->getErrorSummary();
}##Cart API
####Initializing Paymentwall
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 = 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();####Pingback Processing
$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
}
echo 'OK'; // Paymentwall expects response to be OK, otherwise the pingback will be resent
} else {
echo $pingback->getErrorSummary();
}