Windows Universal App - In App Purchases - javascript

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.

Related

Canary release, how to simulate it with coding, if possible at all

I'm in a project where I am building a simulator of a website. I am testing how feature toggling can provide some cons that can help a team release more often than they do now.
One thing I do like to simulate is how the Canary release is working. Lets say I just finished building a new feature and I need to have it tested in production. Canary release is just to push this feature out to a small number of users.
How do you simulate this with code? I'm building the applikation with angular2 anad with typescript. Have created configurationfiles for the features that I can use.
How do you, lets say pick only 5 percents of random people that visit the site to test the specific feature? Is it all done with server configuration (running another build at a different server).
If any could make a code example of how I could simulate this when the application starts, I've be happy.
Have made this code myself:
var switchKey: string = localStorage.getItem('featureSwitch');
if (this.featureSwitch != null) {
if (switchKey == "11") {
this.featureSwitch = 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
}
else {
if (switchKey != null) {
if (switchKey == "11") {
this.featureSwitch = 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
else {
this.featureSwitch = Number(switchKey) + 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
}
else {
this.featureSwitch = 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
}
This is maybe a bad example, cause I don't think it will work on a live site (on the internet), this is only tested on a localhost server. Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.
Any have some ideas how I could do this easily?
Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.
You should do canary releases based on users (not browser sessions). Otherwise the user will be surprised as they switch browsers / devices / locations. And you will not know which users are participating in a test (a user can AND can't be in the test if they use two devices).
This needs server side support, the switch belongs in the server.

Smart card selection for digital signature

I am mantaining a VB6 Windows application which digitally signs PDF documents by launching a JS file, located in the Javascripts subfolder of Acrobat 9.0. Now my Customer wants to plug another smart card reader to the PC which hosts the application, with its own smart card containing certificates related to a second person who will sign certain type of documents.
My question is: how can I programmatically choose, from my JavaScript code, the smart card reader I want?
In my JavaScript code I do the following:
//Initialize the signature handler
var myEngine = security.getHandler("Adobe.PPKLite");
//Obtain the available certificates
var ids = myEngine.digitalIDs;
var myCerts = ids.certs;
//Find the certificate I want to use to sign
for(var j=0; j<myCerts.length; j++)
{
if(myCerts[j].subjectCN == "SMITH JOHN")
{
oCert = myCerts[j];
break;
}
}
//Log to the signature engine by passing the certificate I want to use
//and the slot where the corresponding smart card reader is plugged
myEngine.login( { oParams: { cDIPath: ACROSDK.sigDigitalIDPath,
cPassword: ACROSDK.sigUserPwd,
iSlotID: 1,
oEndUserSignCert: oCert
}
} );
//Digitally sign the document with the certificate I chose
sigField.signatureSign({oSig: myEngine,
bUI: false,
oInfo: { password: ACROSDK.sigUserPwd,
location: ACROSDK.sigLocation,
reason: ACROSDK.sigReason,
contactInfo: ACROSDK.sigContactInfo,
appearance: "FirmaRPPR"
}
});
Why do I receive a General Error when executing signatureSign? Which is the correct way to assign the iSlotID parameter when logging to the signature engine or, alternatively, the cTokenLabel parameter?
Thanks in advance for your help and suggestions!
Mind you, I have no experience in using Acrobat scripting, but in PKCS#11 slot id would refer to the id of the smart card reader connected to the computer, and token label would be assigned label to one of the smart carts in that slot/reader, which can vary from PKCS#11 implementation to another.
And the easiest way to find out the label of the PKCS#11 token would be to configure the PKCS#11 DLL you're using as a Security device in Firefox browser and see the label field in the configuration. But that would be just to get you going in the right direction.
You can write a short C program against the PKCS#11 and use C_GetSlotList and C_GetSlotInfo to find out the slot id's and token labels, here is an example of that. It should not be a problem to port that code over to VB. Also there is NCryptoki that you can use to interface the PKCS#11 DLL.

Chrome packaged app in-app payment api

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.

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