The document discusses building scalable game payment systems using HTML5 and PayPal Digital Goods. It describes the architecture involving client and server-side components, PayPal Digital Goods, HTML5 LocalStorage, and jQuery. It then covers implementing the payment and inventory management flows, including fetching tokens, committing payments, verifying purchases, and retrieving local storage purchases. Finally, it discusses setting up product webhooks for functions like user identity, payment recording and verification, and inventory management.
Dev Dives: Streamline document processing with UiPath Studio Web
HTML5 Gaming Payment Platforms Building Scalable Game Payment Systems
1. HTML5 Gaming Payment Platforms
Building Scalable Game Payment Systems
Jonathan LeBlanc
Developer Evangelist (PayPal)
jleblanc@paypal.com
Twitter: @jcleblanc
Github: github.com/jcleblanc
2. What are we going to talk about
Cross Platform Digital Payments
21. How the Verification Flow Works
Get Data
Product
Storage
Success / Fail
Verify Purchase
Verification Digital
Request Goods
Success / Fail
User
Notify User
Notification
22. Opening and Closing the Flow
Opening the Modal Window
var dgflow = dg.startFlow(
'https://www.sandbox.paypal.com/
webscr?&useraction=commit&token=###');
Closing the Modal Window
dgflow.closeFlow();
23. Session Breakdown
The Architecture
The Implementation
The Product Webhooks
27. Payment: recordPayment
function recordPayment($paymentObj = ""){
$userId = $paymentObj["userId"];
$itemId = $paymentObj["itemId"];
$transactionId = $paymentObj["transactionId"];
$paymentStatus = $paymentObj["paymentStatus"];
$orderTime = $paymentObj["orderTime"];
//INSERT YOUR CODE TO SAVE THE PAYMENT DATA
}
28. Payment: verifyPayment
function verifyPayment($userId = 0, $itemId = 0){
$result = false;
//INSERT YOUR CODE TO QUERY PAYMENT DATA AND
//RETURN TRUE if MATCH FOUND
return $result;
}
31. Inventory: getItem
function getItem($itemId){
$items = array(
array(name => "Mega Shields",
number => "123",
qty => "1",
taxamt => "0",
amt => "1.00",
desc => "Unlock the power!",
category => "Digital"),
...);
$returnObj = array();
for ($i = 0; $i < count($items); $i++){
if ($items[$i]['number'] == $itemId){
$returnObj = $items[$i];
}
}
return $returnObj;
}
32. A Few Links
The HTML5 Toolkit
https://github.com/paypal/html5-dg
The PayPal Sandbox (Create Test Users)
https://developer.paypal.com/
JSWars Code and Demo
http://29a.ch/jswars/
33. Thank You! Any Questions?
http://www.slideshare.net/jcleblanc
Jonathan LeBlanc
Developer Evangelist (PayPal)
jleblanc@paypal.com
Twitter: @jcleblanc
Github: github.com/jcleblanc
Identitywill come from one of two places, either as a hookinto the client ID server or fromPayPalitself
If the user binding is not currently done, we store the information back to the client inventory storeStore inventory information into local storage
The URI for startFlow is comprised of static values (Sandbox / live URI & useraction parameter) and a dynamic token. The token is generated by making a server side request, then a setExpressCheckout call. This server side call sets the value of the item, currency, success / fail URIs, etc. and generates a token to pop up the modal window.