/buttonmanagersdk/src/main/java/urn/ebay/api/PayPalAPI/DoAuthorizationRequestType.java

https://gitlab.com/CORP-RESELLER/buttonmanager-sdk-java · Java · 460 lines · 209 code · 59 blank · 192 comment · 37 complexity · cd46db7fb8781879a02816f86b0fe381 MD5 · raw file

  1. package urn.ebay.api.PayPalAPI;
  2. import urn.ebay.apis.eBLBaseComponents.TransactionEntityType;
  3. import urn.ebay.apis.CoreComponentTypes.BasicAmountType;
  4. import urn.ebay.apis.eBLBaseComponents.AddressType;
  5. import java.util.List;
  6. import java.util.ArrayList;
  7. import urn.ebay.apis.eBLBaseComponents.PaymentDetailsItemType;
  8. import urn.ebay.apis.eBLBaseComponents.AbstractRequestType;
  9. import com.paypal.core.SDKUtil;
  10. /**
  11. * The value of the order’s transaction identification number
  12. * returned by a PayPal product. Required Character length and
  13. * limits: 19 single-byte characters maximum
  14. */
  15. public class DoAuthorizationRequestType extends AbstractRequestType {
  16. private static final String nameSpace="urn:ebay:api:PayPalAPI";
  17. private static final String preferredPrefix="ns";
  18. /**
  19. * The value of the order’s transaction identification number
  20. * returned by a PayPal product. Required Character length and
  21. * limits: 19 single-byte characters maximum
  22. *@Required
  23. */
  24. private String transactionID;
  25. /**
  26. * Type of transaction to authorize. The only allowable value
  27. * is Order, which means that the transaction represents a
  28. * customer order that can be fulfilled over 29 days. Optional
  29. */
  30. private TransactionEntityType transactionEntity;
  31. /**
  32. * Amount to authorize. Required Limitations: Must not exceed
  33. * $10,000 USD in any currency. No currency symbol. Decimal
  34. * separator must be a period (.), and the thousands separator
  35. * must be a comma (,).
  36. *@Required
  37. */
  38. private BasicAmountType amount;
  39. /**
  40. * Address the order will be shipped to. Optional
  41. */
  42. private AddressType shipToAddress;
  43. /**
  44. * Information about the individual purchased items
  45. */
  46. private List<PaymentDetailsItemType> paymentDetailsItem = new ArrayList<PaymentDetailsItemType>();
  47. /**
  48. * Sum of cost of all items in this order. You must set the
  49. * currencyID attribute to one of the three-character currency
  50. * codes for any of the supported PayPal currencies. Optional
  51. * Limitations: Must not exceed $10,000 USD in any currency. No
  52. * currency symbol. Decimal separator must be a period (.), and
  53. * the thousands separator must be a comma (,).
  54. */
  55. private BasicAmountType itemTotal;
  56. /**
  57. * Total shipping costs for this order. You must set the
  58. * currencyID attribute to one of the three-character currency
  59. * codes for any of the supported PayPal currencies. Optional
  60. * Limitations: Must not exceed $10,000 USD in any currency. No
  61. * currency symbol. Decimal separator must be a period (.), and
  62. * the thousands separator must be a comma (,).
  63. */
  64. private BasicAmountType shippingTotal;
  65. /**
  66. * Total handling costs for this order. You must set the
  67. * currencyID attribute to one of the three-character currency
  68. * codes for any of the supported PayPal currencies. Optional
  69. * Limitations: Must not exceed $10,000 USD in any currency. No
  70. * currency symbol. Decimal separator must be a period (.), and
  71. * the thousands separator must be a comma (,).
  72. */
  73. private BasicAmountType handlingTotal;
  74. /**
  75. * Sum of tax for all items in this order. You must set the
  76. * currencyID attribute to one of the three-character currency
  77. * codes for any of the supported PayPal currencies. Optional
  78. * Limitations: Must not exceed $10,000 USD in any currency. No
  79. * currency symbol. Decimal separator must be a period (.), and
  80. * the thousands separator must be a comma (,).
  81. */
  82. private BasicAmountType taxTotal;
  83. /**
  84. * Total shipping insurance costs for this order. Optional
  85. */
  86. private BasicAmountType insuranceTotal;
  87. /**
  88. * Shipping discount for this order, specified as a negative
  89. * number. Optional
  90. */
  91. private BasicAmountType shippingDiscount;
  92. /**
  93. * Description of items the customer is purchasing. Optional
  94. * Character length and limitations: 127 single-byte
  95. * alphanumeric characters
  96. */
  97. private String orderDescription;
  98. /**
  99. * A free-form field for your own use. Optional Character
  100. * length and limitations: 256 single-byte alphanumeric
  101. * characters
  102. */
  103. private String custom;
  104. /**
  105. * Unique id for each API request to prevent duplicate
  106. * payments. Optional Character length and limits: 38
  107. * single-byte characters maximum.
  108. */
  109. private String msgSubID;
  110. /**
  111. * IP Address of the buyer
  112. */
  113. private String iPAddress;
  114. /**
  115. * A flag indicating that this transaction is a Ship to Store
  116. * transaction. Optional
  117. */
  118. private String shipToStore;
  119. /**
  120. * Constructor with arguments
  121. */
  122. public DoAuthorizationRequestType (String transactionID, BasicAmountType amount){
  123. this.transactionID = transactionID;
  124. this.amount = amount;
  125. }
  126. /**
  127. * Default Constructor
  128. */
  129. public DoAuthorizationRequestType (){
  130. }
  131. /**
  132. * Getter for transactionID
  133. */
  134. public String getTransactionID() {
  135. return transactionID;
  136. }
  137. /**
  138. * Setter for transactionID
  139. */
  140. public void setTransactionID(String transactionID) {
  141. this.transactionID = transactionID;
  142. }
  143. /**
  144. * Getter for transactionEntity
  145. */
  146. public TransactionEntityType getTransactionEntity() {
  147. return transactionEntity;
  148. }
  149. /**
  150. * Setter for transactionEntity
  151. */
  152. public void setTransactionEntity(TransactionEntityType transactionEntity) {
  153. this.transactionEntity = transactionEntity;
  154. }
  155. /**
  156. * Getter for amount
  157. */
  158. public BasicAmountType getAmount() {
  159. return amount;
  160. }
  161. /**
  162. * Setter for amount
  163. */
  164. public void setAmount(BasicAmountType amount) {
  165. this.amount = amount;
  166. }
  167. /**
  168. * Getter for shipToAddress
  169. */
  170. public AddressType getShipToAddress() {
  171. return shipToAddress;
  172. }
  173. /**
  174. * Setter for shipToAddress
  175. */
  176. public void setShipToAddress(AddressType shipToAddress) {
  177. this.shipToAddress = shipToAddress;
  178. }
  179. /**
  180. * Getter for paymentDetailsItem
  181. */
  182. public List<PaymentDetailsItemType> getPaymentDetailsItem() {
  183. return paymentDetailsItem;
  184. }
  185. /**
  186. * Setter for paymentDetailsItem
  187. */
  188. public void setPaymentDetailsItem(List<PaymentDetailsItemType> paymentDetailsItem) {
  189. this.paymentDetailsItem = paymentDetailsItem;
  190. }
  191. /**
  192. * Getter for itemTotal
  193. */
  194. public BasicAmountType getItemTotal() {
  195. return itemTotal;
  196. }
  197. /**
  198. * Setter for itemTotal
  199. */
  200. public void setItemTotal(BasicAmountType itemTotal) {
  201. this.itemTotal = itemTotal;
  202. }
  203. /**
  204. * Getter for shippingTotal
  205. */
  206. public BasicAmountType getShippingTotal() {
  207. return shippingTotal;
  208. }
  209. /**
  210. * Setter for shippingTotal
  211. */
  212. public void setShippingTotal(BasicAmountType shippingTotal) {
  213. this.shippingTotal = shippingTotal;
  214. }
  215. /**
  216. * Getter for handlingTotal
  217. */
  218. public BasicAmountType getHandlingTotal() {
  219. return handlingTotal;
  220. }
  221. /**
  222. * Setter for handlingTotal
  223. */
  224. public void setHandlingTotal(BasicAmountType handlingTotal) {
  225. this.handlingTotal = handlingTotal;
  226. }
  227. /**
  228. * Getter for taxTotal
  229. */
  230. public BasicAmountType getTaxTotal() {
  231. return taxTotal;
  232. }
  233. /**
  234. * Setter for taxTotal
  235. */
  236. public void setTaxTotal(BasicAmountType taxTotal) {
  237. this.taxTotal = taxTotal;
  238. }
  239. /**
  240. * Getter for insuranceTotal
  241. */
  242. public BasicAmountType getInsuranceTotal() {
  243. return insuranceTotal;
  244. }
  245. /**
  246. * Setter for insuranceTotal
  247. */
  248. public void setInsuranceTotal(BasicAmountType insuranceTotal) {
  249. this.insuranceTotal = insuranceTotal;
  250. }
  251. /**
  252. * Getter for shippingDiscount
  253. */
  254. public BasicAmountType getShippingDiscount() {
  255. return shippingDiscount;
  256. }
  257. /**
  258. * Setter for shippingDiscount
  259. */
  260. public void setShippingDiscount(BasicAmountType shippingDiscount) {
  261. this.shippingDiscount = shippingDiscount;
  262. }
  263. /**
  264. * Getter for orderDescription
  265. */
  266. public String getOrderDescription() {
  267. return orderDescription;
  268. }
  269. /**
  270. * Setter for orderDescription
  271. */
  272. public void setOrderDescription(String orderDescription) {
  273. this.orderDescription = orderDescription;
  274. }
  275. /**
  276. * Getter for custom
  277. */
  278. public String getCustom() {
  279. return custom;
  280. }
  281. /**
  282. * Setter for custom
  283. */
  284. public void setCustom(String custom) {
  285. this.custom = custom;
  286. }
  287. /**
  288. * Getter for msgSubID
  289. */
  290. public String getMsgSubID() {
  291. return msgSubID;
  292. }
  293. /**
  294. * Setter for msgSubID
  295. */
  296. public void setMsgSubID(String msgSubID) {
  297. this.msgSubID = msgSubID;
  298. }
  299. /**
  300. * Getter for iPAddress
  301. */
  302. public String getIPAddress() {
  303. return iPAddress;
  304. }
  305. /**
  306. * Setter for iPAddress
  307. */
  308. public void setIPAddress(String iPAddress) {
  309. this.iPAddress = iPAddress;
  310. }
  311. /**
  312. * Getter for shipToStore
  313. */
  314. public String getShipToStore() {
  315. return shipToStore;
  316. }
  317. /**
  318. * Setter for shipToStore
  319. */
  320. public void setShipToStore(String shipToStore) {
  321. this.shipToStore = shipToStore;
  322. }
  323. public String toXMLString(String prefix, String name) {
  324. StringBuilder sb = new StringBuilder();
  325. if(name!=null){
  326. if(prefix!=null){
  327. sb.append("<").append(prefix).append(":").append(name).append(">");
  328. }
  329. else{
  330. sb.append("<").append(preferredPrefix).append(":").append(name).append(">");
  331. }
  332. }
  333. sb.append(super.toXMLString(prefix, null));
  334. if(transactionID != null) {
  335. sb.append("<").append(preferredPrefix).append(":TransactionID>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.transactionID));
  336. sb.append("</").append(preferredPrefix).append(":TransactionID>");
  337. }
  338. if(transactionEntity != null) {
  339. sb.append("<").append(preferredPrefix).append(":TransactionEntity>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.transactionEntity.getValue()));
  340. sb.append("</").append(preferredPrefix).append(":TransactionEntity>");
  341. }
  342. if(amount != null) {
  343. sb.append(amount.toXMLString(preferredPrefix,"Amount"));
  344. }
  345. if(shipToAddress != null) {
  346. sb.append(shipToAddress.toXMLString(null,"ShipToAddress"));
  347. }
  348. if(paymentDetailsItem != null) {
  349. for(int i=0; i < paymentDetailsItem.size(); i++) {
  350. sb.append(paymentDetailsItem.get(i).toXMLString(null,"PaymentDetailsItem"));
  351. }
  352. }
  353. if(itemTotal != null) {
  354. sb.append(itemTotal.toXMLString(preferredPrefix,"ItemTotal"));
  355. }
  356. if(shippingTotal != null) {
  357. sb.append(shippingTotal.toXMLString(preferredPrefix,"ShippingTotal"));
  358. }
  359. if(handlingTotal != null) {
  360. sb.append(handlingTotal.toXMLString(preferredPrefix,"HandlingTotal"));
  361. }
  362. if(taxTotal != null) {
  363. sb.append(taxTotal.toXMLString(preferredPrefix,"TaxTotal"));
  364. }
  365. if(insuranceTotal != null) {
  366. sb.append(insuranceTotal.toXMLString(preferredPrefix,"InsuranceTotal"));
  367. }
  368. if(shippingDiscount != null) {
  369. sb.append(shippingDiscount.toXMLString(preferredPrefix,"ShippingDiscount"));
  370. }
  371. if(orderDescription != null) {
  372. sb.append("<").append(preferredPrefix).append(":OrderDescription>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.orderDescription));
  373. sb.append("</").append(preferredPrefix).append(":OrderDescription>");
  374. }
  375. if(custom != null) {
  376. sb.append("<").append(preferredPrefix).append(":Custom>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.custom));
  377. sb.append("</").append(preferredPrefix).append(":Custom>");
  378. }
  379. if(msgSubID != null) {
  380. sb.append("<").append(preferredPrefix).append(":MsgSubID>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.msgSubID));
  381. sb.append("</").append(preferredPrefix).append(":MsgSubID>");
  382. }
  383. if(iPAddress != null) {
  384. sb.append("<").append(preferredPrefix).append(":IPAddress>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.iPAddress));
  385. sb.append("</").append(preferredPrefix).append(":IPAddress>");
  386. }
  387. if(shipToStore != null) {
  388. sb.append("<").append(preferredPrefix).append(":ShipToStore>").append(SDKUtil.escapeInvalidXmlCharsRegex(this.shipToStore));
  389. sb.append("</").append(preferredPrefix).append(":ShipToStore>");
  390. }
  391. if(name!=null){
  392. if(prefix!=null){
  393. sb.append("</").append(prefix).append(":").append(name).append(">");
  394. }
  395. else{
  396. sb.append("</").append(preferredPrefix).append(":").append(name).append(">");
  397. }
  398. }
  399. return sb.toString();
  400. }
  401. }