public class Product<T extends Product<T>> extends java.lang.Object implements JsonParams
Transaction.| Constructor and Description |
|---|
Product()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
T |
addItem(java.lang.String name,
java.lang.String type,
int amount)
Adds an item to the product.
|
T |
addVirtualCurrency(java.lang.String name,
java.lang.String type,
long amount)
Adds a virtual currency to the product.
|
static int |
convertCurrency(DDNA ddna,
java.lang.String code,
float value)
Converts a currency in a floating point format with a decimal point,
such as '1.23' EUR, into an integer representation which can be used
with
setRealCurrency(String, int). |
T |
setRealCurrency(java.lang.String type,
int amount)
Set a real currency for the product.
|
org.json.JSONObject |
toJson() |
public org.json.JSONObject toJson()
toJson in interface JsonParamspublic T setRealCurrency(java.lang.String type, int amount)
type - type of the currency, using an ISO-4217 3 character
currency codeamount - amount of the currency, using the minor currency unitT instancejava.lang.IllegalArgumentException - if the type is null or emptyconvertCurrency(DDNA, String, float)public T addVirtualCurrency(java.lang.String name, java.lang.String type, long amount)
name - name of the currencytype - type of the currency, using an ISO-4217 3 character
currency codeamount - amount of the currency, using the minor currency unitT instancejava.lang.IllegalArgumentException - if the name is null or emptyjava.lang.IllegalArgumentException - if the type is null or emptypublic T addItem(java.lang.String name, java.lang.String type, int amount)
name - name of the itemtype - type of the itemamount - amount of the itemT instancejava.lang.IllegalArgumentException - if the name is null or emptyjava.lang.IllegalArgumentException - if the type is null or emptypublic static int convertCurrency(DDNA ddna, java.lang.String code, float value)
setRealCurrency(String, int). This method will also work
for currencies which don't use a minor currency unit, for example such
as the Japanese Yen (JPY).ddna - the SDK instancecode - the ISO 4217 currency codevalue - the currency value to convertjava.lang.IllegalArgumentException - if ddna is nulljava.lang.IllegalArgumentException - if code is null or empty