@Override
	public FREObject call(FREContext c, final FREObject[] args) {
		
		context = (InAppPurchaseExtensionContext) c;
		
		
		context.executeWithService(new Runnable() {
			@Override
			public void run() {
				String productId = null;
				String payload = null;
				Bundle buyIntentBundle = null;
				
				// Retrieving the desired product ID.
				try {
					productId = args[0].getAsString();
					payload = args[1].getAsString();
				}
				catch(Exception e) { 
					InAppPurchaseExtension.logToAS("Error while retrieving the product ID! " + e.toString()); 
					context.dispatchStatusEventAsync(InAppPurchaseMessages.PURCHASE_FAILURE, e.toString()); 
					return;
				}
				
				try {
					buyIntentBundle = context.getInAppBillingService().getBuyIntent(InAppPurchaseExtension.API_VERSION, context.getActivity().getPackageName(), productId, "inapp", payload);
				}
				catch(Exception e) { 
					InAppPurchaseExtension.logToAS("Error while the buy intent! " + e.toString()); 
					context.dispatchStatusEventAsync(InAppPurchaseMessages.PURCHASE_FAILURE, e.toString()); 
					return;
				}
				
				
				int responseCode = buyIntentBundle.getInt(RESPONSE_CODE);
				if(responseCode == BILLING_RESPONSE_RESULT_OK) {
					
					// Everything's fine, starting the buy intent.
					PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
					try {
						
						// Creates the new activity to do the billing process, and adding it the extra info to start the request.
						Intent intent = new Intent(context.getActivity(), BillingActivity.class);
						intent.putExtra("PENDING_INTENT", pendingIntent);
						intent.putExtra("REQUEST_CODE", BUY_REQUEST_CODE);
						intent.putExtra("DEV_PAYLOAD", payload);
						context.getActivity().startActivity(intent);
					}
					catch(Exception e) { 
						InAppPurchaseExtension.logToAS("Error while the buy intent!\n " + e.toString() + "\n" + InAppPurchaseExtension.getStackString(e));
						context.dispatchStatusEventAsync(InAppPurchaseMessages.PURCHASE_FAILURE, e.toString()); 
						return;
					}
				}
				else if(responseCode == BILLING_RESPONSE_RESULT_USER_CANCELED) {
					InAppPurchaseExtension.logToAS("User cancelled the purchase.");
					context.dispatchStatusEventAsync(InAppPurchaseMessages.PURCHASE_CANCELED, ""); 
				}
				else {
					InAppPurchaseExtension.logToAS("Error while the buy intent : " + ERRORS_MESSAGES.get(responseCode));
					context.dispatchStatusEventAsync(InAppPurchaseMessages.PURCHASE_FAILURE, ERRORS_MESSAGES.get(responseCode));
				}
			}
		});
		
		
		return null;
	}