Handle a callback that purchases were updated from the Billing library
437073
@Override
	// TODO This is executed for each client connected. Should we have only one client connected?
	// TODO Call queryPurchases() at least twice in your code:
	// - Every time your app launches so that you can restore any purchases that a user has made since the app last stopped.
	// - In your onResume() method because a user can make a purchase when your app is in the background (for example, redeeming a promo code in Play Store app).
	// Calling queryPurchases() on startup and resume guarantees that your app finds out about all purchases and redemptions
	// the user may have made while the app wasn't running. Furthermore, if a user makes a purchase while the app is running
	// and your app misses it for any reason, your app still finds out about the purchase the next time the activity resumes and calls queryPurchases().
	// The simplest approach is to call queryPurchases() in your activity's onResume() method, since that callback fires
	// when the activity is created, as well as when the activity is unpaused.
	public void onPurchasesUpdated(@BillingClient.BillingResponse int resultCode, @Nullable List<Purchase> purchases) {
		InAppBillingErrorCode inAppBillingErrorCode = InAppBillingErrorCode.findByErrorResponseCode(resultCode);
		if (inAppBillingErrorCode == null) {
			if (purchases != null) {
				for (Purchase purchase : purchases) {
					String productId = purchase.getSku();
					Product product = inventory.getProduct(productId);
					try {
						if (product != null) {
							product.setPurchase(signatureBase64, purchase.getOriginalJson(), purchase.getSignature(), InAppBillingAppModule.get().getDeveloperPayloadVerificationStrategy());
							InAppBillingAppModule.get().getInAppBillingContext().addPurchasedProductType(product.getProductType());
							
							// TODO Add logic here to see if we are replacing the same purchase. If yes, dont track
							InAppBillingAppModule.get().getModuleAnalyticsSender().trackInAppBillingPurchase(product);
							
							if (listener != null) {
								listener.onPurchaseFinished(product);
							}
							if (product.isWaitingToConsume()) {
								consume(product);
							} else if (listener != null) {
								listener.onProvideProduct(product);
							}
						} else {
							AbstractApplication.get().getExceptionHandler().logWarningException(
									"The purchased product [" + productId + "] is not supported by the app, so it is ignored");
						}
					} catch (ErrorCodeException e) {
						AbstractApplication.get().getExceptionHandler().logHandledException(e);
						if (listener != null) {
							listener.onPurchaseFailed(e);
						}
					} catch (JSONException e) {
						AbstractApplication.get().getExceptionHandler().logHandledException(e);
						if (listener != null) {
							listener.onPurchaseFailed(InAppBillingErrorCode.BAD_PURCHASE_DATA.newErrorCodeException(e));
						}
					}
				}
			}
		} else if (inAppBillingErrorCode.equals(InAppBillingErrorCode.USER_CANCELED)) {
			LOGGER.warn("User cancelled the purchase flow.");
			if (listener != null) {
				listener.onPurchaseFailed(InAppBillingErrorCode.USER_CANCELED.newErrorCodeException("User cancelled the purchase flow."));
			}
		} else {
			AbstractApplication.get().getExceptionHandler().logHandledException(inAppBillingErrorCode.newErrorCodeException());
			if (listener != null) {
				listener.onPurchaseFailed(inAppBillingErrorCode.newErrorCodeException("Purchase failed."));
			}
			
		}
	}
1031905
def update(self, category_id, data, store_view=None):
        
        return bool(
            self.call(
                'catalog_category.update', [category_id, data, store_view]
            )
        )
447992
protected function updatePaymentTransaction(PaymentTransaction $paymentTransaction, CallbackResponse $callbackResponse)
    {
        $paymentTransaction->setStatus($callbackResponse->getStatus());
        $paymentTransaction->getPayment()->setPaynetId($callbackResponse->getPaymentPaynetId());

        if ($callbackResponse->isError() || $callbackResponse->isDeclined())
        {
            $paymentTransaction->addError($callbackResponse->getError());
        }
    }
