Guest User

Untitled

a guest
May 2nd, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package javatestsuite;
  6.  
  7. import com.exact.ews.transaction.Request;
  8. import com.exact.ews.transaction.enums.*;
  9. import com.exact.ews.Transporter;
  10.  
  11. import com.exact.ews.transaction.Response;
  12.  
  13. public class Purchase {
  14.  
  15. private String exactID, password, endpoint;
  16. private String transaction_Type, card_Number, expiry_Date, cardHoldersName,
  17. dollarAmount, reference_No, customer_Ref, reference_3, client_Email,
  18. userName;
  19.  
  20. private final Transporter trans;
  21. private Response resp;
  22.  
  23. public Purchase(String exactID, String password, String endpoint) {
  24. this.exactID = exactID;
  25. this.password = password;
  26. this.endpoint = endpoint;
  27.  
  28. trans = new Transporter(endpoint, null);
  29. reset();
  30.  
  31. }
  32.  
  33. public Response purchase() {
  34. final Request request = new Request(TransactionType.Purchase);
  35. request.setAmount(10.0f);
  36. request.setCardholderName(cardHoldersName);
  37. request.setCardNumber(card_Number);
  38. request.setCardExpiryDate(expiry_Date); //MMYY format
  39.  
  40. request.setExactId(exactID);
  41. request.setPassword(password);
  42.  
  43.  
  44. try {
  45. resp = trans.submit(request);
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. System.out.println("Submitting purchase failed");
  49. }
  50.  
  51. reset();
  52.  
  53. return resp;
  54.  
  55. }
  56.  
  57. public void reset() {
  58. transaction_Type = "00";
  59. card_Number = "4111111111111111";
  60. expiry_Date = "1109";
  61. cardHoldersName = "Captain Simple";
  62. dollarAmount = "1000";
  63. reference_No = "abcdefghij0123456789";
  64. customer_Ref = "abcdefghij0123456789";
  65. reference_3 = "abcdefghijklmnopqrst0123456789";
  66. client_Email = "captainsimple@acme.org";
  67.  
  68. for (int x = 0; x < 25; x++) {
  69. userName += "A";
  70. }
  71. }
  72.  
  73. public void setExactID(String exactID) {
  74. this.exactID = exactID;
  75. }
  76.  
  77. public void setPassword(String password) {
  78. this.password = password;
  79. }
  80.  
  81. public void setEndpoint(String endpoint) {
  82. this.endpoint = endpoint;
  83. }
  84.  
  85. public void setTransaction_Type(String transaction_Type) {
  86. this.transaction_Type = transaction_Type;
  87. }
  88.  
  89. public void setCard_Number(String card_Number) {
  90. this.card_Number = card_Number;
  91. }
  92.  
  93. public void setExpiry_Date(String expiry_Date) {
  94. this.expiry_Date = expiry_Date;
  95. }
  96.  
  97. public void setCardHoldersName(String cardHoldersName) {
  98. this.cardHoldersName = cardHoldersName;
  99. }
  100.  
  101. public void setDollarAmount(String dollarAmount) {
  102. this.dollarAmount = dollarAmount;
  103. }
  104.  
  105. public void setReference_No(String reference_No) {
  106. this.reference_No = reference_No;
  107. }
  108.  
  109. public void setCustomer_Ref(String customer_Ref) {
  110. this.customer_Ref = customer_Ref;
  111. }
  112.  
  113. public void setReference_3(String reference_3) {
  114. this.reference_3 = reference_3;
  115. }
  116.  
  117. public void setClient_Email(String client_Email) {
  118. this.client_Email = client_Email;
  119. }
  120.  
  121. public void setUserName(String userName) {
  122. this.userName = userName;
  123. }
  124. }
Add Comment
Please, Sign In to add comment