facebook - How to provide accurate prices with new Payment system -


according new payment documentation available here if want dynamic pricing need set script fb call saying "user wants buy x items , wants pay in currency cc" , our script should return price in currency. documentation not clear our testing showed fb expects return price of 1 item rounded 2 decimals. if fb asks script "tell me price of 14 tokens in usd" , want 14 tokens cost 2usd need return round(2/14, 2) 0.14 , fb multiply 0.14 14 , show user needs pay 1.96$.

so how supposed make fb show user needs pay 2 dollars 14 tokens?

now managed access new payment flow (as fb made "breking change announcement"), can tell how managed around similar problem.

situation:
offering number of products user individually generated @ runtime, similar problem: 1 of products might example contain amount of ingame currency fixed price. @ time user might additional amount of currency free, resulting in product containing +x ingame currency, for same price.

solution:
define product dynamically, i.e. call script page renders individual product. purpose, provide securely encrypted token sent fb.ui call request_id. product script decrypts token , - if security checks pass - renders product dynamically creating , outputting og:product html...

note:
please make sure generated products og:url tag exactly match called url, e.g. if create product calling http://www.example.com/product.php?test=123&token=nkvadkfjgakajdvkaldhjf product's meta url must this:

<meta property="og:url" content= "http://www.example.com/product.php?test=123&token=nkvadkfjgakajdvkaldhjf" /> 

otherwise, facebook not able follow redirect... keep in mind: every og:product must self referencing, pointing exact url called.

the drawback described procedure fb won't able cache product every used request_id has unique. product individually generated anyway, why bother...

in short:
create product dynamically fulfills needs , make point itself, using amount of 1 instead of 14 , setting final price 2 usd.

<!doctype html> <html>   <head prefix=     "og: http://ogp.me/ns#      fb: http://ogp.me/ns/fb#      product: http://ogp.me/ns/product#">     <meta property="og:type"                   content="og:product" />     <meta property="og:title"                  content="14 tokens" />     <meta property="og:image"                  content="http://www.example.com/imageurl.png" />     <meta property="og:description"            content="you'll 14 tokens here. use them liking..." />     <meta property="og:url"                    content="[exact_path_to_this_file_including_all_params]" />     <meta property="product:price:amount"      content="2"/>     <meta property="product:price:currency"    content="usd"/>   </head> </html> 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -