Difference between revisions of "FBInstant.payments.purchaseAsync"
From GiderosMobile
Line 8: | Line 8: | ||
FBInstant.payments.purchaseAsync(purchaseConfig,callback) | FBInstant.payments.purchaseAsync(purchaseConfig,callback) | ||
</source> | </source> | ||
− | '''purchaseConfig''': (table) The purchase's configuration details. | + | === Parameters === |
− | '''callback''': (function) A function that will be called with two arguments: True when the product is successfully purchased by the player. Otherwise, it rejects if the operation failed, and an error code if the function failed. ''''''<br/> | + | '''purchaseConfig''': (table) The purchase's configuration details. <br/> |
+ | '''callback''': (function) A function that will be called with two arguments: True when the product is successfully purchased by the player. Otherwise, it rejects if the operation failed, and an error code if the function failed. <br/> | ||
+ | === Examples === | ||
+ | '''Example 1'''<br/> | ||
+ | <source lang="lua"><br /> | ||
+ | FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error) | ||
+ | if result then | ||
+ | print("Purchased!") | ||
+ | for key,value in pairs(result) do | ||
+ | print(key,value) | ||
+ | end | ||
+ | end | ||
+ | end) | ||
+ | <br/></source> | ||
+ | '''Example 2'''<br/> | ||
+ | <source lang="lua"><br /> | ||
+ | FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error) | ||
+ | if result then | ||
+ | print("Purchased!") | ||
+ | print("developer string",result.developerPayload) | ||
+ | print("payment id",result.paymentID) | ||
+ | print("product id",result.productID) | ||
+ | print("purchaseTime",result.purchaseTime) | ||
+ | print("puchaseToken",result.purchaseToken) | ||
+ | print("signedRequest",result.signedRequest) | ||
+ | end | ||
+ | end) | ||
+ | <br/></source> |
Revision as of 10:44, 23 August 2018
Available since: Gideros 2018.3
Description
Begins the purchase flow for a specific product.
FBInstant.payments.purchaseAsync(purchaseConfig,callback)
Parameters
purchaseConfig: (table) The purchase's configuration details.
callback: (function) A function that will be called with two arguments: True when the product is successfully purchased by the player. Otherwise, it rejects if the operation failed, and an error code if the function failed.
Examples
Example 1
<br />
FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error)
if result then
print("Purchased!")
for key,value in pairs(result) do
print(key,value)
end
end
end)
<br/>
Example 2
<br />
FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error)
if result then
print("Purchased!")
print("developer string",result.developerPayload)
print("payment id",result.paymentID)
print("product id",result.productID)
print("purchaseTime",result.purchaseTime)
print("puchaseToken",result.purchaseToken)
print("signedRequest",result.signedRequest)
end
end)
<br/>