本文整理汇总了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);
}
}
}
}
示例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));
}
}
}
示例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;
}
示例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();
}
}
}
示例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;
}
}
}
示例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.
}
}
}
示例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;
}
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
}
示例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);
}
}