Chrome packaged app in-app payment api - javascript

I have created a chrome app and trying to get the list of product but I am getting internal server error. The following is a code.
function getProductList() {
console.log("google.payments.inapp.getSkuDetails");
statusDiv.text("Retreiving list of available products...");
google.payments.inapp.getSkuDetails({
'parameters': {env: "prod"},
'success': onSkuDetails,
'failure': onSkuDetailsFailed
});
}
function onSkuDetails(response) {
console.log("onSkuDetails", response);
var products = response.response.details.inAppProducts;
var count = products.length;
for (var i = 0; i < count; i++) {
var product = products[i];
addProductToUI(product);
}
statusDiv.text("");
getLicenses();
}
function onSkuDetailsFailed(response) {
console.log("onSkuDetailsFailed", response);
statusDiv.text("Error retreiving product list. (" + response.response.errorType + ")");
}

I received this same error because I mistakenly changed the app id inside buy.js to my own app id. I thought that this was the way that the in-app purchase mechanism connected to my app in the chrome web store to access the in-app purchases, but this is not the case at all. What I guess the app-id inside buy.js is the connection to the in-app purchase mechanism built inside Chrome.
So I suggest you try again with the original unmodified buy.js that comes with the test app sample zip package and see if that changes.
The consequence of all of this, is that as far as I can determine it is not possible to debug the in-app purchase flow mechanism, because you can only make it work with a already published app on which in-app purchases have been specified and as such you cannot access the Chrome console. I have not tried unpublishing the app, perhaps that might work. What you cannot do, is clone the app and load it again as an unpackaged extension (as that will of course have a different app-id).
Hope this helps.

Related

Enable users of a WebRtc app to download webrtc logs via javascript

I've seen the following:
chrome://webrtc-internals
However I'm looking for a way to let users click a button from within the web app to either download or - preferably - POST WebRtc logs to an endpoint baked into the app. The idea is that I can enable non-technical users to share technical logs with me through the click of a UI button.
How can this be achieved?
Note: This should not be dependent on Chrome; Chromium will also be used as the app will be wrapped up in Electron.
You need to write a javascript equivalent that captures all RTCPeerConnection API calls. rtcstats.js does that but sends all data to a server. If you replace that behaviour with storing it in memory you should be good.
This is what I ended up using (replace knockout with underscore or whatever):
connectionReport.signalingState = connection.signalingState;
connectionReport.stats = [];
connection.getStats(function (stats) {
const reportCollection = stats.result();
ko.utils.arrayForEach(reportCollection, function (innerReport) {
const statReport = {};
statReport.id = innerReport.id;
statReport.type = innerReport.type;
const keys = innerReport.names();
ko.utils.arrayForEach(keys, function (reportKey) {
statReport[reportKey] = innerReport.stat(reportKey);
})
connectionReport.stats.push(statReport);
});
connectionStats.push(connectionReport);
});
UPDATE:
It appears that this getStats mechanism is soon-to-be-deprecated.
Reading through js source of chrome://webrtc-internals, I noticed that the web page is using a method called chrome.send() to send messages like chrome.send('enableEventLogRecordings');, to execute logging commands.
According to here:
chrome.send() is a private function only available to internal chrome
pages.
so the function is sandboxed which makes accessing to it not possible

Windows Universal App - In App Purchases

I have been working (slowly) through the in app purchase example.
I have created 2 in app purchases in the Store for my app. I have linked Visual Studio to that app. I finally have not got any errors when I enter the callback function from requesting my in app purchases.
The error: It says there are 0 products when there should be 2.
My Code:
var ProductsARR = [];
var storeContext = Windows.Services.Store.StoreContext.getDefault();
var productKinds = ["Consumable", "Durable", "UnmanagedConsumable"];
storeContext.getAssociatedStoreProductsAsync(productKinds).then(function (addOns) {
var i;
if (addOns.extendedError) {
if (addOns.extendedError === (0x803f6107 | 0)) {
alert("This sample has not been properly configured.");
} else {
// The user may be offline or there might be some other server failure.
alert("ExtendedError: " + addOns.extendedError.toString());
}
} else if (addOns.products.size === 0) {
alert("No configured Add-ons found for this Store Product.");
} else {
for (i = 0; i < addOns.products.size;i++){
var item = {
title: addOns.products[i].title,
price: addOns.products[i].price.formattedPrice,
inCollection: addOns.products[i].isInUserCollection,
productKind: addOns.products[i].productKind,
storeId: addOns.products[i].storeId
};
ProductsARR .push(item);
}
}
});
What could be causing it to think there are no in app purchases where there are 2?
The only thing I think could be causing confusion is I have not submitted the actual xapproduct to the store yet, but I do not want to do that until I have fleshed out the rest of the code. I am working on the in app purchase code right now. Could that be causing the problem?
If not, what else could be causing the problem. It says in my dashboard that the in app purchase is 'In Store'.
You have to submit your products to the store. They go through a certification process and you should receive 2 emails stating something like "Your productX has been certified".
If you don't want this product to appear and only be available for Beta testing, make sure it's availability is set to "Hide this app in the Store".
Here's some info.
The only thing I think could be causing confusion is I have not
submitted the actual xapproduct to the store yet, but I do not want to
do that until I have fleshed out the rest of the code.
You're using Windows.Services.Store namespace, which doesn't provide a class that you can use to simulate license info during testing, unlike Windows.ApplicationModel.Store provding the CurrentAppSimulator class . So you must publish the app and download it to your development device to use its license for testing.
For testing purpose, this app doesn't need to be your real version but a basic app that meets minimum Windows App Certification Kit requirements. Also, you could choose to hide this app first to prevent customers from seeing your app during your test.
For more details about testing guidance, you might refer to Test your in-app purchase or trial implementation.

