First of all, I make all my tests upon firefox 0S 2.0 simulator
I have a website that is a game webportal.
I made a privilleged packaged app with all requierements. As launch_path I took some "index.html" file and inside this file I wrote all the basic infos and particulary this one in the header:
<meta http-equiv="refresh" content="5;url=http://url10.infinitgame.com?webview=1">
As far as this, it works OK. Meaning that I can launch my app inside firefox OS desktop and get inside my webportal
So next I packaged the fxpay library as explained in some doc and added it in my game webportal server. I've made everything like the tutorial and it perfectly works with the fake products.
After this I made a "real product" (creating a Bango account, chosing countries, and finally creating real products). And then I turned OFF the fake products from the javascript code. Now I cannot find my product and there is the error message I got:
-"using default adapter"
-"using Firefox Marketplace In-App adapter"
-"using custom adapter"
-"receipts fetched from mozApps:" 0
-"receipts fetched from localStorage:" 0
-"Number of receipts installed: 0"
-"about to fetch real products for app" "http%3A%2F%2Furl10.infinitgame.com"
-"opening" "GET""to" "https://marketplace.firefox.com/api/v1/payments/http%3A%2F%2Furl10.infinitgame.com/in-app/?active=1"
-"BAD_API_RESPONSE" "status:" 404 "for URL:" "https://marketplace.firefox.com/api/v1/payments/http%3A%2F%2Furl10.infinitgame.com/in-app/?active=1"
-"BAD_API_RESPONSE" "response:" "{"detail":"Not found"}"
-"Error getting products:" "BAD_API_RESPONSE".
I also read online that an app must be published before production payments can be used. But I find a lot of contradictory informations about firefoxOS since the community is quite small.
Here is my manifest.webapp
{
"version": "1.0.0",
"name": "T-Games",
"description": "T-games service de malade",
"launch_path": "/index.html",
"type": "privileged",
"icons": {
"16": "/img/icon-16.png",
"48": "/img/icon-48.png",
"128": "/img/icon-128.png"
},
"developer": {
"name": "Serial Screener",
"url": "http://url0.infinitgame.com"
},
"permissions": {
"systemXHR": {
"description": "Required to access payment API"
}
},
"chrome": { "navigation": true },
"origin": "app://url10.infinitgame.com",
"csp" : "default-src *; script-src 'self'; object-src 'none'; style-src 'self' 'unsafe-inline'"
}
and here is my index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>T-Games</title>
<meta name="description" content="TGames, service de jeux">
<meta name="viewport" content="width=device-width">
<meta http-equiv="refresh" content="5;url=http://url10.infinitgame.com?webview=1">
</head>
<body>
<p>Loading...</p>
<script type="text/javascript" src="fxpay.min.js"></script>
</body>
</html>
Thanks for time & support.
Tomy
It is true that your app must be fully approved and public before the API will return your real products. On the Developer Hub you can click Status from your app's sidebar to see if it's public or not. A non-public app could cause the BAD_API_RESPONSE (404) you see.
Another problem is that according to your manifest your app is packaged and has an origin of app://url10.infinitgame.com
. However, the console logs suggest that you are running the app from the web at origin http://url10.infinitgame.com
. This will also cause a BAD_API_RESPONSE (404) because your products are registered under the app:
origin, not the http:
origin.
If I understand correctly, you are redirecting to the http:
URL from within the packaged app. If that's the case, you would need to run all of your fxpay
code from within the packaged app and do something like window.postMessage
to pass the results to the http:
URL. You'd also have to switch to using an iframe rather than a redirect so that you can run JavaScript from the top level packaged app window.
It's not required that you use a packaged app for in-app payments with the fxpay
library. As of more recent versions, it's fine to use a hosted app. Maybe that would be easier.