opensocial.Payment
- Method
- opensocial.Payment.Field
- opensocial.Payment.Field.SANDBOX
- opensocial.Payment.Field.ITEMS
- opensocial.Payment.Field.AMOUNT
- opensocial.Payment.Field.MESSAGE
- opensocial.Payment.Field.ATTACHMENT
- opensocial.Payment.Field.PAYMENT_TYPE
- opensocial.Payment.Field.ORDER_ID
- opensocial.Payment.Field.ORDER_TIME
- opensocial.Payment.Field.SUBMITTED_TIME
- opensocial.Payment.Field.EXECUTED_TIME
- opensocial.Payment.Field.RESPONSE_CODE
- opensocial.Payment.Field.RESPONSE_MESSAGE
- opensocial.Payment.Field.PAYMENT_COMPLETE
- mbga.Payment.Field
- opensocial.PaymentType
- opensocial.Payment.ResponseCode
- opensocial.Payment.ResponseCode.APP_LOGIC_ERROR
- opensocial.Payment.ResponseCode.LOGIC_ERROR
- opensocial.Payment.ResponseCode.APP_NETWORK_FAILURE
- opensocial.Payment.ResponseCode.INSUFFICIENT_MONEY
- opensocial.Payment.ResponseCode.INVALID_TOKEN
- opensocial.Payment.ResponseCode.MALFORMED_REQUEST
- opensocial.Payment.ResponseCode.NOT_IMPLEMENTED
- opensocial.Payment.ResponseCode.OK
- opensocial.Payment.ResponseCode.PAYMENT_ERROR
- opensocial.Payment.ResponseCode.PAYMENT_PROCESSOR_ALREADY_OPENED
- opensocial.Payment.ResponseCode.UNKNOWN_ERROR
- opensocial.Payment.ResponseCode.USER_CANCELLED
- opensocial.Payment.RecordsRequestFields
Method
opensocial.newPayment
<static> opensocial.Payment newPayment(params)
Generates Payment object.
Parameter
| Name | Type | Description |
|---|---|---|
| params | Map. | Additional parameters passed on to requests |
Return value
| Type | Description |
|---|---|
| opensocial.Payment | New Payment object |
Sample
var params = {};
params[opensocial.Payment.Field.ITEMS] = [item];
params[opensocial.Payment.Field.AMOUNT] = 200;
params[opensocial.Payment.Field.PAYMENT_TYPE] = opensocial.Payment.PaymentType.PAYMENT;
var payment = opensocial.newPayment(params);
opensocial.newBillingItem
<static> opensocial.BillingItem newBillingItem(params)
Generates BillingItem object.
Parameter
| Name | Type | Description |
|---|---|---|
| params | Map.<opensocial.BillingItem.Field | Object> |
Return value
| Type | Description |
|---|---|
| opensocial.BillingItem | New BillingItem object. |
Sample
var itemParams = {};
itemParams[mbga.BillingItem.Field.NAME] = "Machine gun";
itemParams[opensocial.BillingItem.Field.SKU_ID] = 'XA123';
itemParams[opensocial.BillingItem.Field.PRICE] = 100;
itemParams[opensocial.BillingItem.Field.COUNT] = 2;
itemParams[opensocial.BillingItem.Field.IMAGE_URL] = "http://example.com/iten.gif";
itemParams[mbga.BillingItem.Field.COUNT] = 2;
var item = opensocial.newBillingItem(itemParams);
opensocial.requestPayment
<static> requestPayment(payment, opt_callback)
Makes a request to create the specified activity without waiting for the operation to be completed.
Parameter
| Name | Type | Description |
|---|---|---|
| payment | opensocial.Payment | Payment object |
| opt_callback | Function | The callback function that is called when the request is complete. |
Return value
None
Sample
opensocial.requestPayment(payment, function(response) {
if (response.hadError()) {
// error
} else {
var payment = response.getData();
var orderId = payment.getField(opensocial.Payment.Field.ORDER_ID);
// ...
}
});
opensocial.requestPaymentRecords
Not supported.
opensocial.Payment.isPayment
Boolean isPayment()
Returns "True" when this Payment object type is PAYMENT.
Parameter
None
Return value
| Type | Description |
|---|---|
| Boolean | "True" when this Payment type is PAYMENT; otherwise, it is "False". |
Sample
if (payment.isPayment()) {
// ...
} else {
// ...
}
opensocial.Payment.isCredit
Boolean isCredit()
Returns "True" when this Payment object type is CREDIT.
Parameter
None
Return value
| Type | Description |
|---|---|
| Boolean | "True" when this Payment type is CREDIT; otherwise, it is "False". |
Sample
if (payment.isCredit()) {
// ...
} else {
// ...
}
opensocial.Payment.isComplete
Boolean isComplete()
Returns "True" when the PAYMENT_COMPLETE field of this Payment object is set.
Parameter
None
Return value
| Type | Description |
|---|---|
| Boolean | "True" when this Payment is complete; otherwise, it is "False". |
Sample
if (payment.isComplete()) {
// ...
} else {
// ...
}
opensocial.Payment.getField
String getField(key, opt_params)
Acquires data for the Payment linked to the specified key.
Parameter
| Name | Type | Description |
|---|---|---|
| key | String | Key for acquiring data. Refer to the Field class for possible values |
| opt_params | Map.<opensocial.DataRequest.DataRequestFields | Object> |
Return value
| Type | Description |
|---|---|
| String | Data |
Sample
var title = payment.getField(opensocial.Payment.Field.AMOUNT);
opensocial.Payment.setField
setField(key, data)
Sets data in the Payment with the specified key.
Parameter
| Name | Type | Description |
|---|---|---|
| key | String | The key to set in data |
| String | String | The data to set |
Return value
None
Sample
payment.setField(opensocial.Payment.Field.AMOUNT, 200);
opensocial.Payment.Field
opensocial.Payment.Field.SANDBOX
In a Sandbox environment, "True" is placed in this value.
opensocial.Payment.Field.ITEMS
A list of items included in this settlement. BillingItem is specified with an array. Currently, only one can be specified. This is a required value.
opensocial.Payment.Field.AMOUNT
The total amount of this settlement. It is specified using a positive integer. This is a required value.
opensocial.Payment.Field.MESSAGE
Currently not supported.
opensocial.Payment.Field.ATTACHMENT
Currently not supported.
opensocial.Payment.Field.PAYMENT_TYPE
A type of Payment object. It is specified with opensocial.Payment.PaymentType. Only opensocial.Payment.PaymentType.PAYMENT can be specified.
opensocial.Payment.Field.ORDER_ID
A unique settlement ID in an Application. It is a positive integer.
opensocial.Payment.Field.ORDER_TIME
The time at which settlement was requested. It is shown in milliseconds from epoch. Since this value is generated by the browser, it is not necessarily correct. It is used as a reference in the log.
opensocial.Payment.Field.SUBMITTED_TIME
The time at which the user permitted the settlement. It is shown in milliseconds from epoch. Since this value is generated by the browser, it is not necessarily correct. It is used as a reference in the log.
opensocial.Payment.Field.EXECUTED_TIME
The time at which the Coin was withdrawn. It is shown in milliseconds from epoch.
opensocial.Payment.Field.RESPONSE_CODE
Response code for the settlement. It specifies "OK" when there is no error.
opensocial.Payment.Field.RESPONSE_MESSAGE
Explanation of a readable response. NULL is permitted.
opensocial.Payment.Field.PAYMENT_COMPLETE
Boolean value that indicates whether or not the settlement is complete.
mbga.Payment.Field
mbga.Payment.Field.PAYMENT_ID
A unique settlement ID in Mobage.
opensocial.PaymentType
opensocial.PaymentType.PAYMENT
Regular Coin Payment type.
opensocial.PaymentType.CREDIT
Not supported.
opensocial.Payment.ResponseCode
opensocial.Payment.ResponseCode.APP_LOGIC_ERROR
Specify this status if an error has occurred on an Application server due to a logic problem.
opensocial.Payment.ResponseCode.LOGIC_ERROR
opensocial.Payment.ResponseCode.APP_NETWORK_FAILURE
Returns this status when a problem occurs, such as when the payment handler URL is not set or cannot be connected to, or a timeout has occurred.
opensocial.Payment.ResponseCode.INSUFFICIENT_MONEY
opensocial.Payment.ResponseCode.INVALID_TOKEN
opensocial.Payment.ResponseCode.MALFORMED_REQUEST
Returns this status when the request is incorrect.
opensocial.Payment.ResponseCode.NOT_IMPLEMENTED
opensocial.Payment.ResponseCode.OK
A normal response.
opensocial.Payment.ResponseCode.PAYMENT_ERROR
Returns this error when there is a problem with the settlement.
opensocial.Payment.ResponseCode.PAYMENT_PROCESSOR_ALREADY_OPENED
opensocial.Payment.ResponseCode.UNKNOWN_ERROR
opensocial.Payment.ResponseCode.USER_CANCELLED
Returns this status when the user cancels.
opensocial.Payment.RecordsRequestFields
opensocial.Payment.RecordsRequestFields.TYPE
opensocial.Payment.RecordsRequestFields.IS_COMPLETE
opensocial.Payment.RecordsRequestFields.MAX
opensocial.Payment.RecordsRequestFields.START_TIME
Revision History
- 12/2010
- Initial Release.