Difference between revisions of "FBInstant.payments.purchaseAsync"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 7: Line 7:
 
Begins the purchase flow for a specific product.<br />
 
Begins the purchase flow for a specific product.<br />
 
<br /></translate>
 
<br /></translate>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
  FBInstant.payments.purchaseAsync(purchaseConfig,callback)
 
  FBInstant.payments.purchaseAsync(purchaseConfig,callback)
 
</source>
 
</source>
Line 15: Line 15:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Example 1'''<br/>
 
'''Example 1'''<br/>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error)
 
FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error)
 
     if result then
 
     if result then
Line 26: Line 26:
 
<br/></source>
 
<br/></source>
 
'''Example 2'''<br/>
 
'''Example 2'''<br/>
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error)
 
FBInstant.payments.purchaseAsync({productID="12345", developerPayload="foobar"}, function(result,error)
 
     if result then
 
     if result then

Revision as of 15:28, 13 July 2023


Available since: Gideros 2018.3
Class: Payments

Description


Begins the purchase flow for a specific product.

<syntaxhighlight lang="lua">

FBInstant.payments.purchaseAsync(purchaseConfig,callback)

</source>

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
<syntaxhighlight lang="lua"> 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)
</source> Example 2
<syntaxhighlight lang="lua"> 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)
</source>