Search in sources :

Example 41 with InvalidParameterException

use of java.security.InvalidParameterException in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSession method getCustomerDetails.

/**
 * Gets the CustomerDetails from the GC gateway
 *
 * @param productId, the productId for which you want to look up customerDetails
 * @param countryCode, the country of the customer
 * @param values, the
 */
public void getCustomerDetails(Context context, String productId, CountryCode countryCode, List<KeyValuePair> values, OnCustomerDetailsCallCompleteListener listener) {
    if (context == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, context may not be null");
    }
    if (productId == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, productId may not be null");
    }
    if (countryCode == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, countryCode may not be null");
    }
    if (values == null) {
        throw new InvalidParameterException("Error getting CustomerDetails, values may not be null");
    }
    CustomerDetailsAsyncTask task = new CustomerDetailsAsyncTask(context, productId, countryCode, values, communicator, listener);
    task.execute();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) CustomerDetailsAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.CustomerDetailsAsyncTask)

Example 42 with InvalidParameterException

use of java.security.InvalidParameterException in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSession method convertAmount.

/**
 * Converts a given amount in cents from the given source currency to the given target currency
 *
 * @param amount,   the amount in cents to be converted
 * @param source,   source currency
 * @param target,   target currency
 * @param context,  needed for reading metadata
 * @param listener, listener which will be called by the AsyncTask
 */
public void convertAmount(Long amount, String source, String target, Context context, OnAmountConvertedListener listener) {
    if (amount == null) {
        throw new InvalidParameterException("Error converting amount, amount may not be null");
    }
    if (source == null) {
        throw new InvalidParameterException("Error converting amount, source may not be null");
    }
    if (target == null) {
        throw new InvalidParameterException("Error converting amount, target may not be null");
    }
    if (context == null) {
        throw new InvalidParameterException("Error converting amount, context may not be null");
    }
    if (listener == null) {
        throw new InvalidParameterException("Error converting amount, listener may not be null");
    }
    ConvertAmountAsyncTask task = new ConvertAmountAsyncTask(amount, source, target, context, communicator, listener);
    task.execute();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) ConvertAmountAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.ConvertAmountAsyncTask)

Example 43 with InvalidParameterException

use of java.security.InvalidParameterException in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSession method getIinDetails.

/**
 * Gets the IinDetails for a given partialCreditCardNumber
 *
 * @param context, used for reading device metada which is send to the GC gateway
 * @param partialCreditCardNumber, entered partial creditcardnumber for which the IinDetails will be retrieved
 * @param listener, listener which will be called by the AsyncTask when the IIN result is retrieved
 * @param paymentContext, payment information for which the IinDetails will be retrieved
 */
public void getIinDetails(Context context, String partialCreditCardNumber, OnIinLookupCompleteListener listener, PaymentContext paymentContext) {
    if (context == null) {
        throw new InvalidParameterException("Error getting iinDetails, context may not be null");
    }
    if (partialCreditCardNumber == null) {
        throw new InvalidParameterException("Error getting iinDetails, productId may not be null");
    }
    if (listener == null) {
        throw new InvalidParameterException("Error getting iinDetails, listener may not be null");
    }
    // Add OnPaymentProductsCallComplete listener and this class to list of listeners so we can reset the iinLookupPending flag
    List<OnIinLookupCompleteListener> listeners = new ArrayList<OnIinLookupCompleteListener>();
    listeners.add(this);
    listeners.add(listener);
    if (!iinLookupPending) {
        IinLookupAsyncTask task = new IinLookupAsyncTask(context, partialCreditCardNumber, communicator, listeners, paymentContext);
        task.execute();
        iinLookupPending = true;
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) OnIinLookupCompleteListener(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask.OnIinLookupCompleteListener) ArrayList(java.util.ArrayList) IinLookupAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.IinLookupAsyncTask)

Example 44 with InvalidParameterException

