Tabnine Logo
com.aoindustries.creditcards
Code IndexAdd Tabnine to your IDE (free)

How to use com.aoindustries.creditcards

Best Java code snippets using com.aoindustries.creditcards (Showing top 20 results out of 315)

origin: com.aoindustries/ao-credit-cards-payflowPro

@Override
public SaleResult sale(TransactionRequest transactionRequest, CreditCard creditCard) {
  AuthorizationResult authorizationResult = authorizeOrSale(transactionRequest, creditCard, "S");
  return new SaleResult(
    authorizationResult,
    new CaptureResult(
      authorizationResult.getProviderId(),
      authorizationResult.getCommunicationResult(),
      authorizationResult.getProviderErrorCode(),
      authorizationResult.getErrorCode(),
      authorizationResult.getProviderErrorMessage(),
      authorizationResult.getProviderUniqueId()
    )
  );
}
origin: com.aoindustries/ao-credit-cards-stripe

private static Map<String,Object> makeCardParams(CreditCard creditCard, boolean update) {
  return makeCardParams(
    creditCard,
    update,
    creditCard.getCardNumber(),
    creditCard.getExpirationMonth(),
    creditCard.getExpirationYear(),
    creditCard.getCardCode()
  );
}
origin: com.aoindustries/ao-credit-cards-stripe

/** https://stripe.com/docs/api#update_customer */
private static void addCustomerParams(
  CreditCard creditCard,
  boolean update,
  Map<String,Object> customerParams
) {
  addParam(update, customerParams, "description", creditCard.getComments());
  addParam(update, customerParams, "email", creditCard.getEmail());
  addParam(update, customerParams, "metadata", makeMetadata(creditCard, update));
}
origin: com.aoindustries/ao-credit-cards-stripe

/**
 * Meta data contains both card meta data (also associated with "customer" for stored cards) and transaction meta data.
 * https://stripe.com/docs/api#create_charge
 */
private static Map<String,Object> makeMetadata(TransactionRequest transactionRequest, CreditCard creditCard, boolean update) {
  Map<String,Object> metadata = makeMetadata(creditCard, update);
  // Additional customer meta data
  addMetaData(update, metadata, "customer_description", creditCard.getComments(), true);
  addMetaData(update, metadata, "customer_email", creditCard.getEmail(), false);
  // Transaction meta data
  addMetaData(update, metadata, "customer_ip", transactionRequest.getCustomerIp(), false);
  addMetaData(update, metadata, "order_number", transactionRequest.getOrderNumber(), false);
  addMetaData(update, metadata, "amount", transactionRequest.getAmount(), false);
  addMetaData(update, metadata, "tax_amount", transactionRequest.getTaxAmount(), false);
  addMetaData(update, metadata, "tax_exempt", transactionRequest.getTaxExempt(), false);
  addMetaData(update, metadata, "shipping_amount", transactionRequest.getShippingAmount(), false);
  addMetaData(update, metadata, "duty_amount", transactionRequest.getDutyAmount(), false);
  addMetaData(update, metadata, "shipping_company_name", transactionRequest.getShippingCompanyName(), true);
  addMetaData(update, metadata, "invoice_number", transactionRequest.getInvoiceNumber(), false);
  addMetaData(update, metadata, "purchase_order_number", transactionRequest.getPurchaseOrderNumber(), false);
  return metadata;
}
origin: com.aoindustries/ao-credit-cards-stripe

/** https://stripe.com/docs/api#update_card */
private static void addCardParams(
  CreditCard creditCard,
  boolean update,
  Map<String,Object> cardParams
) {
  addParam(update, cardParams, "name", CreditCard.getFullName(creditCard.getFirstName(), creditCard.getLastName()));
  addParam(update, cardParams, "address_line1", creditCard.getStreetAddress1());
  addParam(update, cardParams, "address_line2", creditCard.getStreetAddress2());
  addParam(update, cardParams, "address_city", creditCard.getCity());
  addParam(update, cardParams, "address_zip", creditCard.getPostalCode());
  addParam(update, cardParams, "address_state", creditCard.getState());
  addParam(update, cardParams, "address_country", creditCard.getCountryCode());
}
origin: com.aoindustries/ao-credit-cards-stripe

/** https://stripe.com/docs/api#create_charge */
private static Map<String,Object> makeShippingAddressParams(TransactionRequest transactionRequest, boolean update) {
  Map<String,Object> shippingAddressParams = new HashMap<String,Object>();
  addParam(update, shippingAddressParams, "line1", transactionRequest.getShippingStreetAddress1());
  addParam(update, shippingAddressParams, "line2", transactionRequest.getShippingStreetAddress2());
  addParam(update, shippingAddressParams, "city", transactionRequest.getShippingCity());
  addParam(update, shippingAddressParams, "state", transactionRequest.getShippingState());
  addParam(update, shippingAddressParams, "postal_code", transactionRequest.getShippingPostalCode());
  addParam(update, shippingAddressParams, "country", transactionRequest.getShippingCountryCode());
  return shippingAddressParams;
}
origin: com.aoindustries/ao-credit-cards-stripe

