当前位置: 首页>>代码示例>>Java>>正文


Java CreditCard类代码示例

本文整理汇总了Java中io.card.payment.CreditCard的典型用法代码示例。如果您正苦于以下问题:Java CreditCard类的具体用法?Java CreditCard怎么用?Java CreditCard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CreditCard类属于io.card.payment包,在下文中一共展示了CreditCard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import io.card.payment.CreditCard; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == CARDIO_REQUEST_ID) {
        if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
            CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

            cardNumber.getEditText().setText(scanResult.getFormattedCardNumber());
            if (scanResult.isExpiryValid()) {
                String month = String.valueOf(scanResult.expiryMonth).length() == 1 ? "0" + scanResult.expiryMonth : String.valueOf(scanResult.expiryMonth);
                String year = String.valueOf(scanResult.expiryYear).substring(2);
                expiryInputLayout.getEditText().setText(month + "/" + year);
            }

            if (scanResult.cvv != null) {
                // Never log or display a CVV
                cvvInputLayout.getEditText().setText(scanResult.cvv);
            }

        }
    }
}
 
开发者ID:aksalj,项目名称:africastalking-android,代码行数:23,代码来源:Cuhn.java

示例2: onActivityResult

import io.card.payment.CreditCard; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
  Log.i(TAG,"Activity Result" + requestCode + " result Code " + resultCode);
  if (REQUEST_CARD_SCAN == requestCode) {
        if (resultCode == CardIOActivity.RESULT_CARD_INFO) {
            CreditCard scanResult = null;
            if (intent.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
                scanResult = intent
                        .getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);
                //this.callbackContext.success(this.toJSONObject(scanResult));
                Log.i(TAG,"Scan Result: " + this.toJSONObject(scanResult));
                this.promise.resolve(this.toJSONObject(scanResult).toString());
            } else {
              this.promise.reject("card was scanned but no result");
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            this.promise.reject("card scan cancelled");
        } else {
            this.promise.reject(Integer.toString(resultCode));
        }
    }
}
 
开发者ID:card-io,项目名称:react-native-card-io,代码行数:23,代码来源:ReactCardIOModule.java

示例3: toJSONObject

import io.card.payment.CreditCard; //导入依赖的package包/类
private JSONObject toJSONObject(CreditCard card) {
    JSONObject scanCard = new JSONObject();
    try {
        scanCard.put("cardType", card.getCardType());
        scanCard.put("redactedCardNumber", card.getRedactedCardNumber());
        scanCard.put("cardNumber", card.cardNumber);
        scanCard.put("expiryMonth", card.expiryMonth);
        scanCard.put("expiryYear", card.expiryYear);
        scanCard.put("cvv", card.cvv);
        scanCard.put("postalCode", card.postalCode);
    } catch (JSONException e) {
        scanCard = null;
    }

    return scanCard;
}
 
开发者ID:card-io,项目名称:react-native-card-io,代码行数:17,代码来源:ReactCardIOModule.java

示例4: handleCardIOResponse

import io.card.payment.CreditCard; //导入依赖的package包/类
@SuppressLint("DefaultLocale")
public void handleCardIOResponse(Intent data) {
    if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
        CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

        if (mCardNumberRequired) {
            mCardNumber.setText(scanResult.cardNumber);
            mCardNumber.focusNextView();
        }

        if (scanResult.isExpiryValid() && mExpirationRequired) {
            mExpiration.setText(String.format("%02d%d", scanResult.expiryMonth, scanResult.expiryYear));
            mExpiration.focusNextView();
        }
    }
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:17,代码来源:CardForm.java

示例5: onActivityResult

import io.card.payment.CreditCard; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
        case REQUEST_CODE_SCAN_CARD: {
            if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
                CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

                String expiryDate = "";
                if (scanResult.isExpiryValid()) {
                    expiryDate = String.format("%d/%d", scanResult.expiryMonth, scanResult.expiryYear);
                }
                updateCardNumber(scanResult.cardNumber, expiryDate);
            }
            break;
        }
    }
}
 
开发者ID:jjhesk,项目名称:EZWebView,代码行数:20,代码来源:CardIoDemoFragment.java

示例6: onActivityResult