use of java.security.InvalidParameterException in project connect-sdk-client-android by Ingenico-ePayments.

the class RenderCurrency method renderField.

@Override
public View renderField(PaymentProductField field, InputDataPersister inputDataPersister, ViewGroup rowView, PaymentContext paymentContext) {
    if (field == null) {
        throw new InvalidParameterException("Error rendering currency, field may not be null");
    }
    if (inputDataPersister == null) {
        throw new InvalidParameterException("Error rendering currency, inputDataPersister may not be null");
    }
    if (rowView == null) {
        throw new InvalidParameterException("Error rendering currency, rowView may not be null");
    }
    if (paymentContext == null) {
        throw new InvalidParameterException("Error rendering currency, paymentContext may not be null");
    }
    PaymentItem paymentItem = inputDataPersister.getPaymentItem();
    // Create new EditText and set its style, restrictions, mask and keyboardtype
    EditText integerPart = new EditText(rowView.getContext());
    // maxlength is 9 - 2 so no integer overflow
    integerPart.setFilters(new InputFilter[] { new InputFilter.LengthFilter(7) });
    Translator translator = Translator.getInstance(rowView.getContext());
    String label = translator.getPaymentProductFieldLabel(paymentItem.getId(), field.getId());
    integerPart.setHint(label);
    // Set correct inputType type
    switch(field.getDisplayHints().getPreferredInputType()) {
        case INTEGER_KEYBOARD:
            integerPart.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
            break;
        case STRING_KEYBOARD:
            integerPart.setInputType(android.text.InputType.TYPE_CLASS_TEXT);
            break;
        case PHONE_NUMBER_KEYBOARD:
            integerPart.setInputType(android.text.InputType.TYPE_CLASS_PHONE);
            break;
        case EMAIL_ADDRESS_KEYBOARD:
            integerPart.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
            break;
        default:
            integerPart.setInputType(android.text.InputType.TYPE_CLASS_TEXT);
            break;
    }
    // Check if this edittext should be obfuscated
    if (field.getDisplayHints().isObfuscate()) {
        integerPart.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
    // Set values from account on file
    if (inputDataPersister.getAccountOnFile() != null) {
        for (KeyValuePair attribute : inputDataPersister.getAccountOnFile().getAttributes()) {
            if (attribute.getKey().equals(field.getId())) {
                StringFormatter stringFormatter = new StringFormatter();
                String maskedValue = stringFormatter.applyMask(field.getDisplayHints().getMask().replace("9", "*"), attribute.getValue());
                integerPart.setText(maskedValue);
                if (!attribute.isEditingAllowed()) {
                    integerPart.setEnabled(false);
                }
            }
        }
    }
    LinearLayout linearLayout = new LinearLayout(rowView.getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    TextView currencySymbol = new TextView(rowView.getContext());
    currencySymbol.setText(paymentContext.getAmountOfMoney().getCurrencyCode().toString());
    TextView separator = new TextView(rowView.getContext());
    String separatorLabel = translator.getPaymentProductFieldLabel(paymentItem.getId(), "separator");
    separator.setText(separatorLabel);
    EditText decimalPart = new EditText(rowView.getContext());
    decimalPart.setHint("00");
    decimalPart.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
    decimalPart.setFilters(new InputFilter[] { new InputFilter.LengthFilter(2) });
    integerPart.addTextChangedListener(new FieldInputTextWatcherCurrency(inputDataPersister, field.getId(), decimalPart, true));
    decimalPart.addTextChangedListener(new FieldInputTextWatcherCurrency(inputDataPersister, field.getId(), integerPart, false));
    // Restore data that has previously been entered in this field
    if (inputDataPersister.getValue(field.getId()) != null) {
        String value = inputDataPersister.getValue(field.getId());
        if (value.length() > 2) {
            integerPart.setText(value.substring(0, value.length() - 2));
        }
        if (!value.endsWith("00")) {
            decimalPart.setText(value.substring(value.length() - 2));
        }
    }
    LinearLayout.LayoutParams params0 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0f);
    linearLayout.addView(currencySymbol, params0);
    LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f);
    linearLayout.addView(integerPart, params1);
    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0f);
    linearLayout.addView(separator, params2);
    LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0f);
    linearLayout.addView(decimalPart, params3);
    // Add it to parentView
    rowView.addView(linearLayout);
    return linearLayout;
}
Also used : EditText(android.widget.EditText) InputFilter(android.text.InputFilter) LayoutParams(android.view.ViewGroup.LayoutParams) KeyValuePair(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair) PaymentItem(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentItem) StringFormatter(com.globalcollect.gateway.sdk.client.android.sdk.formatter.StringFormatter) InvalidParameterException(java.security.InvalidParameterException) Translator(com.globalcollect.gateway.sdk.client.android.exampleapp.translation.Translator) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 45 with InvalidParameterException

