use of com.amazon.device.iap.PurchasingListener in project zype-firebuilder by zype.
the class AmazonInAppPurchase method createIapPurchasingListener.
/**
* Creates IAP purchase listener from PurchaseListener.
*/
/*package private*/
PurchasingListener createIapPurchasingListener(final PurchaseListener listener) {
Log.d(TAG, "PurchasingListener registered");
return new PurchasingListener() {
@Override
public void onUserDataResponse(UserDataResponse userDataResponse) {
Log.d(TAG, "UserDataResponse received " + userDataResponse.toString());
Response response = createResponse(isSuccessful(userDataResponse), userDataResponse.getRequestId().toString());
UserData userData = createUserDataFromIapUserData(userDataResponse.getUserData());
listener.onGetUserDataResponse(response, userData);
}
@Override
public void onProductDataResponse(ProductDataResponse productDataResponse) {
Log.d(TAG, "ProductDataResponse received " + productDataResponse.toString());
Response response = createResponse(isSuccessful(productDataResponse), productDataResponse.getRequestId().toString());
Map<String, Product> productMap = createProductMapFromProductDataResponse(productDataResponse.getProductData());
listener.onProductDataResponse(response, productMap, productDataResponse.getUnavailableSkus());
}
@Override
public void onPurchaseResponse(PurchaseResponse purchaseResponse) {
Log.d(TAG, "purchaseResponse received " + purchaseResponse.toString());
Response response = createResponse(isSuccessful(purchaseResponse), purchaseResponse.getRequestId().toString());
com.amazon.device.iap.model.Receipt iapReceipt = purchaseResponse.getReceipt();
String sku = null;
if (iapReceipt != null) {
sku = iapReceipt.getSku();
}
listener.onPurchaseResponse(response, sku, createReceipt(iapReceipt), createUserDataFromIapUserData(purchaseResponse.getUserData()));
}
@Override
public void onPurchaseUpdatesResponse(PurchaseUpdatesResponse purchaseUpdatesResponse) {
Log.d(TAG, "purchaseUpdatesResponse received " + purchaseUpdatesResponse.toString());
Response response = createResponse(isSuccessful(purchaseUpdatesResponse), purchaseUpdatesResponse.getRequestId().toString());
List<Receipt> receipts = createReceiptList(purchaseUpdatesResponse.getReceipts());
UserData userData = createUserDataFromIapUserData(purchaseUpdatesResponse.getUserData());
listener.onUserDataResponse(response, receipts, userData, purchaseUpdatesResponse.hasMore());
}
};
}
use of com.amazon.device.iap.PurchasingListener in project zype-firebuilder by zype.
the class AmazonInAppPurchase method registerDefaultPurchaseListener.
/**
* {@inheritDoc}
*/
@Override
public void registerDefaultPurchaseListener(PurchaseListener purchaseListener) {
this.mPurchaseListener = purchaseListener;
PurchasingListener iapListener = createIapPurchasingListener(purchaseListener);
PurchasingService.registerListener(mContext, iapListener);
Log.d(TAG, PurchasingService.IS_SANDBOX_MODE + "IS_SANDBOX_MODE");
}
use of com.amazon.device.iap.PurchasingListener in project zype-firebuilder by zype.
the class AmazonInAppPurchaseTest method testCreatePurchasingListener.
@Test
public void testCreatePurchasingListener() {
AmazonInAppPurchase purchase = new AmazonInAppPurchase();
IPurchase.PurchaseListener listener = mock(IPurchase.PurchaseListener.class);
PurchasingListener iapListener = purchase.createIapPurchasingListener(listener);
iapListener.onUserDataResponse(createUserDataResponse());
verify(listener).onGetUserDataResponse(any(Response.class), any(UserData.class));
iapListener.onProductDataResponse(createProductDataResponse());
verify(listener).onProductDataResponse(any(Response.class), Matchers.anyMapOf(String.class, com.amazon.purchase.model.Product.class), Matchers.anySetOf(String.class));
iapListener.onPurchaseResponse(createPurchaseResponse());
verify(listener).onPurchaseResponse(any(Response.class), any(String.class), any(Receipt.class), any(UserData.class));
iapListener.onPurchaseUpdatesResponse(createPurchaseUpdateResponse());
verify(listener).onUserDataResponse(any(Response.class), Matchers.anyListOf(Receipt.class), any(UserData.class), any(Boolean.class));
}
use of com.amazon.device.iap.PurchasingListener in project OneSignal-Android-SDK by OneSignal.
the class TrackAmazonPurchase method checkListener.
void checkListener() {
if (!canTrack)
return;
try {
PurchasingListener curPurchasingListener = (PurchasingListener) listenerHandlerField.get(listenerHandlerObject);
if (curPurchasingListener != osPurchasingListener) {
osPurchasingListener.orgPurchasingListener = curPurchasingListener;
setListener();
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
Aggregations