@Override
    public void run() {
      CreateCustomerProfileResponse response = null;
      CreateCustomerPaymentProfileResponse paymentProfileResponse = null;

      try {
        response =
            (CreateCustomerProfileResponse)
                CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail());
        paymentProfileResponse =
            (CreateCustomerPaymentProfileResponse)
                CreateCustomerPaymentProfile.run(
                    apiLoginId, transactionKey, response.getCustomerProfileId());
      } catch (Exception e) {
        System.out.println("Failure in CIM calls.");
        System.out.println(e.getMessage());
        return;
      }

      try {
        Date dt1 = new Date();
        System.out.println(
            "============================================================================");
        System.out.println("chargeResponse Dt1: + " + dt1.toString());

        if ((response.getCustomerProfileId() != null)
            && (paymentProfileResponse.getCustomerPaymentProfileId() != null)) {
          CreateTransactionResponse chargeResponse =
              (CreateTransactionResponse)
                  ChargeCustomerProfile.run(
                      apiLoginId,
                      transactionKey,
                      response.getCustomerProfileId(),
                      paymentProfileResponse.getCustomerPaymentProfileId(),
                      getAmount());
        } else {
          System.out.println("NULL PROFILE IDS.");
        }

        Date dt2 = new Date();
        System.out.println("chargeResponse Dt2: + " + dt2.toString());

        long difference = dt2.getTime() - dt1.getTime();
        System.out.println("chargeResponse Diff: " + difference / 1000);
        System.out.println(
            "============================================================================");
      } catch (Exception e) {
        System.out.println("Failure in charge customer profile call:");
        System.out.println(e.getMessage());
      }
    }
Ejemplo n.º 2
0
  private static void RunMethod(String methodName) {
    // These are default transaction keys.
    // You can create your own keys in seconds by signing up for a sandbox account here:
    // https://developer.authorize.net/sandbox/
    String apiLoginId = "5KP3u95bQpv";
    String transactionKey = "4Ktq966gC55GAX7S";

    String TransactionAmount;
    String TransactionID;

    String RefID;
    String SubscriptionID;

    Scanner user_input = new Scanner(System.in);

    switch (methodName) {
      case "AuthorizeCreditCard":
        AuthorizeCreditCard.main(apiLoginId, transactionKey);
        break;
      case "CaptureOnly":
        CaptureOnly.main(apiLoginId, transactionKey);
        break;
      case "CapturePreviouslyAuthorizedAmount":
        System.out.println("Enter An Transaction Amount : ");
        TransactionAmount = user_input.next();

        System.out.println("Enter An Transaction ID : ");
        TransactionID = user_input.next();

        CapturePreviouslyAuthorizedAmount.main(
            apiLoginId, transactionKey, TransactionAmount, TransactionID);
        break;
      case "RefundTransaction":
        System.out.println("Enter An Transaction Amount : ");
        TransactionAmount = user_input.next();

        System.out.println("Enter An Transaction ID : ");
        TransactionID = user_input.next();

        RefundTransaction.main(apiLoginId, transactionKey, TransactionAmount, TransactionID);
        break;
      case "ChargeCreditCard":
        ChargeCreditCard.main(apiLoginId, transactionKey);
        break;
      case "ChargeCustomerProfile":
        ChargeCustomerProfile.main(apiLoginId, transactionKey);
        break;
      case "ChargeTokenizedCreditCard":
        ChargeTokenizedCreditCard.main(apiLoginId, transactionKey);
        break;
      case "CreditBankAccount":
        CreditBankAccount.main(apiLoginId, transactionKey);
        break;
      case "DebitBankAccount":
        DebitBankAccount.main(apiLoginId, transactionKey);
        break;
      case "VoidTransaction":
        VoidTransaction.main(apiLoginId, transactionKey);
        break;
      case "CancelSubscription":
        System.out.println("Enter An RefID : ");
        RefID = user_input.next();

        System.out.println("Enter An Subscription ID : ");
        SubscriptionID = user_input.next();

        CancelSubscription.main(apiLoginId, transactionKey, RefID, SubscriptionID);
        break;
      case "CreateSubscription":
        System.out.println("Enter An RefID : ");
        RefID = user_input.next();

        CreateSubscription.main(apiLoginId, transactionKey, RefID);
        break;
      case "GetListSubscription":
        System.out.println("Enter An RefID : ");
        RefID = user_input.next();

        System.out.println("Enter An Subscription ID : ");
        SubscriptionID = user_input.next();

        GetListSubscription.main(apiLoginId, transactionKey, RefID, SubscriptionID);
        break;
      case "GetSubscriptionStatus":
        System.out.println("Enter An RefID : ");
        RefID = user_input.next();

        System.out.println("Enter An Subscription ID : ");
        SubscriptionID = user_input.next();

        GetSubscriptionStatus.main(apiLoginId, transactionKey, RefID, SubscriptionID);
        break;
      case "UpdateSubscription":
        System.out.println("Enter An RefID : ");
        RefID = user_input.next();

        System.out.println("Enter An Subscription ID : ");
        SubscriptionID = user_input.next();

        UpdateSubscription.main(apiLoginId, transactionKey, RefID, SubscriptionID);
        break;
      case "GetBatchStatistics":
        GetBatchStatistics.main(apiLoginId, transactionKey);
        break;
      default:
        break;
    }

    user_input.close();
  }