#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 Ruby 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.
#Installation To install the library in your environment, you can download the ZIP archive, unzip it and place into your project.
Alternatively, you can run:
git clone git://github.com/paymentwall/paymentwall-ruby.git
Then use a code sample below.
#Code Samples
##Digital Goods API
####Initializing Paymentwall
require_relative '/path/to/paymentwall-ruby/lib/paymentwall.rb'
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 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.
widget = Paymentwall::Widget.new(
'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
[ # product details for Flexible Widget Call. To let users select the product on Paymentwall's end, leave this array empty
Paymentwall::Product.new(
'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
1, # duration is 1
Paymentwall::Product::PERIOD_TYPE_MONTH, # month
true # recurring
)
],
{'email' => '[email protected]'} # additional parameters
)
puts widget.getHtmlCode()
####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 = Paymentwall::Pingback.new(request_get_params, request_ip_address)
if pingback.validate()
productId = pingback.getProduct().getId()
if pingback.isDeliverable()
# deliver the product
elsif pingback.isCancelable()
# withdraw the product
end
puts 'OK' # Paymentwall expects response to be OK, otherwise the pingback will be resent
else
puts pingback.getErrorSummary()
end
##Virtual Currency API
####Initializing Paymentwall
require_relative '/path/to/paymentwall-ruby/lib/paymentwall.rb'
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
####Widget Call
widget = Paymentwall::Widget.new(
'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
)
puts widget.getHtmlCode()
####Pingback Processing
pingback = Paymentwall::Pingback.new(request_get_params, request_ip_address)
if pingback.validate()
virtualCurrency = pingback.getVirtualCurrencyAmount()
if pingback.isDeliverable()
# deliver the virtual currency
elsif pingback.isCancelable()
# withdraw the virual currency
end
puts 'OK' # Paymentwall expects response to be OK, otherwise the pingback will be resent
else
puts pingback.getErrorSummary()
end
##Cart API
####Initializing Paymentwall
require_relative '/path/to/paymentwall-ruby/lib/paymentwall.rb'
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 = Paymentwall::Widget.new(
'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,
[
Paymentwall::Product.new('product301', 3.33, 'EUR'), # first product in cart
Paymentwall::Product.new('product607', 7.77, 'EUR') # second product in cart
],
{'email' => '[email protected]'} # additional params
)
puts widget.getHtmlCode()
####Pingback Processing
pingback = Paymentwall::Pingback.new(request_get_params, request_ip_address)
if pingback.validate()
products = pingback.getProducts()
if pingback.isDeliverable()
# deliver the products
elsif pingback.isCancelable()
# withdraw the products
end
puts 'OK' # Paymentwall expects response to be OK, otherwise the pingback will be resent
else
puts pingback.getErrorSummary()
end