/** https://stripe.com/docs/api#create_charge */
private static Map<String,Object> makeShippingParams(TransactionRequest transactionRequest, CreditCard creditCard, boolean update) {
  Map<String,Object> shippingParams = new HashMap<String,Object>();
  addParam(update, shippingParams, "address", makeShippingAddressParams(transactionRequest, update));
  addParam(update, shippingParams, "name", CreditCard.getFullName(transactionRequest.getShippingFirstName(), transactionRequest.getShippingLastName()));
  // Phone cannot be in the shipping by itself
  if(!shippingParams.isEmpty()) addParam(update, shippingParams, "phone", creditCard.getPhone());
  // Unused: tracking_number
  return shippingParams;
}
// </editor-fold>
origin: com.aoindustries/ao-credit-cards-stripe

/** https://stripe.com/docs/api#metadata */
private static Map<String,Object> makeMetadata(CreditCard creditCard, boolean update) {
  Map<String,Object> metadata = new LinkedHashMap<String,Object>();
  addMetaData(update, metadata, "company_name", creditCard.getCompanyName(), true);
  addMetaData(update, metadata, "phone", creditCard.getPhone(), true);
  addMetaData(update, metadata, "fax", creditCard.getFax(), true);
  addMetaData(update, metadata, "customer_id", creditCard.getCustomerId(), true);
  addMetaData(update, metadata, "customer_tax_id", creditCard.getCustomerTaxId(), true);
  return metadata;
}
origin: com.aoindustries/ao-credit-cards-authorizeNet

private static BigDecimal getAmount(TransactionRequest transactionRequest) {
  BigDecimal amount = transactionRequest.getAmount();
  BigDecimal taxAmount = transactionRequest.getTaxAmount();
  if(taxAmount!=null) amount = amount.add(taxAmount);
  BigDecimal shippingAmount = transactionRequest.getShippingAmount();
  if(shippingAmount!=null) amount = amount.add(shippingAmount);
  BigDecimal dutyAmount = transactionRequest.getDutyAmount();
  if(dutyAmount!=null) amount = amount.add(dutyAmount);
  return amount;
}
origin: com.aoindustries/ao-credit-cards-test

  TransactionResult.ErrorCode[] values = TransactionResult.ErrorCode.values();
  TransactionResult.ErrorCode errorCode = values[random.nextInt(values.length)];
  return new CaptureResult(
    getProviderId(),
    communicationResult,
    null,
    errorCode,
    null,
    authorizationResult.getProviderUniqueId()
  );
return new CaptureResult(
  getProviderId(),
  TransactionResult.CommunicationResult.SUCCESS,
  null,
  null,
  null,
  authorizationResult.getProviderUniqueId()
);
origin: com.aoindustries/ao-credit-cards-stripe

@Override
public CaptureResult capture(AuthorizationResult authorizationResult) {
  String id = authorizationResult.getProviderUniqueId();
  try {
    authorizationResult.getProviderUniqueId();
    Charge ch = Charge.retrieve(id, options);
    ch.capture(options);
    return new CaptureResult(
      providerId,
      TransactionResult.CommunicationResult.SUCCESS,
      null,
      null,
      null,
      id
    );
  } catch(StripeException e) {
    ConvertedError converted = convertError(e);
    return new CaptureResult(
      providerId,
      converted.communicationResult,
      converted.providerErrorCode,
      converted.errorCode,
      converted.providerErrorMessage,
      id
    );
  }
}
origin: com.aoindustries/ao-credit-cards-test

  TransactionResult.ErrorCode[] values = TransactionResult.ErrorCode.values();
  TransactionResult.ErrorCode errorCode = values[random.nextInt(values.length)];
  return new VoidResult(
    getProviderId(),
    communicationResult,
    null,
    errorCode,
    null,
    transaction.getAuthorizationResult().getProviderUniqueId()
  );
return new VoidResult(
  getProviderId(),
  TransactionResult.CommunicationResult.SUCCESS,
  null,
  null,
  null,
  transaction.getAuthorizationResult().getProviderUniqueId()
);
origin: com.aoindustries/ao-credit-cards-sagePayments

@Override
public void deleteCreditCard(CreditCard creditCard) throws IOException {
  try {
    boolean success = new WsVaultLocator().getwsVaultSoap().DELETE_DATA(
      emptyStringIfNull(merchantId),
      emptyStringIfNull(merchantKey),
      emptyStringIfNull(creditCard.getProviderUniqueId())
    );
    if(!success) throw new LocalizedIOException(accessor, "MerchantServicesProvider.deleteCreditCard.notSuccessful");
  } catch(ServiceException err) {
    throw new IOException(err);
  } catch(RemoteException err) {
    throw new IOException(err);
  }
}
origin: com.aoindustries/ao-credit-cards-stripe