import io.card.payment.CreditCard; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PaymentFormActivity.SCAN_REQUEST_CODE) {

        if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
            CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

            mCardNumber.setFilters( new InputFilter[] { new InputFilter.LengthFilter(Integer.MAX_VALUE)});
            mCardNumber.setText(scanResult.getFormattedCardNumber());

            if (scanResult.isExpiryValid()) {

                String expiryYear = String.valueOf(scanResult.expiryYear);
                if (expiryYear.length() == 4 && TextUtils.isDigitsOnly(expiryYear)) {

                    mCardExpiration.setText(scanResult.expiryMonth + "/" + expiryYear.substring(2,4));
                }
            }
        }
        else {

            //no-op, scan was canceled.
        }
    }
}
 
开发者ID:hipay,项目名称:hipay-fullservice-sdk-android,代码行数:29,代码来源:TokenizableCardPaymentFormFragment.java

示例7: onActivityResult

import io.card.payment.CreditCard; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {

        /**
         * Credit card scanner, this is coming from {@link #onPayButtonCreditCard()}
         */
        case MY_SCAN_REQUEST_CODE:
            String number = "";
            String expMonth = "";
            String expYear = "";

            if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
                CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

                number = scanResult.getFormattedCardNumber();
                expMonth = String.valueOf(scanResult.expiryMonth);
                expYear = String.valueOf(scanResult.expiryYear);


            } else {
                Toast.makeText(this, "scan cancel", Toast.LENGTH_SHORT).show();

            }

            // Pass the data again with credit card information to OpenSalesPayButtonIntentService
            OpenSalesPayButtonIntentService.insertNewData(this, qqOldHeaderKey, qqUserUid, qqSalesHeaderModel, qqSalesDetailModelList, number, expMonth+"/"+expYear, qqCashPaid, qqChangeCash);

            finish();
            break;
    }

}
 
开发者ID:Hishmad,项目名称:stockita-point-of-sale,代码行数:36,代码来源:OpenSalesDetailActivity.java

示例8: handleCardIOResponse_setsCardNumber

