#v2.4 - New architecture applied to invoice (#38)

This commit is contained in:
Antonio Buedo 2019-08-02 14:19:32 +02:00 committed by GitHub
parent ea84650820
commit fff612d3c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 724 additions and 214 deletions

View File

@ -93,7 +93,7 @@ model</FONT>
Class Invoice</H2>
<PRE>
java.lang.Object
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.Invoice</B>
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.Invoice.Invoice</B>
</PRE>
<HR>
<DL>

View File

@ -93,7 +93,7 @@ model</FONT>
Class InvoiceBuyer</H2>
<PRE>
java.lang.Object
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.InvoiceBuyer</B>
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.Invoice.Buyer</B>
</PRE>
<HR>
<DL>

View File

@ -93,7 +93,7 @@ model</FONT>
Class InvoiceFlags</H2>
<PRE>
java.lang.Object
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.InvoiceFlags</B>
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.Invoice.InvoiceFlags</B>
</PRE>
<HR>
<DL>

View File

@ -93,7 +93,7 @@ model</FONT>
Class InvoicePaymentUrls</H2>
<PRE>
java.lang.Object
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.InvoicePaymentUrls</B>
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.Invoice.InvoicePaymentUrls</B>
</PRE>
<HR>
<DL>

View File

@ -93,7 +93,7 @@ model</FONT>
Class InvoiceTransaction</H2>
<PRE>
java.lang.Object
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.InvoiceTransaction</B>
<IMG SRC="../resources/inherit.gif" ALT="extended by "><B>model.Invoice.InvoiceTransaction</B>
</PRE>
<HR>
<DL>

View File

@ -4,7 +4,7 @@
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Fri Oct 23 16:37:05 EDT 2015 -->
<TITLE>
Uses of Class model.Invoice
Uses of Class model.Invoice.Invoice
</TITLE>
<META NAME="date" CONTENT="2015-10-23">

View File

@ -4,7 +4,7 @@
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Fri Oct 23 16:37:05 EDT 2015 -->
<TITLE>
Uses of Class model.InvoiceBuyer
Uses of Class model.Invoice.Buyer
</TITLE>
<META NAME="date" CONTENT="2015-10-23">

View File

@ -4,7 +4,7 @@
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Fri Oct 23 16:37:05 EDT 2015 -->
<TITLE>
Uses of Class model.InvoiceFlags
Uses of Class model.Invoice.InvoiceFlags
</TITLE>
<META NAME="date" CONTENT="2015-10-23">

View File

@ -4,7 +4,7 @@
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Fri Oct 23 16:37:05 EDT 2015 -->
<TITLE>
Uses of Class model.InvoicePaymentUrls
Uses of Class model.Invoice.InvoicePaymentUrls
</TITLE>
<META NAME="date" CONTENT="2015-10-23">

View File

@ -4,7 +4,7 @@
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Fri Oct 23 16:37:05 EDT 2015 -->
<TITLE>
Uses of Class model.InvoiceTransaction
Uses of Class model.Invoice.InvoiceTransaction
</TITLE>
<META NAME="date" CONTENT="2015-10-23">

View File