private static Map<String,Object> makeCardParams(
  CreditCard creditCard,
  boolean update,
  String cardNumber,
  byte expirationMonth,
  short expirationYear,
  String cardCode
) {
  Map<String,Object> cardParams = new HashMap<String,Object>();
  addParam(update, cardParams, "number", CreditCard.numbersOnly(cardNumber));
  addParam(update, cardParams, "exp_month", expirationMonth);
  addParam(update, cardParams, "exp_year", expirationYear);
  addParam(update, cardParams, "cvc", cardCode);
  addCardParams(creditCard, update, cardParams);
  return cardParams;
}
origin: com.aoindustries/ao-credit-cards-stripe

  @Override
  public void deleteCreditCard(CreditCard creditCard) throws IOException {
    try {
      Customer customer = Customer.retrieve(creditCard.getProviderUniqueId(), options);
      if(customer.getDeleted() == null || !customer.getDeleted()) {
        DeletedCustomer deletedCustomer = customer.delete(options);
      }
    } catch(StripeException e) {
      ConvertedError converted = convertError(e);
      // TODO: Throw ErrorCodeException to provide more details
      throw new LocalizedIOException(e, accessor, "MerchantServicesProvider.deleteCreditCard.notSuccessful");
    }
  }
}
origin: com.aoindustries/ao-credit-cards-usaepay

/**
 * Adds a parameter to the request after checking its length.
 * If longer, throws an ErrorCodeException with the provided <code>TransactionResult.ErrorCode</code>, otherwise appends the value.
 */
protected static void addMaxLengthParameter(Map<String,String> request, String name, String value, int maxLength, TransactionResult.ErrorCode errorCode) throws ErrorCodeException {
  if(value.length()>maxLength) {
    throw new ErrorCodeException(
      errorCode,
      "TransactionRequest.field.tooLong",
      name,
      maxLength
    );
  }
  request.put(name, value);
}
origin: com.aoindustries/ao-credit-cards-stripe

@Override
public SaleResult sale(TransactionRequest transactionRequest, CreditCard creditCard) {
  AuthorizationResult authorizationResult = saleOrAuthorize(transactionRequest, creditCard, true);
  return new SaleResult(
    authorizationResult,
    new CaptureResult(
      authorizationResult.getProviderId(),
      authorizationResult.getCommunicationResult(),
      authorizationResult.getProviderErrorCode(),
      authorizationResult.getErrorCode(),
      authorizationResult.getProviderErrorMessage(),
      authorizationResult.getProviderUniqueId()
    )
  );
}
origin: com.aoindustries/ao-credit-cards-authorizeNet

@Override
public SaleResult sale(TransactionRequest transactionRequest, CreditCard creditCard) {
  AuthorizationResult authorizationResult = authorizeOrSale(transactionRequest, creditCard, "AUTH_CAPTURE");
  return new SaleResult(
    authorizationResult,
    new CaptureResult(
      authorizationResult.getProviderId(),
      authorizationResult.getCommunicationResult(),
      authorizationResult.getProviderErrorCode(),
      authorizationResult.getErrorCode(),
      authorizationResult.getProviderErrorMessage(),
      authorizationResult.getProviderUniqueId()
    )
  );
}
origin: com.aoindustries/ao-credit-cards-usaepay

@Override
public SaleResult sale(TransactionRequest transactionRequest, CreditCard creditCard) {
  AuthorizationResult authorizationResult = authorizeOrSale(transactionRequest, creditCard, "sale");
  return new SaleResult(
    authorizationResult,
    new CaptureResult(
      authorizationResult.getProviderId(),
      authorizationResult.getCommunicationResult(),
      authorizationResult.getProviderErrorCode(),
      authorizationResult.getErrorCode(),
      authorizationResult.getProviderErrorMessage(),
      authorizationResult.getProviderUniqueId()
    )
  );
}
origin: com.aoindustries/ao-credit-cards-sagePayments

@Override
public SaleResult sale(TransactionRequest transactionRequest, CreditCard creditCard) {
  AuthorizationResult authorizationResult = saleOrAuthorize(transactionRequest, creditCard, true);
  return new SaleResult(
    authorizationResult,
    new CaptureResult(
      authorizationResult.getProviderId(),
      authorizationResult.getCommunicationResult(),
      authorizationResult.getProviderErrorCode(),
      authorizationResult.getErrorCode(),
      authorizationResult.getProviderErrorMessage(),
      authorizationResult.getProviderUniqueId()
    )
  );
}
com.aoindustries.creditcards

Most used classes

  • AuthorizationResult
  • CaptureResult
  • CreditCard
  • SaleResult
  • TransactionRequest
  • ErrorCodeException,
  • Transaction,
  • VoidResult,
  • AuthorizationResult$DeclineReason,
  • AuthorizeNet,
  • PayflowPro,
  • SagePayments,
  • BANKCARD_AUTHONLY,
  • BANKCARD_AUTHONLYResponse,
  • BANKCARD_AUTHONLYResponseBANKCARD_AUTHONLYResult,
  • BANKCARD_CREDIT,
  • BANKCARD_CREDITResponse,
  • BANKCARD_CREDITResponseBANKCARD_CREDITResult,
  • BANKCARD_CREDIT_OR_REFUND
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now