use of java.security.InvalidParameterException in project connect-sdk-client-android by Ingenico-ePayments.

the class RenderList method renderField.

@Override
public View renderField(PaymentProductField field, InputDataPersister inputDataPersister, ViewGroup rowView, PaymentContext paymentContext) {
    if (field == null) {
        throw new InvalidParameterException("Error rendering list, field may not be null");
    }
    if (inputDataPersister == null) {
        throw new InvalidParameterException("Error rendering list, inputDataPersister may not be null");
    }
    if (rowView == null) {
        throw new InvalidParameterException("Error rendering list, rowView may not be null");
    }
    this.field = field;
    this.inputDataPersister = inputDataPersister;
    // Create new spinner and fill its values
    Spinner spinner = new Spinner(rowView.getContext());
    // Parse the loaded values to array and set as ArrayAdapter
    values = new ArrayList<>();
    // Fill values
    for (ValueMap valueMap : field.getDisplayHints().getFormElement().getValueMapping()) {
        values.add(getDisplayNameFromDisplayElements(valueMap.getDisplayElements()));
    }
    // Make and set adapter to spinner
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(rowView.getContext(), android.R.layout.simple_spinner_item, values);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter);
    // Set the spinner to the stored value in the account
    if (inputDataPersister.getAccountOnFile() != null) {
        for (KeyValuePair attribute : inputDataPersister.getAccountOnFile().getAttributes()) {
            if (attribute.getKey().equals(field.getId())) {
                int spinnerPosition = dataAdapter.getPosition(attribute.getValue());
                spinner.setSelection(spinnerPosition);
                if (!attribute.isEditingAllowed()) {
                    spinner.setEnabled(false);
                }
            }
        }
    }
    // is redrawn (i.e. when the user turns the phone)
    if (inputDataPersister.getValue(field.getId()) != null) {
        int spinnerPosition = dataAdapter.getPosition(inputDataPersister.getValue(field.getId()));
        spinner.setSelection(spinnerPosition);
    }
    // Add this as listener for this inputfield
    spinner.setOnItemSelectedListener(this);
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    rowView.addView(spinner, params);
    return spinner;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) LayoutParams(android.widget.LinearLayout.LayoutParams) KeyValuePair(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.KeyValuePair) Spinner(android.widget.Spinner) ValueMap(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.ValueMap) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)280 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)24 ActionEvent (com.cloud.event.ActionEvent)22 SecureRandom (java.security.SecureRandom)19 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)18 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)16 File (java.io.File)16 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)15 FirewallRule (com.cloud.network.rules.FirewallRule)14 DB (com.cloud.utils.db.DB)14 Map (java.util.Map)14 HashMap (java.util.HashMap)12 MalformedURLException (java.net.MalformedURLException)11 Paint (android.graphics.Paint)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)8 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)8 HttpURLConnection (java.net.HttpURLConnection)8 Scanner (java.util.Scanner)8