Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javatestsuite;
- import com.exact.ews.transaction.Request;
- import com.exact.ews.transaction.enums.*;
- import com.exact.ews.Transporter;
- import com.exact.ews.transaction.Response;
- public class Purchase {
- private String exactID, password, endpoint;
- private String transaction_Type, card_Number, expiry_Date, cardHoldersName,
- dollarAmount, reference_No, customer_Ref, reference_3, client_Email,
- userName;
- private final Transporter trans;
- private Response resp;
- public Purchase(String exactID, String password, String endpoint) {
- this.exactID = exactID;
- this.password = password;
- this.endpoint = endpoint;
- trans = new Transporter(endpoint, null);
- reset();
- }
- public Response purchase() {
- final Request request = new Request(TransactionType.Purchase);
- request.setAmount(10.0f);
- request.setCardholderName(cardHoldersName);
- request.setCardNumber(card_Number);
- request.setCardExpiryDate(expiry_Date); //MMYY format
- request.setExactId(exactID);
- request.setPassword(password);
- try {
- resp = trans.submit(request);
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println("Submitting purchase failed");
- }
- reset();
- return resp;
- }
- public void reset() {
- transaction_Type = "00";
- card_Number = "4111111111111111";
- expiry_Date = "1109";
- cardHoldersName = "Captain Simple";
- dollarAmount = "1000";
- reference_No = "abcdefghij0123456789";
- customer_Ref = "abcdefghij0123456789";
- reference_3 = "abcdefghijklmnopqrst0123456789";
- client_Email = "captainsimple@acme.org";
- for (int x = 0; x < 25; x++) {
- userName += "A";
- }
- }
- public void setExactID(String exactID) {
- this.exactID = exactID;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public void setEndpoint(String endpoint) {
- this.endpoint = endpoint;
- }
- public void setTransaction_Type(String transaction_Type) {
- this.transaction_Type = transaction_Type;
- }
- public void setCard_Number(String card_Number) {
- this.card_Number = card_Number;
- }
- public void setExpiry_Date(String expiry_Date) {
- this.expiry_Date = expiry_Date;
- }
- public void setCardHoldersName(String cardHoldersName) {
- this.cardHoldersName = cardHoldersName;
- }
- public void setDollarAmount(String dollarAmount) {
- this.dollarAmount = dollarAmount;
- }
- public void setReference_No(String reference_No) {
- this.reference_No = reference_No;
- }
- public void setCustomer_Ref(String customer_Ref) {
- this.customer_Ref = customer_Ref;
- }
- public void setReference_3(String reference_3) {
- this.reference_3 = reference_3;
- }
- public void setClient_Email(String client_Email) {
- this.client_Email = client_Email;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- }
Add Comment
Please, Sign In to add comment