Meteor: Authenticating Chrome Extension via DDP

I've built a Chrome Extension that takes a selection of text and when I right click and choose the context menu item, it sends that text to my Meteor app. This works fine, however, I can't figure out the process of using Oauth to authenticate users.
I'm using this package: https://github.com/eddflrs/meteor-ddp
Here is the JS within background.js (for Chrome Extension):
var ddp = new MeteorDdp("ws://localhost:3000/websocket");
ddp.connect().then(function() {
ddp.subscribe("textSnippets");
chrome.runtime.onMessage.addListener(function(message) {
ddp.call('transferSnippet', ['snippetContent', 'tag', snippetString]);
});
});
Here is the relevant portion of my other JS file within my Chrome Extension:
function genericOnClick(info) {
snippetString = [];
snippetString.push(info.selectionText);
var snippetTag = prompt('tag this thing')
snippetString.push(snippetTag);
chrome.runtime.sendMessage(snippetString);
}
And here is the relevant portion of my Meteor app:
'transferSnippet': function(field1, field2, value1, value2) {
var quickObject = {};
quickObject.field1 = value1[0];
quickObject.field2 = value1[1];
TextSnippets.insert({
snippetContent: value1[0],
tag: value1[1]
});
}
Basically I'm stuck and don't know how to go about making a DDP call that will talk to my Meteor app in order to authenticate a user
This question is a bit old, but if anyone is still looking for a solution. I had a similar problem that I was able to solve using the following plugin: https://github.com/mondora/asteroid. Here is an example of how to do it for twitter oauth:
https://github.com/mondora/asteroid/issues/41#issuecomment-72334353

Adobe DPS Android Entitlement

We are stuck with an Adobe DPS project. We cant get our DPS android app to do Entitlement for our print subscribers and we were wondering if anyone out there has managed to get this right.
We've used Adobe's tutorial here:
http://www.adobe.com/devnet/digitalpublishingsuite/articles/library-store-combined-template.html, with isEntitlementViewer set to true.
The code asks for a username and password and then via Adobe's API AdobeLibraryAPI.js, it authenticates a user via our own API. the very same code is working 100% in the iPad version of the app.
The file that actually processes the login (called LoginDialog.js) contains the following code within a function called clickHandler (we’ve added a few javascript alerts to try debug the login process)
// Login using the authenticationService.
var transaction = adobeDPS.authenticationService.login($username.val(), $password.val());
alert("1: "+transaction.state ); //returns “1: 0”
transaction.completedSignal.addOnce(function(transaction) {
alert("2: "+transaction.state ); //never returns
var transactionStates = adobeDPS.transactionManager.transactionStates;
if (transaction.state == transactionStates.FAILED) {
$("#login .error").html("Authentication Failed.")
} else if (transaction.state == transactionStates.FINISHED){
this.$el.trigger("loginSuccess");
this.close();
}
alert("3: "+transaction.state ); //never returns
}, this);
alert("4: "+transaction.error ); //never returns
Anyone out there with some DPS/android/Entitlement experience?
Android Entitlement only works after an integrator ID is registered with Adobe, as the android viewers service routes are only configured via the integrator ID.
If you do not have an integrator ID, you need to acquire one from Adobe Support.
Also it is worth mentioning, that in contrary to iOS, Android DPS viewers only support one base Route/URL for Authentication and Entitlements.
For Example whereas in iOS you can have the login been done via the first URL:
https://example.com/api/v1/SignInWithCredentials
The second URL for entitlements can be on a different URL:
http://server2.example.com/v1/api/entitlements
In android both URLs have to be the same, e.g.:
https://example.com/api/v1/SignInWithCredentials and
https://example.com/api/v1/entitlements

chrome.management.getAll does not return Chrome Store's app data

I am now writing a new tab page replacement for Chrome 33.
While I am using chrome.management.getAll() to get app list, I found a strange thing.
Here is my code:
document.addEventListener('DOMContentLoaded', function () {
...
chrome.management.getAll(getAllApps);
...});
function getAllApps(data) {
...
console.log("Installed App Count:" + data.length);
for (var i = data.length - 1; i >= 0; i--) {
console.log("Found App: " + data[i].name + " type:" + data[i].type);
if (data[i].type == 'theme' ||
data[i].type == 'extension' ) {
continue;
};
...
}
}
The output never lists Chrome Store.
But if I use chrome.management.get(), I could get the record of Chrome Store by its id.
Is there anything wrong in my code? Or is the Store is intended to be hidden?
Thank you. It is my first question here, so if there is any inappropriate words in my question, please forgive me.
The Store app is a component extension. Those extensions are built in to Chrome, not installed. As you can see from the documentation, getAll() returns only the user's installed extensions.
Your best bet is to hardcode the list of extensions that appear in a brand-new profile, which will consist only of component items (unless you're on a machine you don't control). Over time that list will diverge from the canonical list in the source code.
Both chrome.management.get() and chrome.management.getAll() show information about apps/extensions/themes installed on local computer, not information from Chrome Web Store.

Categories

Resources