コード例 #1
0
  private void checkForTaxExemption(
      final Invoice invoice,
      final Collection<PluginProperty> properties,
      final TenantContext context) {
    // Overridden by plugin properties?
    if (PluginProperties.findPluginPropertyValue(
            AvaTaxTaxCalculator.CUSTOMER_USAGE_TYPE, properties)
        != null) {
      return;
    }

    final List<CustomField> customFields =
        killbillAPI
            .getCustomFieldUserApi()
            .getCustomFieldsForObject(invoice.getAccountId(), ObjectType.ACCOUNT, context);
    final CustomField customField =
        Iterables.<CustomField>tryFind(
                customFields,
                new Predicate<CustomField>() {
                  @Override
                  public boolean apply(final CustomField customField) {
                    return AvaTaxTaxCalculator.CUSTOMER_USAGE_TYPE.equals(
                        customField.getFieldName());
                  }
                })
            .orNull();

    if (customField != null) {
      properties.add(
          new PluginProperty(
              AvaTaxTaxCalculator.CUSTOMER_USAGE_TYPE, customField.getFieldValue(), false));
    }
  }
コード例 #2
0
 private void addTaxCodeToInvoiceItem(
     final UUID invoiceItemId, final String taxCode, final Collection<PluginProperty> properties) {
   final String pluginPropertyName =
       String.format("%s_%s", AvaTaxTaxCalculator.TAX_CODE, invoiceItemId);
   // Already in plugin properties?
   if (PluginProperties.findPluginPropertyValue(pluginPropertyName, properties) == null) {
     properties.add(new PluginProperty(pluginPropertyName, taxCode, false));
   }
 }
  public static PaymentInfo toPaymentInfo(
      @Nullable final AccountData account,
      final AdyenConfigProperties configuration,
      final Clock clock,
      final Iterable<PluginProperty> properties) {
    final WebPaymentFrontend paymentInfo = new WebPaymentFrontend();

    final String propertyShipBeforeDate =
        PluginProperties.findPluginPropertyValue(PROPERTY_SHIP_BEFORE_DATE, properties);
    final DateTime shipBeforeDateTime =
        propertyShipBeforeDate == null
            ? clock.getUTCNow().plusHours(1)
            : new DateTime(propertyShipBeforeDate);
    paymentInfo.setShipBeforeDate(shipBeforeDateTime.toString("yyyy-MM-dd"));

    String countryCode = PluginProperties.getValue(PROPERTY_COUNTRY, null, properties);
    if (countryCode == null && account != null) {
      countryCode = account.getCountry();
    }
    final String skinCode =
        PluginProperties.getValue(
            PROPERTY_SKIN_CODE, configuration.getSkin(countryCode), properties);
    paymentInfo.setSkinCode(skinCode);

    final String orderData =
        PluginProperties.findPluginPropertyValue(PROPERTY_ORDER_DATA, properties);
    paymentInfo.setOrderData(orderData);

    final String sessionValidity =
        PluginProperties.getValue(
            PROPERTY_SESSION_VALIDITY,
            clock.getUTCNow().plusMinutes(15).toString("yyyy-MM-dd'T'HH:mm:ssZZ"),
            properties);
    paymentInfo.setSessionValidity(sessionValidity);

    final String merchantReturnData =
        PluginProperties.findPluginPropertyValue(PROPERTY_MERCHANT_RETURN_DATA, properties);
    paymentInfo.setMerchantReturnData(merchantReturnData);

    final String allowedMethods =
        PluginProperties.findPluginPropertyValue(PROPERTY_ALLOWED_METHODS, properties);
    paymentInfo.setAllowedMethods(allowedMethods);

    final String blockedMethods =
        PluginProperties.findPluginPropertyValue(PROPERTY_BLOCKED_METHODS, properties);
    paymentInfo.setBlockedMethods(blockedMethods);

    final String brandCode =
        PluginProperties.getValue(
            PROPERTY_BRAND_CODE, configuration.getHppVariantOverride(), properties);
    paymentInfo.setBrandCode(brandCode);

    final String issuerId =
        PluginProperties.findPluginPropertyValue(PROPERTY_ISSUER_ID, properties);
    paymentInfo.setIssuerId(issuerId);

    final String offerEmail =
        PluginProperties.findPluginPropertyValue(PROPERTY_OFFER_EMAIL, properties);
    paymentInfo.setOfferEmail(offerEmail);

    final String serverUrl =
        PluginProperties.findPluginPropertyValue(PROPERTY_SERVER_URL, properties);
    final String resultUrl =
        PluginProperties.findPluginPropertyValue(PROPERTY_RESULT_URL, properties);
    paymentInfo.setResURL(Strings.nullToEmpty(serverUrl) + Strings.nullToEmpty(resultUrl));

    return paymentInfo;
  }