Skip to content

Commit a493fcf

Browse files
author
zhaque
committed
Conflicts: src/main/java/net/authorize/sample/SampleCode.java
2 parents 32a184e + 4c090e9 commit a493fcf

File tree

6 files changed

+274
-37
lines changed

6 files changed

+274
-37
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
package net.authorize.sample.PaymentTransactions;
3+
4+
import net.authorize.Environment;
5+
import net.authorize.api.contract.v1.*;
6+
import net.authorize.api.controller.base.ApiOperationBase;
7+
import net.authorize.api.controller.UpdateSplitTenderGroupController;
8+
9+
/**
10+
*
11+
* @author gnongsie
12+
*/
13+
public class UpdateSplitTenderGroup {
14+
public static void run(String apiLoginId, String transactionKey) {
15+
System.out.println("Update Split Tender Group Sample Code");
16+
17+
//Common code to set for all requests
18+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
19+
20+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
21+
merchantAuthenticationType.setName(apiLoginId);
22+
merchantAuthenticationType.setTransactionKey(transactionKey);
23+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
24+
25+
// Provide a split tender Id
26+
// To get a split Tender ID in sandbox, authorize any transaction with amount = 462.25 [if card present] and set allowPartialAuth = true
27+
String splitTenderId = "SPLIT_TENDER_ID";
28+
29+
// Create a request
30+
UpdateSplitTenderGroupRequest request = new UpdateSplitTenderGroupRequest();
31+
request.setMerchantAuthentication(merchantAuthenticationType);
32+
request.setSplitTenderId(splitTenderId);
33+
34+
// Set the Split Tender Status (VOIDED or HELD or COMPLETED)
35+
request.setSplitTenderStatus(SplitTenderStatusEnum.VOIDED);
36+
37+
UpdateSplitTenderGroupController controller = new UpdateSplitTenderGroupController(request);
38+
controller.execute();
39+
40+
UpdateSplitTenderGroupResponse response = controller.getApiResponse();
41+
42+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK){
43+
System.out.println(response.getMessages().getMessage().get(0).getCode());
44+
System.out.println(response.getMessages().getMessage().get(0).getText());
45+
}
46+
47+
else {
48+
System.out.println("Error: " + response.getMessages().getMessage().get(0).getCode() +
49+
" " + response.getMessages().getMessage().get(0).getText());
50+
}
51+
}
52+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package net.authorize.sample.PaypalExpressCheckout;
2+
3+
import java.math.BigDecimal;
4+
5+
import net.authorize.Environment;
6+
import net.authorize.api.contract.v1.*;
7+
import net.authorize.api.controller.base.ApiOperationBase;
8+
import net.authorize.api.controller.CreateTransactionController;
9+
10+
public class AuthorizationOnlyContinued {
11+
12+
13+
public static void run(String apiLoginId, String transactionKey, String transactionId, String payerId) {
14+
15+
System.out.println("PayPal Authorize Only-Continue Transaction");
16+
//Common code to set for all requests
17+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
18+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
19+
merchantAuthenticationType.setName(apiLoginId);
20+
merchantAuthenticationType.setTransactionKey(transactionKey);
21+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
22+
23+
// Populate PayPal Transaction Data
24+
PayPalType payPalType = new PayPalType();
25+
payPalType.setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
26+
payPalType.setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
27+
payPalType.setPayerID(payerId);
28+
29+
// Populate the payment data
30+
PaymentType paymentType = new PaymentType();
31+
paymentType.setPayPal(payPalType);
32+
33+
// Create the payment transaction request
34+
TransactionRequestType txnRequest = new TransactionRequestType();
35+
txnRequest.setTransactionType(TransactionTypeEnum.AUTH_ONLY_CONTINUE_TRANSACTION.value());
36+
txnRequest.setPayment(paymentType);
37+
txnRequest.setAmount(new BigDecimal(500.00));
38+
txnRequest.setRefTransId(transactionId);
39+
40+
// Make the API Request
41+
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
42+
apiRequest.setTransactionRequest(txnRequest);
43+
CreateTransactionController controller = new CreateTransactionController(apiRequest);
44+
controller.execute();
45+
46+
47+
CreateTransactionResponse response = controller.getApiResponse();
48+
49+
if (response!=null) {
50+
51+
// If API Response is ok, go ahead and check the transaction response
52+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
53+
54+
TransactionResponse result = response.getTransactionResponse();
55+
if (result.getResponseCode().equals("1")) {
56+
System.out.println(result.getResponseCode());
57+
System.out.println("Successful PayPal Transaction");
58+
//System.out.println("Reference Transaction ID: " + result.getRefTransID());
59+
System.out.println("Description: "+result.getMessages().getMessage().get(0).getDescription());
60+
}
61+
else
62+
{
63+
System.out.println(result.getResponseCode());
64+
System.out.println("Failed Transaction Description: "+result.getErrors().getError().get(0).getErrorText());
65+
}
66+
}
67+
else
68+
{
69+
System.out.println("Failed Transaction: "+response.getMessages().getResultCode());
70+
System.out.println("Error Code: "+response.getMessages().getMessage().get(0).getCode());
71+
}
72+
}
73+
74+
}
75+
76+
77+
78+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package net.authorize.sample.PaypalExpressCheckout;
2+
3+
import java.math.BigDecimal;
4+
5+
import net.authorize.Environment;
6+
import net.authorize.api.contract.v1.*;
7+
import net.authorize.api.controller.base.ApiOperationBase;
8+
import net.authorize.api.controller.CreateTransactionController;
9+
10+
public class Credit {
11+
12+
public static void run(String apiLoginId, String transactionKey, String transactionId) {
13+
14+
System.out.println("PayPal Credit Transaction");
15+
//Common code to set for all requests
16+
ApiOperationBase.setEnvironment(Environment.SANDBOX);
17+
MerchantAuthenticationType merchantAuthenticationType = new MerchantAuthenticationType() ;
18+
merchantAuthenticationType.setName(apiLoginId);
19+
merchantAuthenticationType.setTransactionKey(transactionKey);
20+
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
21+
22+
// Populate PayPal Transaction Data
23+
PayPalType payPalType = new PayPalType();
24+
payPalType.setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
25+
payPalType.setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
26+
27+
// Populate the payment data
28+
PaymentType paymentType = new PaymentType();
29+
paymentType.setPayPal(payPalType);
30+
31+
// Create the payment transaction request
32+
TransactionRequestType txnRequest = new TransactionRequestType();
33+
txnRequest.setTransactionType(TransactionTypeEnum.REFUND_TRANSACTION.value());
34+
txnRequest.setPayment(paymentType);
35+
txnRequest.setAmount(new BigDecimal(500.00));
36+
txnRequest.setRefTransId(transactionId);
37+
38+
// Make the API Request
39+
CreateTransactionRequest apiRequest = new CreateTransactionRequest();
40+
apiRequest.setTransactionRequest(txnRequest);
41+
CreateTransactionController controller = new CreateTransactionController(apiRequest);
42+
controller.execute();
43+
44+
45+
CreateTransactionResponse response = controller.getApiResponse();
46+
47+
if (response!=null) {
48+
49+
// If API Response is ok, go ahead and check the transaction response
50+
if (response.getMessages().getResultCode() == MessageTypeEnum.OK) {
51+
52+
TransactionResponse result = response.getTransactionResponse();
53+
if (result.getResponseCode().equals("1")) {
54+
System.out.println(result.getResponseCode());
55+
System.out.println("Successful PayPal Transaction");
56+
//System.out.println("Reference Transaction ID: " + result.getRefTransID());
57+
System.out.println(result.getMessages().getMessage().get(0).getDescription());
58+
}
59+
else
60+
{
61+
System.out.println("Transaction Error: "+result.getErrors().getError().get(0).getErrorCode()+" "+result.getErrors().getError().get(0).getErrorText());
62+
63+
}
64+
}
65+
else
66+
{
67+
System.out.println("Error: "+response.getMessages().getMessage().get(0).getCode()+ " " + response.getMessages().getMessage().get(0).getText());
68+
69+
}
70+
}
71+
72+
}
73+
74+
75+
76+
}