import io.card.payment.CreditCard; //导入依赖的package包/类
@Test
public void handleCardIOResponse_setsCardNumber() {
    setRequiredFields(true, true, false, false, false);
    Intent intent = new Intent()
            .putExtra(CardIOActivity.EXTRA_SCAN_RESULT, new CreditCard(VISA, 0, 0, "", "", ""));

    mCardForm.handleCardIOResponse(intent);

    assertEquals(VISA, ((EditText) mActivity.findViewById(R.id.bt_card_form_card_number)).getText().toString());
    assertTrue(mCardForm.findViewById(R.id.bt_card_form_expiration).hasFocus());
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:12,代码来源:CardFormTest.java

示例9: handleCardIOResponse_doesNotSetCardNumberIfCardNumberNotRequired

import io.card.payment.CreditCard; //导入依赖的package包/类
@Test
public void handleCardIOResponse_doesNotSetCardNumberIfCardNumberNotRequired() {
    setRequiredFields(false, true, true, true, true);
    Intent intent = new Intent()
            .putExtra(CardIOActivity.EXTRA_SCAN_RESULT, new CreditCard(VISA, 0, 0, "", "", ""));

    mCardForm.handleCardIOResponse(intent);

    assertEquals("", ((EditText) mActivity.findViewById(R.id.bt_card_form_card_number)).getText().toString());
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:11,代码来源:CardFormTest.java

示例10: handleCardIOResponse_setsExpirationDate

import io.card.payment.CreditCard; //导入依赖的package包/类
@Test
public void handleCardIOResponse_setsExpirationDate() {
    setRequiredFields(false, true, true, false, false);
    Intent intent = new Intent()
            .putExtra(CardIOActivity.EXTRA_SCAN_RESULT, new CreditCard(VISA, 12, 2020, "", "", ""));

    mCardForm.handleCardIOResponse(intent);

    assertEquals("122020", ((EditText) mActivity.findViewById(R.id.bt_card_form_expiration)).getText().toString());
    assertTrue(mCardForm.findViewById(R.id.bt_card_form_cvv).hasFocus());
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:12,代码来源:CardFormTest.java

示例11: handleCardIOResponse_handlesSingleDigitExpirationMonths

import io.card.payment.CreditCard; //导入依赖的package包/类
@Test
public void handleCardIOResponse_handlesSingleDigitExpirationMonths() {
    setRequiredFields(false, true, true, false, false);
    Intent intent = new Intent()
            .putExtra(CardIOActivity.EXTRA_SCAN_RESULT, new CreditCard(VISA, 7, 2020, "", "", ""));

    mCardForm.handleCardIOResponse(intent);

    assertEquals("07", ((ExpirationDateEditText) mActivity.findViewById(R.id.bt_card_form_expiration)).getMonth());
    assertEquals("2020", ((ExpirationDateEditText) mActivity.findViewById(R.id.bt_card_form_expiration)).getYear());
    assertTrue(mCardForm.findViewById(R.id.bt_card_form_cvv).hasFocus());
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:13,代码来源:CardFormTest.java

示例12: handleCardIOResponse_doesNotSetExpirationDateIfExpirationDateInvalid

import io.card.payment.CreditCard; //导入依赖的package包/类
@Test
public void handleCardIOResponse_doesNotSetExpirationDateIfExpirationDateInvalid() {
    setRequiredFields(true, true, false, false, false);
    Intent intent = new Intent()
            .putExtra(CardIOActivity.EXTRA_SCAN_RESULT, new CreditCard(VISA, 12, 2000, "", "", ""));

    mCardForm.handleCardIOResponse(intent);

    assertEquals("", ((EditText) mActivity.findViewById(R.id.bt_card_form_expiration)).getText().toString());
    assertTrue(mCardForm.findViewById(R.id.bt_card_form_expiration).hasFocus());
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:12,代码来源:CardFormTest.java

示例13: handleCardIOResponse_doesNotSetExpirationDateIfExpirationDateNotRequired

import io.card.payment.CreditCard; //导入依赖的package包/类
@Test
public void handleCardIOResponse_doesNotSetExpirationDateIfExpirationDateNotRequired() {
    setRequiredFields(true, false, true, false, false);
    Intent intent = new Intent()
            .putExtra(CardIOActivity.EXTRA_SCAN_RESULT, new CreditCard(VISA, 12, 2020, "", "", ""));

    mCardForm.handleCardIOResponse(intent);

    assertEquals("", ((EditText) mActivity.findViewById(R.id.bt_card_form_expiration)).getText().toString());
    assertTrue(mCardForm.findViewById(R.id.bt_card_form_cvv).hasFocus());
}
 
开发者ID:braintree,项目名称:android-card-form,代码行数:12,代码来源:CardFormTest.java

示例14: onActivityResult

import io.card.payment.CreditCard; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE_CARD_IO) {
        if (data == null || !data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
            return;
        }

        CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);
        applyCardIOResult(scanResult);

    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:omise,项目名称:omise-android,代码行数:15,代码来源:CreditCardActivity.java

示例15: applyCardIOResult

import io.card.payment.CreditCard; //导入依赖的package包/类
private void applyCardIOResult(CreditCard data) {
    EditText numberField = views.editText(R.id.edit_card_number);
    EditText nameField = views.editText(R.id.edit_card_name);
    EditText securityCodeField = views.editText(R.id.edit_security_code);

    if (data.cardNumber != null && !data.cardNumber.isEmpty()) {
        numberField.setText(CardNumber.format(data.cardNumber));
    }

    if (data.cardholderName != null && !data.cardholderName.isEmpty()) {
        nameField.setText(data.cardholderName);
    }

    if (data.isExpiryValid()) {
        Spinner spinner = views.spinner(R.id.spinner_expiry_month);
        ExpiryMonthSpinnerAdapter monthAdapter = (ExpiryMonthSpinnerAdapter) spinner.getAdapter();
        spinner.setSelection(monthAdapter.getPosition(data.expiryMonth));

        spinner = views.spinner(R.id.spinner_expiry_year);
        ExpiryYearSpinnerAdapter yearAdapter = (ExpiryYearSpinnerAdapter) spinner.getAdapter() ;
        spinner.setSelection(yearAdapter.getPosition(data.expiryYear));
    }

    if (data.cvv != null && !data.cvv.isEmpty()) {
        securityCodeField.setText(data.cvv);
    }

    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (numberField.getText() == null || numberField.getText().toString().isEmpty()) {
        numberField.requestFocus();
        imm.showSoftInput(numberField, InputMethodManager.SHOW_IMPLICIT);
    } else if (nameField.getText() == null || nameField.getText().toString().isEmpty()) {
        nameField.requestFocus();
        imm.showSoftInput(nameField, InputMethodManager.SHOW_IMPLICIT);
    } else if (securityCodeField.getText() == null || securityCodeField.getText().toString().isEmpty()) {
        securityCodeField.requestFocus();
        imm.showSoftInput(securityCodeField, InputMethodManager.SHOW_IMPLICIT);
    }
}
 
开发者ID:omise,项目名称:omise-android,代码行数:40,代码来源:CreditCardActivity.java


注:本文中的io.card.payment.CreditCard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。