Skip to content

Commit 5d4f6eb

Browse files
committed
added envelope and transaction objects
1 parent ec77e9f commit 5d4f6eb

File tree

11 files changed

+518
-24
lines changed

11 files changed

+518
-24
lines changed

src/main/java/com/visa/inappsdk/connectors/inapp/datamodel/InAppBillTo.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,47 @@ public class InAppBillTo implements InAppBaseModel {
1111

1212
public final String FIRST_NAME = "firstName";
1313
public final String LAST_NAME = "lastName";
14+
public final String EMAIL = "email";
1415
public final String POSTAL_CODE = "postalCode";
16+
public final String STREET1 = "street1";
17+
public final String STREET2 = "street2";
18+
public final String CITY = "city";
19+
public final String STATE = "state";
20+
public final String COUNTRY = "country";
1521

1622
public String firstName;
1723
public String lastName;
24+
public String email;
1825
public String postalCode;
26+
public String street1;
27+
public String street2;
28+
public String city;
29+
public String state;
30+
public String country;
1931

2032
/**
2133
* @param firstName
2234
* @param lastName
35+
* @param email
2336
* @param postalCode
37+
* @param street1
38+
* @param street2
39+
* @param city
40+
* @param state
41+
* @param country
2442
*/
25-
public InAppBillTo(String firstName, String lastName, String postalCode) {
43+
public InAppBillTo(String firstName, String lastName, String email,
44+
String postalCode, String street1, String street2,
45+
String city, String state, String country) {
2646
this.firstName = firstName;
2747
this.lastName = lastName;
2848
this.postalCode = postalCode;
49+
this.email = email;
50+
this.street1 = street1;
51+
this.street2 = street2;
52+
this.city = city;
53+
this.state = state;
54+
this.country = country;
2955
}
3056

3157
@Override
@@ -37,8 +63,26 @@ public void updateEnvelope(SDKXMLParentNode request) {
3763
if (this.lastName != null) {
3864
billTo.addTextNode(billTo.getNamespace(), LAST_NAME, this.lastName);
3965
}
66+
if (this.email != null) {
67+
billTo.addTextNode(billTo.getNamespace(), EMAIL, this.email);
68+
}
4069
if (this.postalCode != null) {
4170
billTo.addTextNode(billTo.getNamespace(), POSTAL_CODE, this.postalCode);
4271
}
72+
if (this.street1 != null) {
73+
billTo.addTextNode(billTo.getNamespace(), STREET1, this.street1);
74+
}
75+
if (this.street2 != null) {
76+
billTo.addTextNode(billTo.getNamespace(), STREET2, this.street2);
77+
}
78+
if (this.city != null) {
79+
billTo.addTextNode(billTo.getNamespace(), CITY, this.city);
80+
}
81+
if (this.state != null) {
82+
billTo.addTextNode(billTo.getNamespace(), STATE, this.state);
83+
}
84+
if (this.country != null) {
85+
billTo.addTextNode(billTo.getNamespace(), COUNTRY, this.country);
86+
}
4387
}
4488
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.visa.inappsdk.connectors.inapp.datamodel;
2+
3+
import com.visa.inappsdk.soap.model.SDKXMLParentNode;
4+
5+
/**
6+
* Created by fzubair on 11/18/2015.
7+
*/
8+
public class InAppEncryptedPayment implements InAppBaseModel {
9+
10+
public final String OBJECT_NAME = "encryptedPayment";
11+
public final String DESCRIPTOR = "descriptor";
12+
public final String DATA = "data";
13+
14+
public String descriptor;
15+
public String data;
16+
17+
/**
18+
* All fields in constructor are required
19+
*
20+
* @param descriptor the FID
21+
* @param data encrypted payment data as a blob
22+
*/
23+
public InAppEncryptedPayment(String descriptor, String data) {
24+
this.descriptor = descriptor;
25+
this.data = data;
26+
}
27+
28+
@Override
29+
public void updateEnvelope(SDKXMLParentNode request) {
30+
if (validateObject()) {
31+
SDKXMLParentNode purchase = request.addNode(request.getNamespace(), OBJECT_NAME);
32+
if (this.descriptor != null) {
33+
purchase.addTextNode(purchase.getNamespace(), DESCRIPTOR, this.descriptor);
34+
}
35+
if (this.data != null) {
36+
purchase.addTextNode(null, DATA, this.data);
37+
}
38+
}
39+
}
40+
41+
private boolean validateObject() {
42+
return !(this.descriptor == null && this.data == null);
43+
}
44+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.visa.inappsdk.connectors.inapp.datamodel;
2+
3+
import com.visa.inappsdk.soap.model.SDKXMLParentNode;
4+
5+
/**
6+
* Describes fields in "item" object in WebService request
7+
*
8+
* @author fzubair
9+
*/
10+
public class InAppItem implements InAppBaseModel {
11+
12+
public final String OBJECT_NAME = "item";
13+
public final String ID = "id";
14+
public final String UNIT_PRICE = "unitPrice";
15+
public final String QUANTITY = "quantity";
16+
public final String PRODUCT_CODE = "productCode";
17+
public final String PRODUCT_NAME = "productName";
18+
public final String PRODUCT_SKU = "productSKU";
19+
public final String TAX_AMOUNT = "taxAmount";
20+
21+
public String unitPrice;
22+
public String quantity;
23+
public String id;
24+
public String productCode;
25+
public String productName;
26+
public String productSKU;
27+
public String taxAmount;
28+
29+
/**
30+
* @param id
31+
* @param unitPrice
32+
* @param quantity
33+
* @param productCode
34+
* @param productName
35+
* @param productSKU
36+
* @param taxAmount
37+
*/
38+
public InAppItem(String id, String unitPrice, String quantity, String productCode, String productName,
39+
String productSKU, String taxAmount) {
40+
this.id = id;
41+
this.unitPrice = unitPrice;
42+
this.quantity = quantity;
43+
this.productCode = productCode;
44+
this.productName = productName;
45+
this.productSKU = productSKU;
46+
this.taxAmount = taxAmount;
47+
}
48+
49+
@Override
50+
public void updateEnvelope(SDKXMLParentNode request) {
51+
if (validateObject()) {
52+
SDKXMLParentNode item = request.addNode(request.getNamespace(), OBJECT_NAME);
53+
if (this.id != null) {
54+
item.addAttribute(null, ID, this.id);
55+
}
56+
if (this.unitPrice != null) {
57+
item.addTextNode(item.getNamespace(), UNIT_PRICE, this.unitPrice);
58+
}
59+
if (this.quantity != null) {
60+
item.addTextNode(item.getNamespace(), QUANTITY, this.quantity);
61+
}
62+
if (this.productCode != null) {
63+
item.addTextNode(item.getNamespace(), PRODUCT_CODE, this.productCode);
64+
}
65+
if (this.productName != null) {
66+
item.addTextNode(item.getNamespace(), PRODUCT_NAME, this.productName);
67+
}
68+
if (this.productSKU != null) {
69+
item.addTextNode(item.getNamespace(), PRODUCT_SKU, this.productSKU);
70+
}
71+
if (this.taxAmount != null) {
72+
item.addTextNode(item.getNamespace(), TAX_AMOUNT, this.taxAmount);
73+
}
74+
}
75+
}
76+
77+
private boolean validateObject() {
78+
return !(this.id == null && this.unitPrice == null && this.quantity == null && this.productCode == null
79+
&& this.productName == null && this.productSKU == null && this.taxAmount == null);
80+
}
81+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package com.visa.inappsdk.connectors.inapp.envelopes;
2+
3+
import com.visa.inappsdk.common.error.SDKError;
4+
import com.visa.inappsdk.connectors.inapp.datamodel.InAppBillTo;
5+
import com.visa.inappsdk.connectors.inapp.datamodel.InAppCard;
6+
import com.visa.inappsdk.connectors.inapp.responses.InAppResponseObject;
7+
import com.visa.inappsdk.connectors.inapp.services.InAppEncryptPaymentDataService;
8+
import com.visa.inappsdk.connectors.inapp.transaction.InAppEnvelopeEncryptionTransactionObject;
9+
import com.visa.inappsdk.connectors.inapp.transaction.client.InAppTransactionObject;
10+
import com.visa.inappsdk.datamodel.response.SDKGatewayResponseType;
11+
import com.visa.inappsdk.datamodel.transaction.fields.SDKBillTo;
12+
import com.visa.inappsdk.datamodel.transaction.fields.SDKCardData;
13+
import com.visa.inappsdk.soap.model.SDKXMLParentNode;
14+
15+
import java.io.InputStream;
16+
17+
/**
18+
* Created by fzubair on 11/18/2015.
19+
*/
20+
public class InAppAndroidPayEnvelope extends InAppBaseEnvelope{
21+
22+
InAppAndroidPayEnvelope() {
23+
}
24+
25+
public InAppAndroidPayEnvelope(InAppTransactionObject transactionObject, String merchantId, String messageSignature) {
26+
createEnvelopeHeader(merchantId, messageSignature);
27+
InAppEnvelopeEncryptionTransactionObject encryptionTransactionObject = convertTransactionObject(transactionObject, merchantId);
28+
createEnvelopeBody(encryptionTransactionObject);
29+
}
30+
31+
private void createEnvelopeBody(InAppEnvelopeEncryptionTransactionObject paymentObject) {
32+
SDKXMLParentNode request = this.createRequestMessage();
33+
paymentObject.updateEnvelope(request);
34+
}
35+
36+
private InAppEnvelopeEncryptionTransactionObject convertTransactionObject(InAppTransactionObject transactionObject,
37+
String merchantId) {
38+
39+
String merchantReferenceCode = transactionObject.getMerchantReferenceCode();
40+
41+
SDKCardData cardData = transactionObject.getCardData();
42+
InAppCard card = null;
43+
if (cardData != null) {
44+
card = new InAppCard(cardData.getAccountNumber(), cardData.getCardExpirationMonth(),
45+
cardData.getCardExpirationYear(), cardData.getCvNumber(),
46+
cardData.getCardAccountNumberType());
47+
}
48+
49+
SDKBillTo billTo = transactionObject.getBillTo();
50+
InAppBillTo bill = null;
51+
if (billTo != null) {
52+
bill = new InAppBillTo(billTo.getFirstName(), billTo.getLastName(),
53+
billTo.getEmail(), billTo.getPostalCode(), billTo.getStreet1(),
54+
billTo.getStreet2(), billTo.getCity(), billTo.getState(),
55+
billTo.getCountry());
56+
}
57+
58+
InAppEncryptPaymentDataService inAppEncryptPaymentDataService = new InAppEncryptPaymentDataService(true, null);
59+
/*transactionObject.getPurchaseDetails().getCommerceIndicator());*/
60+
61+
// Faizan -- added the encrypted payment part
62+
//VMposEncryptedPayment encryptedPayment = transactionObject.getEncryptedPayment();
63+
64+
/* VMposEncryptedPayment encryptedPayment = new VMposEncryptedPayment();
65+
encryptedPayment.setEncodedData(getIDTechTestBlob());
66+
encryptedPayment.setEncodedMetaData(VMposMessageSignature.MetadataEncodedValue);
67+
encryptedPayment.setPaymentSolution(VMposMessageSignature.PAYMENT_SOLUTION_DEFAULT_VALUE);*/
68+
69+
InAppEnvelopeEncryptionTransactionObject inAppEncryptionTransactionObject = new InAppEnvelopeEncryptionTransactionObject(
70+
merchantId, merchantReferenceCode, card, bill, inAppEncryptPaymentDataService, CLIENT_LIBRARY/*, encryptedPayment*/);
71+
return inAppEncryptionTransactionObject;
72+
}
73+
74+
@Override
75+
protected void createEnvelopeHeader(String merchantID, String messageSignature) {
76+
super.createEnvelopeHeader(merchantID, messageSignature);
77+
}
78+
79+
@Override
80+
public SDKError parseGatewayError(InputStream inputStream) {
81+
return super.parseGatewayError(inputStream);
82+
}
83+
84+
@Override
85+
public InAppResponseObject parseResponse(InputStream inputStream) {
86+
return InAppResponseObject.createEncryptionResponse(inputStream, getResponseType());
87+
}
88+
89+
@Override
90+
public SDKGatewayResponseType getResponseType() {
91+
return SDKGatewayResponseType.SDK_ANDROID_PAY;
92+
}
93+
94+
/* protected InAppEncryptEnvelope(Parcel in) {
95+
super(in);
96+
}
97+
98+
public static final Parcelable.Creator<InAppEncryptEnvelope> CREATOR = new Parcelable.Creator<InAppEncryptEnvelope>() {
99+
100+
@Override
101+
public InAppEncryptEnvelope createFromParcel(Parcel in) {
102+
return new InAppEncryptEnvelope(in);
103+
}
104+
105+
@Override
106+
public InAppEncryptEnvelope[] newArray(int size) {
107+
return new InAppEncryptEnvelope[size];
108+
}
109+
};*/
110+
}

src/main/java/com/visa/inappsdk/connectors/inapp/envelopes/InAppEncryptEnvelope.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ private InAppEnvelopeEncryptionTransactionObject convertTransactionObject(InAppT
5050
InAppBillTo bill = null;
5151
if (billTo != null) {
5252
bill = new InAppBillTo(billTo.getFirstName(), billTo.getLastName(),
53-
billTo.getPostalCode());
53+
billTo.getEmail(), billTo.getPostalCode(), billTo.getStreet1(),
54+
billTo.getStreet2(), billTo.getCity(), billTo.getState(),
55+
billTo.getCountry());
5456
}
5557

5658
InAppEncryptPaymentDataService inAppEncryptPaymentDataService = new InAppEncryptPaymentDataService(true, null);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.visa.inappsdk.connectors.inapp.services;
2+
3+
import com.visa.inappsdk.soap.model.SDKXMLParentNode;
4+
5+
/**
6+
* Describes fields of "ccAuthService" object in WebService request
7+
*
8+
* Created by fzubair on 11/18/2015.
9+
*/
10+
public class InAppAuthService extends InAppBaseService {
11+
12+
public final String OBJECT_NAME = "ccAuthService";
13+
public final String RUN = "run";
14+
public final String COMMERCE_INDICATOR = "commerceIndicator";
15+
public final String BILL_PAYMENT = "billPayment";
16+
public final String PARTIAL_AUTH_INDICATOR = "partialAuthIndicator";
17+
18+
public String run;
19+
String commerceIndicator;
20+
public String partialAuthIndicator;
21+
22+
/**
23+
* All fields in constructor are required
24+
*
25+
* @param run
26+
*/
27+
public InAppAuthService(boolean run, String commerceIndicator,
28+
boolean partialAuthIndicator) {
29+
this.run = String.valueOf(run);
30+
this.commerceIndicator = commerceIndicator;
31+
this.partialAuthIndicator = String.valueOf(partialAuthIndicator);
32+
}
33+
34+
@Override
35+
public void updateEnvelope(SDKXMLParentNode request) {
36+
if (validateObject()) {
37+
SDKXMLParentNode creditService = request.addNode(request.getNamespace(), OBJECT_NAME);
38+
if (this.run != null) {
39+
creditService.addAttribute(null, RUN, this.run);
40+
}
41+
if (this.commerceIndicator != null) {
42+
creditService.addTextNode(creditService.getNamespace(), COMMERCE_INDICATOR, commerceIndicator);
43+
}
44+
if (this.partialAuthIndicator != null) {
45+
creditService.addTextNode(creditService.getNamespace(), PARTIAL_AUTH_INDICATOR, partialAuthIndicator);
46+
}
47+
}
48+
}
49+
50+
private boolean validateObject() {
51+
if (this.run == null) {
52+
return false;
53+
} else {
54+
return true;
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)