@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import model.*;
import model.Invoice.Invoice;
import model.Invoice.PaymentTotal;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
@ -445,7 +447,7 @@ public class BitPay {
* Checks whether a BitPay invoice has been paid in full.
* Returns true if the amountPaid >= paymentTotals, returns false otherwise
*
* @param Invoice A Bitpay invoice object
* @param invoice A Bitpay invoice object
* @return true if the amountPaid >= paymentTotals, returns false otherwise
*/
@ -456,9 +458,16 @@ public class BitPay {
if (transactionCurrency == null){
return false;
}
Hashtable <String, Long> paymentTotals = invoice.getPaymentTotals();
if (amountPaid < paymentTotals.get(transactionCurrency)){
return false;
PaymentTotal paymentTotals = invoice.getPaymentTotals();
if (transactionCurrency.equals("BTC")) {
if (amountPaid < paymentTotals.getBTC()) {
return false;
}
}
else if (transactionCurrency.equals("BCH")) {
if (amountPaid < paymentTotals.getBCH()) {
return false;
}
}
return true;
}

196
src/model/Currency.java Normal file
View File

@ -0,0 +1,196 @@
package model;
import java.lang.reflect.Field;
public class Currency {
// Crypto
public static final String BCH = "BCH";
public static final String BTC = "BTC";
public static final String ETH = "ETH";
public static final String USDC = "USDC";
public static final String GUSD = "GUSD";
public static final String PAX = "PAX";
// FIAT
public static final String AED = "AED";
public static final String AFN = "AFN";
public static final String ALL = "ALL";
public static final String AMD = "AMD";
public static final String ANG = "ANG";
public static final String AOA = "AOA";
public static final String ARS = "ARS";
public static final String AUD = "AUD";
public static final String AWG = "AWG";
public static final String AZN = "AZN";
public static final String BAM = "BAM";
public static final String BBD = "BBD";
public static final String BDT = "BDT";
public static final String BGN = "BGN";
public static final String BHD = "BHD";
public static final String BIF = "BIF";
public static final String BMD = "BMD";
public static final String BND = "BND";
public static final String BOB = "BOB";
public static final String BOV = "BOV";
public static final String BRL = "BRL";
public static final String BSD = "BSD";
public static final String BTN = "BTN";
public static final String BWP = "BWP";
public static final String BYR = "BYR";
public static final String BZD = "BZD";
public static final String CAD = "CAD";
public static final String CDF = "CDF";
public static final String CHE = "CHE";
public static final String CHF = "CHF";
public static final String CHW = "CHW";
public static final String CLF = "CLF";
public static final String CLP = "CLP";
public static final String CNY = "CNY";
public static final String COP = "COP";
public static final String COU = "COU";
public static final String CRC = "CRC";
public static final String CUC = "CUC";
public static final String CUP = "CUP";
public static final String CVE = "CVE";
public static final String CZK = "CZK";
public static final String DJF = "DJF";
public static final String DKK = "DKK";
public static final String DOP = "DOP";
public static final String DZD = "DZD";
public static final String EGP = "EGP";
public static final String ERN = "ERN";
public static final String ETB = "ETB";
public static final String EUR = "EUR";
public static final String FJD = "FJD";
public static final String FKP = "FKP";
public static final String GBP = "GBP";
public static final String GEL = "GEL";
public static final String GHS = "GHS";
public static final String GIP = "GIP";
public static final String GMD = "GMD";
public static final String GNF = "GNF";
public static final String GTQ = "GTQ";
public static final String GYD = "GYD";
public static final String HKD = "HKD";
public static final String HNL = "HNL";
public static final String HRK = "HRK";
public static final String HTG = "HTG";
public static final String HUF = "HUF";
public static final String IDR = "IDR";
public static final String ILS = "ILS";
public static final String INR = "INR";
public static final String IQD = "IQD";
public static final String IRR = "IRR";
public static final String ISK = "ISK";
public static final String JMD = "JMD";
public static final String JOD = "JOD";
public static final String JPY = "JPY";
public static final String KES = "KES";
public static final String KGS = "KGS";
public static final String KHR = "KHR";
public static final String KMF = "KMF";
public static final String KPW = "KPW";
public static final String KRW = "KRW";
public static final String KWD = "KWD";
public static final String KYD = "KYD";
public static final String KZT = "KZT";
public static final String LAK = "LAK";
public static final String LBP = "LBP";
public static final String LKR = "LKR";
public static final String LRD = "LRD";
public static final String LSL = "LSL";
public static final String LYD = "LYD";
public static final String MAD = "MAD";
public static final String MDL = "MDL";
public static final String MGA = "MGA";
public static final String MKD = "MKD";
public static final String MMK = "MMK";
public static final String MNT = "MNT";
public static final String MOP = "MOP";
public static final String MRU = "MRU";
public static final String MUR = "MUR";
public static final String MVR = "MVR";
public static final String MWK = "MWK";
public static final String MXN = "MXN";
public static final String MXV = "MXV";
public static final String MYR = "MYR";
public static final String MZN = "MZN";
public static final String NAD = "NAD";
public static final String NGN = "NGN";
public static final String NIO = "NIO";
public static final String NOK = "NOK";
public static final String NPR = "NPR";
public static final String NZD = "NZD";
public static final String OMR = "OMR";
public static final String PAB = "PAB";
public static final String PEN = "PEN";
public static final String PGK = "PGK";
public static final String PHP = "PHP";
public static final String PKR = "PKR";
public static final String PLN = "PLN";
public static final String PYG = "PYG";
public static final String QAR = "QAR";
public static final String RON = "RON";
public static final String RSD = "RSD";
public static final String RUB = "RUB";
public static final String RWF = "RWF";
public static final String SAR = "SAR";
public static final String SBD = "SBD";
public static final String SCR = "SCR";
public static final String SDG = "SDG";
public static final String SEK = "SEK";
public static final String SGD = "SGD";
public static final String SHP = "SHP";
public static final String SLL = "SLL";
public static final String SOS = "SOS";
public static final String SRD = "SRD";
public static final String SSP = "SSP";
public static final String STN = "STN";
public static final String SVC = "SVC";
public static final String SYP = "SYP";
public static final String SZL = "SZL";
public static final String THB = "THB";
public static final String TJS = "TJS";
public static final String TMT = "TMT";
public static final String TND = "TND";
public static final String TOP = "TOP";
public static final String TRY = "TRY";
public static final String TTD = "TTD";
public static final String TWD = "TWD";
public static final String TZS = "TZS";
public static final String UAH = "UAH";
public static final String UGX = "UGX";
public static final String USD = "USD";
public static final String USN = "USN";
public static final String UYI = "UYI";
public static final String UYU = "UYU";
public static final String UZS = "UZS";
public static final String VEF = "VEF";
public static final String VND = "VND";
public static final String VUV = "VUV";
public static final String WST = "WST";
public static final String XAF = "XAF";
public static final String XCD = "XCD";
public static final String XDR = "XDR";
public static final String XOF = "XOF";
public static final String XPF = "XPF";
public static final String XSU = "XSU";
public static final String XUA = "XUA";
public static final String YER = "YER";
public static final String ZAR = "ZAR";
public static final String ZMW = "ZMW";
public static final String ZWL = "ZWL";
public static boolean isValid(String value)
{
try {
Class<?> currencyClass = Currency.class;
Field symbol = currencyClass.getField(value);
return symbol!=null;
}
catch (Exception ex) {
return false;
}
}
}

View File

@ -1,21 +1,22 @@
package model;
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
public class InvoiceBuyer {
public class Buyer {
private String _name = "";
private String _address1 = "";
private String _address2 = "";
private String _locality = "";
private String _region = "";
private String _postalCode = "";
private String _country = "";
private String _email = "";
private String _phone = "";
private String _name;
private String _address1;
private String _address2;
private String _locality;
private String _region;
private String _postalCode;
private String _country;
private String _email;
private String _phone;
private boolean _notify;
public InvoiceBuyer() {}
public Buyer() {}
@JsonProperty("name")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@ -105,15 +106,26 @@ public class InvoiceBuyer {
this._email = email;
}
@JsonProperty("phone")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonProperty("phone")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public String getPhone() {
return _phone;
}
@JsonProperty("phone")
@JsonProperty("phone")
public void setPhone(String phone) {
this._phone = phone;
}
@JsonProperty("notify")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public boolean getNotify() {
return _notify;
}
@JsonProperty("notify")
public void setNotify(boolean notify) {
this._notify = notify;
}
}

View File

@ -1,4 +1,4 @@
package model;
package model.Invoice;
import java.util.Hashtable;
import java.util.List;
@ -6,24 +6,17 @@ import java.util.List;
import com.fasterxml.jackson.annotation.*;
import controller.BitPayException;
import model.Currency;
@JsonIgnoreProperties(ignoreUnknown=true)
public class Invoice {
public static final String STATUS_NEW = "new";
public static final String STATUS_PAID = "paid";
public static final String STATUS_CONFIRMED = "confirmed";
public static final String STATUS_COMPLETE = "complete";
public static final String STATUS_INVALID = "invalid";
public static final String EXSTATUS_FALSE = "false";
public static final String EXSTATUS_PAID_OVER = "paidOver";
public static final String EXSTATUS_PAID_PARTIAL = "paidPartial";
private String _currency;
private String _guid = "";
private String _token = "";
private Double _price;
private String _currency;
private String _posData = "";
private String _notificationURL = "";
private String _transactionSpeed = "";
@ -34,26 +27,34 @@ public class Invoice {
private String _itemDesc = "";
private String _itemCode = "";
private boolean _physical = false;
private InvoiceBuyer _buyer;
private List<String> _paymentCurrencies;
private long _acceptanceWindow;
private Buyer _buyer;
private String _id;
private String _url;
private String _status;
private String _lowFeeDetected;
private String _invoiceTime;
private long _expirationTime;
private long _currentTime;
private List<InvoiceTransaction> _transactions;
private String _exceptionStatus;
private InvoicePaymentUrls _paymentUrls = new InvoicePaymentUrls();
private String _refundAddressRequestPending;
private InvoiceBuyerProvidedInfo _invoiceBuyerProvidedInfo = new InvoiceBuyerProvidedInfo();
private SupportedTransactionCurrencies _supportedTransactionCurrencies = new SupportedTransactionCurrencies();
private MinerFees _minerFees = new MinerFees();
private PaymentCodes _paymentCodes = new PaymentCodes();
private boolean _extendedNotifications = false;
private String _transactionCurrency;
private long _amountPaid;
private Hashtable<String, Hashtable <String, String> > _exchangeRates;
private Hashtable<String, Long> _paymentTotals;
private Hashtable<String, Long> _paymentSubtotals;
private PaymentTotal _paymentTotals;
private PaymentTotal _paymentSubtotals;
private PaymentTotal _paymentDisplayTotals;
private PaymentTotal _paymentDisplaySubTotals;
/**
* Constructor, create an empty Invoice object.
*/
@ -115,10 +116,9 @@ public class Invoice {
@JsonProperty("currency")
public void setCurrency(String _currency) throws BitPayException {
if (_currency.length() != 3)
{
throw new BitPayException("Error: currency code must be exactly three characters");
}
if (!Currency.isValid(_currency))
throw new BitPayException("Error: currency code must be a type of Model.Currency");
this._currency = _currency;
}
@ -202,6 +202,17 @@ public class Invoice {
this._fullNotifications = _fullNotifications;
}
@JsonProperty("extendedNotifications")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public boolean getExtendedNotifications() {
return _extendedNotifications;
}
@JsonProperty("extendedNotifications")
public void setExtendedNotifications(boolean _extendedNotifications) {
this._extendedNotifications = _extendedNotifications;
}
@JsonProperty("notificationEmail")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public String getNotificationEmail() {
@ -235,29 +246,42 @@ public class Invoice {
this._physical = _physical;
}
@JsonProperty("paymentCurrencies")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public List<String> getPaymentCurrencies() {
return _paymentCurrencies;
}
@JsonProperty("paymentCurrencies")
public void setPaymentCurrencies(List<String> _paymentCurrencies) {
this._paymentCurrencies = _paymentCurrencies;
}
@JsonProperty("acceptanceWindow")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public long getAcceptanceWindow() {
return _acceptanceWindow;
}
@JsonProperty("acceptanceWindow")
public void setAcceptanceWindow(long _acceptanceWindow) {
this._acceptanceWindow = _acceptanceWindow;
}
// Buyer data
//
@JsonProperty("buyer")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public InvoiceBuyer getBuyer() {
public Buyer getBuyer() {
return _buyer;
}
@JsonProperty("buyer")
public void setBuyer(InvoiceBuyer _buyer) {
public void setBuyer(Buyer _buyer) {
this._buyer = _buyer;
}
@JsonProperty("extendedNotifications")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public boolean getExtendedNotifications() {
return _extendedNotifications;
}
@JsonProperty("extendedNotifications")
public void setExtendedNotifications(boolean _extendedNotifications) {
this._extendedNotifications = _extendedNotifications;
}
// Response fields
//
@ -281,16 +305,22 @@ public class Invoice {
this._url = _url;
}
@JsonIgnore
@JsonIgnore
public String getStatus() {
return _status;
}
@JsonProperty("status")
@JsonProperty("status")
public void setStatus(String _status) {
this._status = _status;
}
@JsonIgnore
public String getLowFeeDetected() { return _lowFeeDetected; }
@JsonProperty("lowFeeDetected")
public void setLowFeeDetected(String _lowFeeDetected) { this._lowFeeDetected = _lowFeeDetected; }
@JsonIgnore
public String getInvoiceTime() {
return _invoiceTime;
@ -341,65 +371,123 @@ public class Invoice {
this._exceptionStatus = _exceptionStatus;
}
@JsonIgnore
public InvoicePaymentUrls getPaymentUrls() {
return _paymentUrls;
}
@JsonProperty("paymentUrls")
public void setPaymentUrls(InvoicePaymentUrls _paymentUrls) {
this._paymentUrls = _paymentUrls;
}
@JsonIgnore
public String getRefundAddressRequestPending() {
return _refundAddressRequestPending;
}
@JsonProperty("refundAddressRequestPending")
public void setRefundAddressRequestPending(String _refundAddressRequestPending) {
this._refundAddressRequestPending = _refundAddressRequestPending;
}
@JsonIgnore
public String getTransactionCurrency() {
return _transactionCurrency;
}
@JsonProperty("transactionCurrency")
public void setTransactionCurrency(String _transactionCurrency) {
this._transactionCurrency = _transactionCurrency;
}
@JsonIgnore
public long getAmountPaid() {
return _amountPaid;
}
@JsonProperty("amountPaid")
public void setAmountPaid(long _amountPaid) {
this._amountPaid = _amountPaid;
}
public InvoiceBuyerProvidedInfo getInvoiceBuyerProvidedInfo() {
return _invoiceBuyerProvidedInfo;
}
@JsonProperty("invoiceBuyerProvidedInfo")
public void setInvoiceBuyerProvidedInfo(InvoiceBuyerProvidedInfo _invoiceBuyerProvidedInfo) {
this._invoiceBuyerProvidedInfo = _invoiceBuyerProvidedInfo;
}
@JsonIgnore
public SupportedTransactionCurrencies getSupportedTransactionCurrencies() {
return _supportedTransactionCurrencies;
}
@JsonProperty("supportedTransactionCurrencies")
public void setSupportedTransactionCurrencies(SupportedTransactionCurrencies _supportedTransactionCurrencies) {
this._supportedTransactionCurrencies = _supportedTransactionCurrencies;
}
@JsonIgnore
public MinerFees getMinerFees() {
return _minerFees;
}
@JsonProperty("minerFees")
public void setMinerFees(MinerFees _minerFees) {
this._minerFees = _minerFees;
}
@JsonIgnore
public String getTransactionCurrency() {
return _transactionCurrency;
}
@JsonProperty("transactionCurrency")
public void setTransactionCurrency(String _transactionCurrency) {
this._transactionCurrency = _transactionCurrency;
}
@JsonIgnore
public PaymentCodes getPaymentCodes() {
return _paymentCodes;
}
@JsonProperty("paymentCodes")
public void setPaymentCodes(PaymentCodes _paymentCodes) {
this._paymentCodes = _paymentCodes;
}
@JsonIgnore
public PaymentTotal getPaymentSubtotals() {
return _paymentSubtotals;
}
@JsonProperty("paymentSubtotals")
public void setPaymentSubtotals(PaymentTotal _paymentSubtotals) {
this._paymentSubtotals = _paymentSubtotals;
}
@JsonIgnore
public PaymentTotal getPaymentTotals() {
return _paymentTotals;
}
@JsonProperty("paymentTotals")
public void setPaymentTotals(PaymentTotal _paymentTotals) {
this._paymentTotals = _paymentTotals;
}
@JsonIgnore
public PaymentTotal getPaymentDisplayTotals() {
return _paymentDisplayTotals;
}
@JsonProperty("paymentDisplayTotals")
public void setPaymentDisplayTotals(PaymentTotal _paymentDisplayTotals) {
this._paymentDisplayTotals = _paymentDisplayTotals;
}
@JsonIgnore
public PaymentTotal getPaymentDisplaySubTotals() {
return _paymentDisplaySubTotals;
}
@JsonProperty("paymentDisplaySubTotals")
public void setPaymentDisplaySubTotals(PaymentTotal _paymentDisplaySubTotals) {
this._paymentDisplaySubTotals = _paymentDisplaySubTotals;
}
@JsonIgnore
public long getAmountPaid() {
return _amountPaid;
}
@JsonProperty("amountPaid")
public void setAmountPaid(long _amountPaid) {
this._amountPaid = _amountPaid;
}
@JsonIgnore
public Hashtable<String, Hashtable <String, String> > getExchangeRates() {
return _exchangeRates;
}
@JsonProperty("exchangeRates")
@JsonProperty("exchangeRates")
public void setExchangeRates(Hashtable<String, Hashtable <String, String> > _exchangeRates) {
this._exchangeRates = _exchangeRates;
}
@JsonIgnore
public Hashtable<String, Long> getPaymentTotals() {
return _paymentTotals;
}
@JsonProperty("paymentTotals")
public void setPaymentTotals(Hashtable<String, Long> _paymentTotals) {
this._paymentTotals = _paymentTotals;
}
@JsonIgnore
public Hashtable<String, Long> getPaymentSubtotals() {
return _paymentSubtotals;
}
@JsonProperty("paymentSubtotals")
public void setPaymentSubtotals(Hashtable<String, Long> _paymentSubtotals) {
this._paymentSubtotals = _paymentSubtotals;
}
}

View File

@ -0,0 +1,42 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class InvoiceBuyerProvidedInfo {
private String _name;
private String _phoneNumber;
private String _emailAddress;
public InvoiceBuyerProvidedInfo() {}
@JsonIgnore
public String getName() {
return _name;
}
@JsonProperty("name")
public void setName(String name) {
this._name = name;
}
@JsonIgnore
public String getPhoneNumber() {
return _phoneNumber;
}
@JsonProperty("phoneNumber")
public void setPhoneNumber(String phoneNumber) {
this._phoneNumber = phoneNumber;
}
@JsonIgnore
public String getEmailAddress() {
return _emailAddress;
}
@JsonProperty("emailAddress")
public void setEmailAddress(String emailAddress) {
this._emailAddress = emailAddress;
}
}

View File

@ -0,0 +1,11 @@
package model.Invoice;
public class InvoiceStatus {
public static final String New = "new";
public static final String Funded = "funded";
public static final String Processing = "processing";
public static final String Complete = "complete";
public static final String Failed = "failed";
public static final String Cancelled = "cancelled";
}

View File

@ -1,4 +1,4 @@
package model;
package model.Invoice;
import java.util.Date;
@ -35,16 +35,6 @@ public class InvoiceTransaction {
this._confirmations = confirmations;
}
@JsonIgnore
public Date getTime() {
return _time;
}
@JsonProperty("time")
public void setTime(Date time) {
this._time = time;
}
@JsonIgnore
public Date getReceivedTime() {
return _receivedTime;
@ -65,4 +55,14 @@ public class InvoiceTransaction {
this._txid = txid;
}
@JsonIgnore
public Date getTime() {
return _time;
}
@JsonProperty("time")
public void setTime(Date time) {
this._time = time;
}
}

View File

@ -0,0 +1,32 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class MinerFees {
private MinerFeesItem _btc = new MinerFeesItem();
private MinerFeesItem _bch = new MinerFeesItem();
public MinerFees() {}
@JsonIgnore
public MinerFeesItem getBtc() {
return _btc;
}
@JsonProperty("BTC")
public void setBtc(MinerFeesItem btc) {
this._btc = btc;
}
@JsonIgnore
public MinerFeesItem getBch() {
return _bch;
}
@JsonProperty("BCH")
public void setBch(MinerFeesItem bch) {
this._bch = bch;
}
}

View File

@ -0,0 +1,32 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class MinerFeesItem {
private Double _satoshisPerByte;
private Double _totalFee;
public MinerFeesItem() {}
@JsonIgnore
public Double getSatoshisPerByte() {
return _satoshisPerByte;
}
@JsonProperty("satoshisPerByte")
public void setSatoshisPerByte(Double satoshisPerByte) {
this._satoshisPerByte = satoshisPerByte;
}
@JsonIgnore
public Double getTotalFee() {
return _totalFee;
}
@JsonProperty("totalFee")
public void setTotalFee(Double totalFee) {
this._totalFee = totalFee;
}
}

View File

@ -0,0 +1,32 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class PaymentCode {
private String _bip72b;
private String _bip73;
public PaymentCode() {}
@JsonIgnore
public String getBip72b() {
return _bip72b;
}
@JsonProperty("BIP72b")
public void setBip72b(String bip72b) {
this._bip72b = bip72b;
}
@JsonIgnore
public String getBip73() {
return _bip73;
}
@JsonProperty("BIP73")
public void setBip73(String bip73) {
this._bip73 = bip73;
}
}

View File

@ -0,0 +1,32 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class PaymentCodes {
private PaymentCode _btc = new PaymentCode();
private PaymentCode _bch = new PaymentCode();
public PaymentCodes() {}
@JsonIgnore
public PaymentCode getBtc() {
return _btc;
}
@JsonProperty("BTC")
public void setBtc(PaymentCode btc) {
this._btc = btc;
}
@JsonIgnore
public PaymentCode getBch() {
return _bch;
}
@JsonProperty("BCH")
public void setBch(PaymentCode bch) {
this._bch = bch;
}
}

View File

@ -0,0 +1,32 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class PaymentTotal {
private Double _btc;
private Double _bch;
public PaymentTotal() {}
@JsonIgnore
public Double getBTC() {
return _btc;
}
@JsonProperty("BTC")
public void setBtc(Double btc) {
this._btc = btc;
}
@JsonIgnore
public Double getBCH() {
return _bch;
}
@JsonProperty("BCH")
public void setBch(Double bch) {
this._bch = bch;
}
}

View File

@ -0,0 +1,32 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class SupportedTransactionCurrencies {
private SupportedTransactionCurrency _btc = new SupportedTransactionCurrency();
private SupportedTransactionCurrency _bch = new SupportedTransactionCurrency();
public SupportedTransactionCurrencies() {}
@JsonIgnore
public SupportedTransactionCurrency getBtc() {
return _btc;
}
@JsonProperty("BTC")
public void setBtc(SupportedTransactionCurrency btc) {
this._btc = btc;
}
@JsonIgnore
public SupportedTransactionCurrency getBch() {
return _bch;
}
@JsonProperty("BCH")
public void setBch(SupportedTransactionCurrency bch) {
this._bch = bch;
}
}

View File

@ -0,0 +1,21 @@
package model.Invoice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class SupportedTransactionCurrency {
private boolean _enabled;
public SupportedTransactionCurrency() {}
@JsonIgnore
public boolean getEnabled() {
return _enabled;
}
@JsonProperty("enabled")
public void setNotify(boolean enabled) {
this._enabled = enabled;
}
}

View File

@ -1,22 +0,0 @@
package model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class InvoiceFlags {
private boolean _refundable = false;
public InvoiceFlags() {}
@JsonIgnore
public boolean getRefundable() {
return _refundable;
}
@JsonProperty("refundable")
public void setRefundable(boolean refundable) {
this._refundable = refundable;
}
}

View File

@ -1,54 +0,0 @@
package model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class InvoicePaymentUrls {
private String _BIP21 = "";
private String _BIP72 = "";
private String _BIP72b = "";
private String _BIP73 = "";
public InvoicePaymentUrls() {}
@JsonIgnore
public String getBIP21() {
return _BIP21;
}
@JsonProperty("BIP21")
public void setBIP21(String BIP21) {
this._BIP21 = BIP21;
}
@JsonIgnore
public String getBIP72() {
return _BIP72;
}
@JsonProperty("BIP72")
public void setBIP72(String BIP72) {
this._BIP72 = BIP72;
}
@JsonIgnore
public String getBIP72b() {
return _BIP72b;
}
@JsonProperty("BIP72b")
public void setBIP72b(String BIP72b) {
this._BIP72b = BIP72b;
}
@JsonIgnore
public String getBIP73() {
return _BIP73;
}
@JsonProperty("BIP73")
public void setBIP73(String BIP73) {
this._BIP73 = BIP73;
}
}

View File

@ -1,5 +1,7 @@
package model;
import model.Invoice.Invoice;
public class RefundHelper {
private Refund _refund;

View File

@ -5,6 +5,9 @@ import controller.BitPayException;
import controller.BitPayLogger;
import controller.KeyUtils;
import model.*;
import model.Invoice.Invoice;
import model.Invoice.Buyer;
import model.Invoice.InvoiceStatus;
import org.bitcoinj.core.ECKey;
import org.junit.Before;
import org.junit.BeforeClass;
@ -138,14 +141,14 @@ public class BitPayTest {
@Test
public void testShouldGetInvoiceStatus()
{
Invoice invoice = new Invoice(50.0, "USD");
Invoice invoice = new Invoice(2.0, "EUR");
try {
basicInvoice = bitpay.createInvoice(invoice);
} catch (BitPayException e) {
e.printStackTrace();
fail(e.getMessage());
}
assertEquals(Invoice.STATUS_NEW, basicInvoice.getStatus());
assertEquals(InvoiceStatus.New, basicInvoice.getStatus());
}
@Test
@ -209,7 +212,7 @@ public class BitPayTest {
@Test
public void testShouldCreateInvoiceWithAdditionalParams()
{
InvoiceBuyer buyer = new InvoiceBuyer();
Buyer buyer = new Buyer();
buyer.setName("Satoshi");
buyer.setEmail("satoshi@buyeremaildomain.com");
@ -224,7 +227,7 @@ public class BitPayTest {
e.printStackTrace();
fail(e.getMessage());
}
assertEquals(Invoice.STATUS_NEW, invoice.getStatus());
assertEquals(InvoiceStatus.New, invoice.getStatus());
assertEquals(100.0, invoice.getPrice(), EPSILON);
assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", invoice.getPosData());
assertEquals("Satoshi", invoice.getBuyer().getName());

View File

@ -3,7 +3,8 @@ package test;
import controller.BitPay;
import controller.BitPayException;
import controller.BitPayLogger;
import model.Invoice;
import model.Invoice.Invoice;
import model.Currency;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -11,6 +12,7 @@ import org.junit.Test;
import java.net.UnknownHostException;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class BitPayTest2 {
@ -34,7 +36,7 @@ public class BitPayTest2 {
// time should result in the authorized client (this test) running to completion.
clientName += " on " + java.net.InetAddress.getLocalHost();
BitPay bitpay = new BitPay(clientName, BitPay.BITPAY_TEST_URL); //this tests the old way of creating keys/clients
if (!bitpay.clientIsAuthorized(BitPay.FACADE_POS))
{
// Get POS facade authorization code.
@ -42,7 +44,7 @@ public class BitPayTest2 {
// this device and input into and approved by the desired merchant account. To
// generate invoices a POS facade is required.
String pairingCode = bitpay.requestClientAuthorization(BitPay.FACADE_POS);
// Signal the device operator that this client needs to be paired with a merchant account.
_log.info("Client is requesting POS facade access. Go to " + BitPay.BITPAY_TEST_URL + " and pair this client with your merchant account using the pairing code: " + pairingCode);
throw new BitPayException("Error: client is not authorized.");
@ -60,4 +62,12 @@ public class BitPayTest2 {
}
assertNotNull(invoice.getId());
}
@Test
public void testCurrency()
{
boolean validCurrency;
validCurrency = Currency.isValid("EUR");
assertTrue(validCurrency);
}
}