com.jambool.socialgold.api
Class PaymentsClient

java.lang.Object
  extended by com.jambool.socialgold.api.PaymentsClient

public class PaymentsClient
extends Object

PaymentsClient

Sample code to provide convient access to the Social Gold Payments V1 API methods that make a call to the service: - getBalance - getTransactionStatus - getTransaction - creditUser - debitUser - refundUser - buyGoods methods that generate a URL for merchant to render in a page: - getBuyPaymentsURL - getBuyGoodsURL Notes: - input validation is weak, if at all - JSON, XML, and other parsers are not included at this time - formal excetions should be thrown


Field Summary
private  String offerID
          WRITEME: Document this brpocock@star-hope.org
private  String secretMerchantKey
          WRITEME: Document this brpocock@star-hope.org
private  String serverName
          WRITEME: Document this brpocock@star-hope.org
 
Constructor Summary
PaymentsClient(String newServerName, String newOfferID, String newSecretMerchantKey)
          ---------------------------------------------------------------- -------------
 
Method Summary
private  String _calculateSignature(Hashtable<?,?> signatureParams)
          ---------------------------------------------------------------- -------------
private  Hashtable _getResponse(String cmdURL)
          ---------------------------------------------------------------- -------------
private  Hashtable _getResponse(String cmdURL, Boolean requiresSSL)
           
private  String _getURL(Hashtable baseParams, Hashtable requiredParams, Hashtable optionalParams)
          ================================================================ ============= private methods below this ========================== ===================================================
private  String _getURL(Hashtable baseParams, Hashtable requiredParams, Hashtable optionalParams, Boolean requiresSSL)
          WRITEME: Document this method brpocock@star-hope.org
private  void _mergeParams(Hashtable srcParams, Hashtable destParams)
          ---------------------------------------------------------------- -------------
private  String _paramHashToURI(Hashtable params)
          ---------------------------------------------------------------- -------------
 String getBuyCurrencyURL(String userID, Float usdAmount, String currency_label, Integer currency_xrate, Integer currency_amount, Float quantity, String format, String app_params, String platform)
          WRITEME: Document this method brpocock@star-hope.org
 String getBuyGoodsURL(String userID, Float usdAmount, String title, String format, String external_ref_id, Integer quantity, String app_params, String platform, String platform_sub_id, String statement_descriptor, String sku)
          
============================================================ ==============

buy_goods_with_socialgold

returns a URL to have in your IFRAME SRC= tag

WRITEME: Document this method brpocock@star-hope.org
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offerID

private String offerID
WRITEME: Document this brpocock@star-hope.org


secretMerchantKey

private String secretMerchantKey
WRITEME: Document this brpocock@star-hope.org


serverName

private String serverName
WRITEME: Document this brpocock@star-hope.org

Constructor Detail

PaymentsClient

public PaymentsClient(String newServerName,
                      String newOfferID,
                      String newSecretMerchantKey)
---------------------------------------------------------------- -------------

Parameters:
newServerName - WRITEME
newOfferID - WRITEME
newSecretMerchantKey - WRITEME
Method Detail

main

public static void main(String[] args)
Parameters:
args - command-line arguments (none needed)

_calculateSignature

private String _calculateSignature(Hashtable<?,?> signatureParams)
---------------------------------------------------------------- -------------

Parameters:
signatureParams - WRITEME
Returns:
WRITEME

_getResponse

private Hashtable _getResponse(String cmdURL)
                        throws org.apache.http.client.ClientProtocolException,
                               IOException
---------------------------------------------------------------- -------------

Parameters:
cmdURL - WRITEME
Returns:
WRITEME
Throws:
IOException
org.apache.http.client.ClientProtocolException

_getResponse

private Hashtable _getResponse(String cmdURL,
                               Boolean requiresSSL)
                        throws org.apache.http.client.ClientProtocolException,
                               IOException
Throws:
org.apache.http.client.ClientProtocolException
IOException

_getURL

private String _getURL(Hashtable baseParams,
                       Hashtable requiredParams,
                       Hashtable optionalParams)
================================================================ ============= private methods below this ========================== ===================================================

Parameters:
baseParams - WRITEME
requiredParams - WRITEME
optionalParams - WRITEME
Returns:
WRITEME

_getURL

private String _getURL(Hashtable baseParams,
                       Hashtable requiredParams,
                       Hashtable optionalParams,
                       Boolean requiresSSL)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
baseParams - WRITEME
requiredParams - WRITEME
optionalParams - WRITEME
requiresSSL - WRITEME
Returns:
WRITEME

_mergeParams

private void _mergeParams(Hashtable srcParams,
                          Hashtable destParams)
---------------------------------------------------------------- -------------


_paramHashToURI

private String _paramHashToURI(Hashtable params)
---------------------------------------------------------------- -------------


getBuyCurrencyURL

public String getBuyCurrencyURL(String userID,
                                Float usdAmount,
                                String currency_label,
                                Integer currency_xrate,
                                Integer currency_amount,
                                Float quantity,
                                String format,
                                String app_params,
                                String platform)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
userID - WRITEME
usdAmount - WRITEME
currency_label - WRITEME
currency_xrate - WRITEME
currency_amount - WRITEME
quantity - WRITEME
format - WRITEME
app_params - WRITEME
platform - WRITEME
Returns:
WRITEME

getBuyGoodsURL

public String getBuyGoodsURL(String userID,
                             Float usdAmount,
                             String title,
                             String format,
                             String external_ref_id,
                             Integer quantity,
                             String app_params,
                             String platform,
                             String platform_sub_id,
                             String statement_descriptor,
                             String sku)

============================================================ ==============

buy_goods_with_socialgold

returns a URL to have in your IFRAME SRC= tag

WRITEME: Document this method brpocock@star-hope.org

Parameters:
userID - the user_id of the player (e.g., "abc123")
usdAmount - amount in USD$ of the purchase (e.g., 1.75 implies $1.75)
title - description of item being sold
format - ( iframe )
external_ref_id - a unique string with your representation of the transaction
quantity - quantity
app_params - a variable that will be passed back to you on the post back
platform - the platform of where this user is unique. If
this is for a Facebook user,
then pass in "facebook", etc. Use these values if appropiate,
otherwise send in a string representing the platform
facebook
myspace
orkut
friendster
hi5
tagged
twitter
bebo
You may also pass in any short (32 chars) alphanumeric string to
represent your own platform.
For example "mywebsite", "mygame123"
platform_sub_id - unique enum, representing the above
platforms - see website for details
statement_descriptor - 8 character string - to be shown on
invice, credit card statement, etc
sku - unique string representing item in your system
Returns: