1 5 package com.openedit.store; 6 7 import java.text.NumberFormat ; 8 9 13 public class CreditPaymentMethod extends PaymentMethod 14 { 15 protected CreditCardType fieldCreditCardType; 16 protected String fieldCardNumber = ""; 17 protected int fieldExpirationMonth = 0; 18 protected int fieldExpirationYear = 0; 19 protected String fieldNote; 20 protected boolean fieldBillMeLater; 22 public CreditPaymentMethod() 23 { 24 super(); 25 } 26 27 public String getCardNumber() 28 { 29 return fieldCardNumber; 30 } 31 32 public CreditCardType getCreditCardType() 33 { 34 if ( fieldCreditCardType == null ) 35 { 36 fieldCreditCardType = new CreditCardType(); 37 } 38 return fieldCreditCardType; 39 } 40 41 public String getExpirationDateString() 42 { 43 NumberFormat twoDigitIntFormat = NumberFormat.getIntegerInstance(); 44 twoDigitIntFormat.setMinimumIntegerDigits(2); 45 return twoDigitIntFormat.format(getExpirationMonth()) + '/' + 46 twoDigitIntFormat.format(getExpirationYear() % 100); 47 } 48 49 public String getExpirationMonthString() 50 { 51 String dateString = getExpirationDateString(); 52 String monthString = dateString.substring(0,2); 53 return monthString; 54 } 55 56 public String getExpirationYearString() 57 { 58 String dateString = getExpirationDateString(); 59 String yearString = dateString.substring(3,5); 60 return yearString; 61 } 62 63 public int getExpirationMonth() 64 { 65 return fieldExpirationMonth; 66 } 67 68 public int getExpirationYear() 69 { 70 return fieldExpirationYear; 71 } 72 73 public void setCardNumber(String inString) 74 { 75 fieldCardNumber = inString; 76 } 77 78 public void setCreditCardType(CreditCardType inType) 79 { 80 fieldCreditCardType = inType; 81 } 82 83 public void setExpirationMonth(int inI) 84 { 85 fieldExpirationMonth = inI; 86 } 87 88 public void setExpirationYear(int inI) 89 { 90 fieldExpirationYear = inI; 91 } 92 93 public String toString() 94 { 95 StringBuffer sb = new StringBuffer ( "Credit Card: " ); 96 sb.append( fieldCreditCardType ); 97 sb.append( '\n' ); 98 sb.append( fieldCardNumber ); 99 sb.append( " Expiration: " ); 100 sb.append( fieldExpirationMonth ); 101 sb.append( '/' ); 102 sb.append( fieldExpirationYear ); 103 sb.append( '\n' ); 104 return sb.toString(); 105 } 106 107 110 public boolean requiresValidation() 111 { 112 return !getBillMeLater(); 114 } 115 116 119 public String getType() 120 { 121 return "creditcard"; 122 } 123 public boolean getBillMeLater() 124 { 125 return fieldBillMeLater; 126 } 127 public void setBillMeLater(boolean inBillMeLater) 128 { 129 fieldBillMeLater = inBillMeLater; 130 } 131 132 public String getNote() 133 { 134 return fieldNote; 135 } 136 public void setNote( String inNote ) 137 { 138 fieldNote = inNote; 139 } 140 } 141 | Popular Tags |