09-26-2011 01:57 AM
Hi All,
I am using payment api 1.5 which was released recently by rim. But i am getting exeption like this unable to athunicate payment service. I am attaching the code please have a look once
/** * */ package com.id.Test; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.FieldChangeListener; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.ButtonField; import net.rim.device.api.ui.component.Dialog; import net.rim.device.api.ui.container.MainScreen; import net.rimlib.blackberry.api.paymentsdk.AppWorldUpdateRequired; import net.rimlib.blackberry.api.paymentsdk.ExistingPurch asesResult; import net.rimlib.blackberry.api.paymentsdk.PaymentEngine ; import net.rimlib.blackberry.api.paymentsdk.PaymentExcept ion; import net.rimlib.blackberry.api.paymentsdk.Purchase; import net.rimlib.blackberry.api.paymentsdk.PurchaseArgum entsBuilder; /** * @author K.Sandeep Sagar * */ public class PaymentScreen extends MainScreen { /** * */ public PaymentScreen() { ButtonField prevPurchaesField = new ButtonField("Get Purchases", ButtonField.CONSUME_CLICK); add(prevPurchaesField); prevPurchaesField.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { // engine.setConnectionMode(PaymentEngine.CONNECTION_ MODE_LOCAL); UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { final PaymentEngine engine = PaymentEngine .getInstance(); if (engine != null) { try { // Purchase purchase = engine.purchase(arguments // .build()); ExistingPurchasesResult purchase = engine .getExistingPurchases(true); Dialog.inform("Purchase of " + purchase.isSuccessful() + " is successful."); } catch (PaymentException e) { Dialog.inform(e.getMessage()); } } } }); } }); ButtonField buyField1 = new ButtonField("Buy", ButtonField.CONSUME_CLICK); add(buyField1); buyField1.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { PaymentEngine engine = PaymentEngine.getInstance(); try { PaymentEngine.isAppWorldInstalledAndAtCorrectVersi on(); } catch (AppWorldUpdateRequired e1) { PaymentEngine.upDateAppWorld(); e1.printStackTrace(); } PurchaseArgumentsBuilder arguments = new PurchaseArgumentsBuilder() .withDigitalGoodSku("abc123") .withDigitalGoodName( "Adventures of a BlackBerry Java Developer") .withPurchasingAppName("My eBooks") .withMetadata("ISBN 34560202010"); try { engine.checkExisting("abc123"); } catch (AppWorldUpdateRequired e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (PaymentException e1) { // TODO Auto-generated catch block Dialog.inform(e1.getMessage()); } if (engine != null) { try { Purchase purchase = engine.purchase(arguments .build()); // Purchase[] purchase = engine // .getExistingPurchases(true); Dialog.inform("Purchase of " + purchase.getTransactionId() + " is successful."); } catch (PaymentException e) { Dialog.inform(e.getMessage()); } } } }); } }); } }
Please help me how to provide subscriptions for applictions.
Thank you......
09-26-2011 06:04 AM
/** * */ package com.id.Test; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.FieldChangeListener; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.ButtonField; import net.rim.device.api.ui.component.Dialog; import net.rim.device.api.ui.container.MainScreen; import net.rimlib.blackberry.api.paymentsdk.AppWorldUpdateRequired; import net.rimlib.blackberry.api.paymentsdk.ExistingPurch asesResult; import net.rimlib.blackberry.api.paymentsdk.PaymentEngine ; import net.rimlib.blackberry.api.paymentsdk.PaymentExcept ion; import net.rimlib.blackberry.api.paymentsdk.Purchase; import net.rimlib.blackberry.api.paymentsdk.PurchaseArgum entsBuilder; /** * @author K.Sandeep Sagar * */ public class PaymentScreen extends MainScreen { /** * */ public PaymentScreen() { ButtonField prevPurchaesField = new ButtonField("Get Purchases", ButtonField.CONSUME_CLICK); add(prevPurchaesField); prevPurchaesField.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { // engine.setConnectionMode(PaymentEngine.CONNECTION_ MODE_LOCAL); UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { final PaymentEngine engine = PaymentEngine .getInstance(); if (engine != null) { try { // Purchase purchase = engine.purchase(arguments // .build()); ExistingPurchasesResult purchase = engine .getExistingPurchases(true); Dialog.inform("Purchase of " + purchase.isSuccessful() + " is successful."); } catch (PaymentException e) { Dialog.inform(e.getMessage()); } } } }); } }); ButtonField buyField1 = new ButtonField("Buy", ButtonField.CONSUME_CLICK); add(buyField1); buyField1.setChangeListener(new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { PaymentEngine engine = PaymentEngine.getInstance(); try { PaymentEngine .isAppWorldInstalledAndAtCorrectVersion(); } catch (AppWorldUpdateRequired e1) { PaymentEngine.upDateAppWorld(); e1.printStackTrace(); } PurchaseArgumentsBuilder arguments = new PurchaseArgumentsBuilder() .withDigitalGoodSku("abc123") .withDigitalGoodName( "Adventures of a BlackBerry Java Developer") .withPurchasingAppName("My eBooks") .withMetadata("ISBN 34560202010"); try { engine.checkExisting("abc123"); } catch (AppWorldUpdateRequired e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (PaymentException e1) { // TODO Auto-generated catch block Dialog.inform(e1.getMessage()); } if (engine != null) { try { Purchase purchase = engine.purchase(arguments .build()); // Purchase[] purchase = engine // .getExistingPurchases(true); Dialog.inform("Purchase of " + purchase.getTransactionId() + " is successful."); } catch (PaymentException e) { Dialog.inform(e.getMessage()); } } } }); } }); } }
09-26-2011 06:06 AM
/**
*
*/
package com.id.Test;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
import net.rimlib.blackberry.api.paymentsdk.AppWorldUpdat
import net.rimlib.blackberry.api.paymentsdk.ExistingPurch
import net.rimlib.blackberry.api.paymentsdk.PaymentEngine
import net.rimlib.blackberry.api.paymentsdk.PaymentExcept
import net.rimlib.blackberry.api.paymentsdk.Purchase;
import net.rimlib.blackberry.api.paymentsdk.PurchaseArgum
/**
* @author K.Sandeep Sagar
*
*/
public class PaymentScreen extends MainScreen {
/**
*
*/
public PaymentScreen() {
ButtonField prevPurchaesField = new ButtonField("Get Purchases",
ButtonField.CONSUME_CLICK);
add(prevPurchaesField);
prevPurchaesField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
// engine.setConnectionMode(PaymentEngine.CONNECTION_
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
final PaymentEngine engine = PaymentEngine
.getInstance();
if (engine != null) {
try {
// Purchase purchase = engine.purchase(arguments
// .build());
ExistingPurchasesResult purchase = engine
.getExistingPurchases(true);
Dialog.inform("Purchase of "
+ purchase.isSuccessful()
+ " is successful.");
} catch (PaymentException e) {
Dialog.inform(e.getMessage());
}
}
}
});
}
});
ButtonField buyField1 = new ButtonField("Buy",
ButtonField.CONSUME_CLICK);
add(buyField1);
buyField1.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
PaymentEngine engine = PaymentEngine.getInstance();
try {
PaymentEngine
.isAppWorldInstalledAndAtCorrectVersion();
} catch (AppWorldUpdateRequired e1) {
PaymentEngine.upDateAppWorld();
e1.printStackTrace();
}
PurchaseArgumentsBuilder arguments = new PurchaseArgumentsBuilder()
.withDigitalGoodSku("abc123")
.withDigitalGoodName(
"Adventures of a BlackBerry Java Developer")
.withPurchasingAppName("My eBooks")
.withMetadata("ISBN 34560202010");
try {
engine.checkExisting("abc123");
} catch (AppWorldUpdateRequired e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (PaymentException e1) {
// TODO Auto-generated catch block
Dialog.inform(e1.getMessage());
}
if (engine != null) {
try {
Purchase purchase = engine.purchase(arguments
.build());
// Purchase[] purchase = engine
// .getExistingPurchases(true);
Dialog.inform("Purchase of "
+ purchase.getTransactionId()
+ " is successful.");
} catch (PaymentException e) {
Dialog.inform(e.getMessage());
}
}
}
});
}
});
}
}