private void consumePurchase(String packageName, String token) { try { int consumeResponse = inAppBillingService.consumePurchase( IN_APP_PURCHASE_VERSION, packageName, token); if (consumeResponse == 0) { Log.d(TAG, "Successfully consumed package: " + packageName); } else { Log.d(TAG, "Faileds to consume package: " + packageName + " " + consumeResponse); } } catch (RemoteException e) { Log.e(TAG, "Consuming purchase remote exception.", e); } }
if (transaction != null && !TextUtils.isEmpty(transaction.purchaseToken)) int response = billingService.consumePurchase(Constants.GOOGLE_API_VERSION, contextPackageName, transaction.purchaseToken);
@Override void start(@Nonnull IInAppBillingService service, @Nonnull String packageName) throws RemoteException, RequestException { final int response = service.consumePurchase(mApiVersion, packageName, mToken); if (!handleError(response)) { Billing.waitGooglePlay(); onSuccess(new Object()); } }
@Test public void testShouldError() throws Exception { final Request request = newRequest(); final RequestListener l = mock(RequestListener.class); request.setListener(l); final Bundle bundle = newBundle(BILLING_UNAVAILABLE); final IInAppBillingService service = mock(IInAppBillingService.class); when(service.isBillingSupported(anyInt(), anyString(), anyString())).thenReturn(BILLING_UNAVAILABLE); when(service.consumePurchase(anyInt(), anyString(), anyString())).thenReturn(BILLING_UNAVAILABLE); when(service.getPurchases(anyInt(), anyString(), anyString(), anyString())).thenReturn(bundle); when(service.getPurchaseHistory(anyInt(), anyString(), anyString(), anyString(), any(Bundle.class))).thenReturn(bundle); when(service.getSkuDetails(anyInt(), anyString(), anyString(), any(Bundle.class))).thenReturn(bundle); when(service.getBuyIntent(anyInt(), anyString(), anyString(), anyString(), anyString())).thenReturn(bundle); request.start(service, "testse"); verify(l).onError(eq(BILLING_UNAVAILABLE), any(Exception.class)); verify(l, never()).onSuccess(any()); }
@Test public void testShouldSuccess() throws Exception { final Request r = newRequest(); final RequestListener l = mock(RequestListener.class); r.setListener(l); final IInAppBillingService service = mock(IInAppBillingService.class); when(service.isBillingSupported(anyInt(), anyString(), anyString())).thenReturn(OK); when(service.consumePurchase(anyInt(), anyString(), anyString())).thenReturn(OK); final Bundle purchases = new Bundle(); purchases.putStringArrayList("INAPP_PURCHASE_DATA_LIST", new ArrayList<String>()); when(service.getPurchases(anyInt(), anyString(), anyString(), anyString())).thenReturn(purchases); when(service.getPurchaseHistory(anyInt(), anyString(), anyString(), anyString(), any(Bundle.class))).thenReturn(purchases); final Bundle skuDetails = new Bundle(); skuDetails.putStringArrayList("DETAILS_LIST", new ArrayList<String>()); when(service.getSkuDetails(anyInt(), anyString(), anyString(), any(Bundle.class))).thenReturn(skuDetails); final Bundle buyIntent = new Bundle(); buyIntent.putParcelable("BUY_INTENT", PendingIntent.getActivity(RuntimeEnvironment.application, 100, new Intent(), 0)); when(service.getBuyIntent(anyInt(), anyString(), anyString(), anyString(), anyString())).thenReturn(buyIntent); r.start(service, ""); verify(l).onSuccess(anyObject()); verify(l, never()).onError(anyInt(), any(Exception.class)); }
int response = mService.consumePurchase(3, mContext.getPackageName(), token); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Successfully consumed sku: " + sku);
@Override public boolean consumeSku(@NonNull String purchaseToken) { try { final int response = service.consumePurchase(3, packageName, purchaseToken); return response == BILLING_RESPONSE_RESULT_OK; } catch (RemoteException ignore) { } return false; }
private int consumePurchaseToken(String token) throws RemoteException { return billingService().consumePurchase(BILLING_API_VERSION, installerPackageName, token); } }
public Response consumePurchase(String purchaseToken) throws RemoteException { ReactiveBilling.log(null, "Consume purchase - request (thread %s)", Thread.currentThread().getName()); int response = billingService.consumePurchase(BillingService.API_VERSION, context.getPackageName(), purchaseToken); ReactiveBilling.log(null, "Consume purchase - response: %d", response); return new Response(response); }
@Test public void shouldCancelTestPurchaseWhenCancellingTestPurchases() throws Exception { activityBindAndConnect(); whenGetPurchasesRequestReturn(purchasesResponseOneTransactionFullEditionSandboxOrder()); v3InAppbillingService.cancelTestPurchases(); verify(nativeInAppBillingService).getPurchases(BILLING_API_VERSION, PACKAGE_NAME_GOOD, PURCHASE_TYPE_IN_APP, null); verify(nativeInAppBillingService).consumePurchase(eq(BILLING_API_VERSION), eq(PACKAGE_NAME_GOOD), anyString()); }
@Override public void onBind(IInAppBillingService service) { try { checkIfBillingIsSupported(PurchaseType.IN_APP, service); String token = getToken(service, itemId); int response = service.consumePurchase( mContext.getApiVersion(), mContext.getContext().getPackageName(), token ); if (response != Constants.BILLING_RESPONSE_RESULT_OK) { throw new BillingException(response, Constants.ERROR_MSG_CONSUME); } postConsumePurchaseSuccess(handler); } catch (BillingException e) { postOnError(e, handler); } catch (RemoteException e) { postOnError(new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage()), handler); } }
int response = mService.consumePurchase(3, mContext.getPackageName(), token); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Successfully consumed sku: " + sku);
int response = mService.consumePurchase(3, mContext.getPackageName(), token); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Successfully consumed sku: " + sku);
int response = mService.consumePurchase(3, mContext.getPackageName(), token); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Successfully consumed sku: " + sku);
int response = mService.consumePurchase(3, mContext.getPackageName(), token); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Successfully consumed sku: " + sku);
int response = mService.consumePurchase(3, mContext.getPackageName(), token); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Successfully consumed sku: " + sku);
int response = mService.consumePurchase(API_VERSION, mContext.getPackageName(), token); if (response == OK.code) { logDebug("Successfully consumed sku: " + sku);
int response = mService.consumePurchase(API_VERSION, mContext.getPackageName(), token); if (response == OK.code) { logDebug("Successfully consumed sku: " + sku);