1034474
def retry(self):
		

		if not self.paid and not self.forgiven and not self.closed:
			stripe_invoice = self.api_retrieve()
			updated_stripe_invoice = (
				stripe_invoice.pay()
			)  # pay() throws an exception if the charge is not successful.
			type(self).sync_from_stripe_data(updated_stripe_invoice)
			return True
		return False
1244866
private List<InvoiceItem> processRecurringEvent(final UUID invoiceId, final UUID accountId, final BillingEvent thisEvent, @Nullable final BillingEvent nextEvent,
                                                    final LocalDate targetDate, final Currency currency,
                                                    final InvoiceItemGeneratorLogger invoiceItemGeneratorLogger, final BillingMode billingMode,
                                                    final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDate,
                                                    final InternalCallContext internalCallContext) throws InvoiceApiException {

        try {
            final List<InvoiceItem> items = new ArrayList<InvoiceItem>();

            // For FIXEDTERM phases we need to stop when the specified duration has been reached
            final LocalDate maxEndDate = thisEvent.getPlanPhase().getPhaseType() == PhaseType.FIXEDTERM ?
                                         thisEvent.getPlanPhase().getDuration().addToLocalDate(internalCallContext.toLocalDate(thisEvent.getEffectiveDate())) :
                                         null;

            // Handle recurring items
            final BillingPeriod billingPeriod = thisEvent.getBillingPeriod();
            if (billingPeriod != BillingPeriod.NO_BILLING_PERIOD) {
                final LocalDate startDate = internalCallContext.toLocalDate(thisEvent.getEffectiveDate());

                if (!startDate.isAfter(targetDate)) {
                    final LocalDate endDate = (nextEvent == null) ? null : internalCallContext.toLocalDate(nextEvent.getEffectiveDate());

                    final int billCycleDayLocal = thisEvent.getBillCycleDayLocal();

                    final RecurringInvoiceItemDataWithNextBillingCycleDate itemDataWithNextBillingCycleDate;
                    try {
                        itemDataWithNextBillingCycleDate = generateInvoiceItemData(startDate, endDate, targetDate, billCycleDayLocal, billingPeriod, billingMode);
                    } catch (final InvalidDateSequenceException e) {
                        throw new InvoiceApiException(ErrorCode.INVOICE_INVALID_DATE_SEQUENCE, startDate, endDate, targetDate);
                    }
                    for (final RecurringInvoiceItemData itemDatum : itemDataWithNextBillingCycleDate.getItemData()) {

                        // Stop if there a maxEndDate and we have reached it
                        if (maxEndDate != null && maxEndDate.compareTo(itemDatum.getEndDate()) < 0) {
                            break;
                        }

                        final BigDecimal rate = thisEvent.getRecurringPrice(internalCallContext.toUTCDateTime(itemDatum.getStartDate()));
                        if (rate != null) {
                            final BigDecimal amount = KillBillMoney.of(itemDatum.getNumberOfCycles().multiply(rate), currency);
                            final RecurringInvoiceItem recurringItem = new RecurringInvoiceItem(invoiceId,
                                                                                                accountId,
                                                                                                thisEvent.getBundleId(),
                                                                                                thisEvent.getSubscriptionId(),
                                                                                                thisEvent.getPlan().getProduct().getName(),
                                                                                                thisEvent.getPlan().getName(),
                                                                                                thisEvent.getPlanPhase().getName(),
                                                                                                itemDatum.getStartDate(),
                                                                                                itemDatum.getEndDate(),
                                                                                                amount, rate, currency);
                            items.add(recurringItem);
                        }
                    }
                    updatePerSubscriptionNextNotificationDate(thisEvent.getSubscriptionId(), itemDataWithNextBillingCycleDate.getNextBillingCycleDate(), items, billingMode,
                                                              perSubscriptionFutureNotificationDate);
                }
            }

            // For debugging purposes
            invoiceItemGeneratorLogger.append(thisEvent, items);

            return items;
        } catch (final CatalogApiException e) {
            throw new InvoiceApiException(e);
        }
    }