src/main/java/net/authorize/sample/RecurringBilling/CreateSubscription.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public static void run(String apiLoginId, String transactionKey) {
5050

5151
ARBSubscriptionType arbSubscriptionType = new ARBSubscriptionType();
5252
arbSubscriptionType.setPaymentSchedule(schedule);
53-
arbSubscriptionType.setAmount(new BigDecimal(10.29));
54-
arbSubscriptionType.setTrialAmount(new BigDecimal(0.00));
53+
arbSubscriptionType.setAmount(new BigDecimal("10.29"));
54+
arbSubscriptionType.setTrialAmount(new BigDecimal("0.00"));
5555
arbSubscriptionType.setPayment(paymentType);
5656

5757
NameAndAddressType name = new NameAndAddressType();
@@ -80,4 +80,4 @@ public static void run(String apiLoginId, String transactionKey) {
8080
}
8181
}
8282
}
83-
}
83+
}

src/main/java/net/authorize/sample/SampleCode.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import net.authorize.sample.TransactionReporting.*;
1313
import net.authorize.sample.CustomerProfiles.*;
1414

15-
1615
/**
1716
* Created by anetdeveloper on 8/5/15.
1817
*/
@@ -88,13 +87,12 @@ private static void ShowMethods()
8887
System.out.println(" ChargeTokenizedCreditCard");
8988
System.out.println(" ChargeCustomerProfile");
9089
System.out.println(" CreateSubscription");
91-
System.out.println(" GetSubscription");
9290
System.out.println(" GetSubscriptionStatus");
9391
System.out.println(" CancelSubscription");
9492
System.out.println(" UpdateSubscription");
9593
System.out.println(" GetListOfSubscriptions");
9694
System.out.println(" GetBatchStatistics");
97-
//System.out.println(" GetSettledBatchList");
95+
System.out.println(" GetSettledBatchList");
9896
System.out.println(" GetTransactionList");
9997
System.out.println(" GetUnsettledTransactionList");
10098
System.out.println(" GetTransactionDetails");
@@ -105,8 +103,8 @@ private static void ShowMethods()
105103
System.out.println(" DeleteCustomerProfile");
106104
System.out.println(" DeleteCustomerShippingAddress");
107105
System.out.println(" GetCustomerPaymentProfile");
108-
System.out.println(" GetCustomerPaymentProfileList");
109106
System.out.println(" GetCustomerProfile");
107+
System.out.println(" GetCustomerProfileIds");
110108
System.out.println(" GetCustomerShippingAddress");
111109
System.out.println(" GetHostedProfilePage");
112110
System.out.println(" UpdateCustomerPaymentProfile");
@@ -116,7 +114,10 @@ private static void ShowMethods()
116114
System.out.println(" PayPalAuthorizationOnly");
117115
System.out.println(" PayPalAuthorizeCaptureContinue");
118116
System.out.println(" PayPalGetDetails");
119-
System.out.println(" PayPalPriorAuthorizationCapture");
117+
System.out.println(" PayPalPriorAuthorizationCapture");
118+
System.out.println(" PayPalAuthorizeOnlyContinue");
119+
System.out.println(" PayPalCredit");
120+
System.out.println(" UpdateSplitTenderGroup");
120121
}
121122