221647
function() {
      delete self._requestState[transactionId];
      self._localMap.add(nbname, group, address, ttl, self._type);
      self._sendRefresh(nbname, function(error) {
        if (typeof callback === 'function') {
          callback(error, !error);
        }
      });
    }
1081016
function _callback(changed_keys) {
      if (intersection(keys_to_watch_for_changes, changed_keys).length) {
        // only update the state if a key we care about has changed
        var state_update_obj = {};
        keys_to_watch_for_changes.forEach(function (k) {
          return state_update_obj[k] = store._store[k];
        });
        this.setState(state_update_obj);

        // if some other custom callback is required by the component
        // call that function as well
        if (additonal_callback) {
          additonal_callback(changed_keys);
        }
      }
    }
1211966
public void getPurchaseInfo(PurchaseInfoRequest request, GetPurchaseInfoHandler handler) {
        HMSAgentLog.i("getPurchaseInfo:request=" + StrUtils.objDesc(request) + "  handler=" + StrUtils.objDesc(handler));
        this.purchaseInfoReq = request;
        this.handler = handler;
        this.retryTimes = MAX_RETRY_TIMES;
        connect();
    }
954126
def on(self, evt, func):
        ''''''
        if evt not in self._callbacks:
            raise NotImplementedError('callback "%s"' % evt)
        else:
            self._callbacks[evt] = func
1205716
def payment_status_changed_listener(sender, instance, old_status, new_status, **kwargs):
    
    logger.debug("payment_status_changed_listener, old=%s, new=%s", old_status,
                 new_status)
    if old_status != 'paid' and new_status == 'paid':
        # Ensures that we process order only one
        instance.order.status = 'P'
        instance.order.save()
1144402
function updateCallback(that) {
        var i;
        that.status = GameTimer.RUNNING;
        that.timePassed += that.update;
        that.timeLeft -= that.update;
        that.updateStart = J.now();
        // Fire custom hooks from the latest to the first if any.
        for (i = that.hooks.length; i > 0; i--) {
            that.fire(that.hooks[(i-1)]);
        }
        // Fire Timeup Event
        if (that.timeLeft <= 0) {
            that.doTimeup();
            return false;
        }
        else {
            return true;
        }
    }
912589
def update_refund(self, refund_id, refund_deets):
        """"""
        request = self._put('transactions/refunds/' + str(refund_id), refund_deets)
        return self.responder(request)
1055778
function (transaction) {
	    if (this._pendingElement != null) {
	      ReactReconciler.receiveComponent(this, this._pendingElement, transaction, this._context);
	    } else if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
	      this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
	    } else {
	      this._updateBatchNumber = null;
	    }
	  }
1234763
function onPagePulled() {

        // For incremental pull, make a note of the lastKnownUpdatedAt in the store
        if (pullQueryId) {
            return store.upsert(pulltimeTableName, {
                id: pullQueryId,
                tableName: pagePullQuery.getComponents().table,
                value: lastKnownUpdatedAt
            });
        }
    }
262807
def fetch(self, refund_id, data={}, **kwargs):
        "
        return super(Refund, self).fetch(refund_id, data, **kwargs)
1191746
function() {
    const changed_keys = store._changed_keys
    if (changed_keys.length === 0) {
      console.error('no keys were changed, yet we are trying to publish a store change')
      return
    }

    // make sure _changed_keys is reset before executing callbacks
    // (if callbacks modify state, the list of keys the callback changed would be wiped out)
    store._changed_keys = []
    store._clearDebounceTimeout()
    store._callback_objs.forEach(obj => obj.callback(changed_keys))
  }
14511
private void afterBeginCallback() {
		if ( this.timeOut > 0 ) {
			owner.setTransactionTimeOut( this.timeOut );
		}
		owner.afterTransactionBegin();
		for ( TransactionObserver observer : observers ) {
			observer.afterBegin();
		}
		log.trace( "ResourceLocalTransactionCoordinatorImpl#afterBeginCallback" );
	}