122123
private static void RunMethod(String methodName)
@@ -125,10 +126,10 @@ private static void RunMethod(String methodName)
125126
// You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/
126127
String apiLoginId = "5KP3u95bQpv";
127128
String transactionKey = "4Ktq966gC55GAX7S";
128-
129-
//Set transactionID and payerID here for some function calls
130-
String transactionID = "";
131-
String payerID = "";
129+
//Update the payedId with which you want to run the sample code
130+
String payerId = "";
131+
//Update the transactionId with which you want to run the sample code
132+
String transactionId = "";
132133

133134
switch (methodName) {
134135
case "VisaCheckoutDecrypt":
@@ -173,9 +174,6 @@ private static void RunMethod(String methodName)
173174
case "CreateSubscription":
174175
CreateSubscription.run(apiLoginId, transactionKey);
175176
break;
176-
case "GetSubscription":
177-
GetSubscription.run(apiLoginId, transactionKey);
178-
break;
179177
case "GetSubscriptionStatus":
180178
GetSubscriptionStatus.run(apiLoginId, transactionKey);
181179
break;
@@ -191,9 +189,9 @@ private static void RunMethod(String methodName)
191189
case "GetBatchStatistics":
192190
GetBatchStatistics.run(apiLoginId, transactionKey);
193191
break;
194-
/*case "GetSettledBatchList":
192+
case "GetSettledBatchList":
195193
GetSettledBatchList.run(apiLoginId, transactionKey);
196-
break;*/
194+
break;
197195
case "GetTransactionList":
198196
GetTransactionList.run(apiLoginId, transactionKey);
199197
break;
@@ -224,12 +222,12 @@ private static void RunMethod(String methodName)
224222
case "GetCustomerPaymentProfile":
225223
GetCustomerPaymentProfile.run(apiLoginId, transactionKey);
226224
break;
227-
case "GetCustomerPaymentProfileList":
228-
GetCustomerPaymentProfileList.run(apiLoginId, transactionKey);
229-
break;
230225
case "GetCustomerProfile":
231226
GetCustomerProfile.run(apiLoginId, transactionKey);
232227
break;
228+
case "GetCustomerProfileIds":
229+
GetCustomerProfileIds.run(apiLoginId, transactionKey);
230+
break;
233231
case "GetCustomerShippingAddress":
234232
GetCustomerShippingAddress.run(apiLoginId, transactionKey);
235233
break;
@@ -252,17 +250,26 @@ private static void RunMethod(String methodName)
252250
AuthorizationOnly.run(apiLoginId, transactionKey);
253251
break;
254252
case "PayPalAuthorizeCaptureContinue":
255-
AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, transactionID, payerID);
253+
AuthorizationAndCaptureContinue.run(apiLoginId, transactionKey, transactionId, payerId);
256254
break;
255+
case "PayPalAuthorizeOnlyContinue":
256+
AuthorizationOnlyContinued.run(apiLoginId, transactionKey, transactionId, payerId);
257+
break;
258+
case "PayPalCredit":
259+
Credit.run(apiLoginId, transactionKey, transactionId);
260+
break;
257261
case "PayPalGetDetails":
258262
GetDetails.run(apiLoginId, transactionKey);
259-
case "PaypalPriorAuthorizationCapture":
260-
String transactionId = "2241801682"; // Use a valid transaction ID here
263+
case "PaypalPriorAuthorizationCapture":
264+
transactionId = "2241801682"; // Use a valid transaction ID here
261265
PriorAuthorizationCapture.run(apiLoginId, transactionKey, transactionId);
262266
break;
267+
case "UpdateSplitTenderGroup":
268+
UpdateSplitTenderGroup.run(apiLoginId, transactionKey);
269+
break;
263270
default:
264271
ShowUsage();
265272
break;
266273
}
267274
}
268-
}
275+
}

0 commit comments

Comments
 (0)