Skip to content

Commit 28d41ae

Browse files
author
srathod
committed
- Added junit dependency in pom.xml.
- Fixed some samplecodes.
1 parent e39c176 commit 28d41ae

File tree

7 files changed

+93
-60
lines changed

7 files changed

+93
-60
lines changed

pom.xml

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,67 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>net.authorize.sample</groupId>
5-
<artifactId>SampleCode</artifactId>
6-
<packaging>jar</packaging>
7-
<version>1.0</version>
8-
<name>SampleCode</name>
9-
<url>http://maven.apache.org</url>
10-
<dependencies>
11-
<dependency>
12-
<groupId>net.authorize</groupId>
13-
<artifactId>anet-java-sdk</artifactId>
14-
<version>1.8.6</version>
15-
</dependency>
16-
</dependencies>
17-
<build>
18-
<plugins>
19-
<plugin>
20-
<artifactId>maven-compiler-plugin</artifactId>
21-
<configuration>
22-
<source>1.7</source>
23-
<target>1.7</target>
24-
</configuration>
25-
</plugin>
26-
<plugin>
27-
<groupId>org.apache.maven.plugins</groupId>
28-
<artifactId>maven-shade-plugin</artifactId>
29-
<version>2.4.1</version>
30-
<executions>
31-
<execution>
32-
<phase>package</phase>
33-
<goals>
34-
<goal>shade</goal>
35-
</goals>
36-
<configuration>
37-
<finalName>SampleCode</finalName>
38-
<transformers>
39-
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
40-
<mainClass>net.authorize.sample.SampleCode</mainClass>
41-
</transformer>
42-
</transformers>
43-
</configuration>
44-
</execution>
45-
</executions>
46-
</plugin>
47-
</plugins>
48-
</build>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>net.authorize.sample</groupId>
5+
<artifactId>SampleCode</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.0</version>
8+
<name>SampleCode</name>
9+
<!-- <url>http://maven.apache.org</url> -->
10+
<dependencies>
11+
<dependency>
12+
<groupId>net.authorize</groupId>
13+
<artifactId>anet-java-sdk</artifactId>
14+
<version>1.8.6</version>
15+
</dependency>
16+
<dependency>
17+
<groupId>junit</groupId>
18+
<artifactId>junit</artifactId>
19+
<version>4.8.1</version>
20+
<scope>test</scope>
21+
</dependency>
22+
</dependencies>
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<artifactId>maven-compiler-plugin</artifactId>
27+
<configuration>
28+
<source>1.7</source>
29+
<target>1.7</target>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<groupId>org.apache.maven.plugins</groupId>
34+
<artifactId>maven-shade-plugin</artifactId>
35+
<version>2.4.1</version>
36+
<executions>
37+
<execution>
38+
<phase>package</phase>
39+
<goals>
40+
<goal>shade</goal>
41+
</goals>
42+
<configuration>
43+
<finalName>SampleCode</finalName>
44+
<transformers>
45+
<transformer
46+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
47+
<mainClass>net.authorize.sample.SampleCode</mainClass>
48+
</transformer>
49+
</transformers>
50+
</configuration>
51+
</execution>
52+
</executions>
53+
</plugin>
54+
<!-- <plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-surefire-plugin</artifactId>
57+
<version>2.9</version>
58+
<configuration>
59+
<includes>
60+
<include>net.authorize.sample.SampleCodeTest.*.java</include>
61+
</includes>
62+
<groups> </groups>
63+
</configuration>
64+
</plugin> -->
65+
</plugins>
66+
</build>
4967
</project>

src/main/java/net/authorize/sample/PaymentTransactions/CaptureFundsAuthorizedThroughAnotherChannel.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class CaptureFundsAuthorizedThroughAnotherChannel {
1313
// Run this sample from command line with:
1414
// java -jar target/ChargeCreditCard-jar-with-dependencies.jar
1515
//
16-
public static ANetApiResponse run(String apiLoginId, String transactionKey) {
16+
public static ANetApiResponse run(String apiLoginId, String transactionKey, Double amount) {
1717

1818
//Common code to set for all requests
1919
ApiOperationBase.setEnvironment(Environment.SANDBOX);
@@ -22,11 +22,20 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) {
2222
merchantAuthenticationType.setName(apiLoginId);
2323
merchantAuthenticationType.setTransactionKey(transactionKey);
2424
ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);
25+
26+
CreditCardType cc = new CreditCardType();
27+
cc.setCardNumber("4111111111111111");
28+
cc.setExpirationDate("2020-12");
29+
30+
PaymentType payment = new PaymentType();
31+
payment.setCreditCard(cc);
2532

2633
// Create the payment transaction request
2734
TransactionRequestType txnRequest = new TransactionRequestType();
2835
txnRequest.setTransactionType(TransactionTypeEnum.CAPTURE_ONLY_TRANSACTION.value());
29-
txnRequest.setRefTransId("2238786428");
36+
txnRequest.setAmount(new BigDecimal(amount.toString()));
37+
txnRequest.setPayment(payment);
38+
txnRequest.setAuthCode("ROHNFQ");
3039

3140
// Make the API Request
3241
CreateTransactionRequest apiRequest = new CreateTransactionRequest();

src/main/java/net/authorize/sample/PaymentTransactions/ChargeCustomerProfile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ChargeCustomerProfile {
1414
// java -jar target/ChargeCreditCard-jar-with-dependencies.jar
1515
//
1616
public static ANetApiResponse run(String apiLoginId, String transactionKey, String customerProfileId,
17-
String customerPaymentProfileId) {
17+
String customerPaymentProfileId, Double amount) {
1818

1919

2020
//Common code to set for all requests
@@ -37,7 +37,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey, Stri
3737
TransactionRequestType txnRequest = new TransactionRequestType();
3838
txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
3939
txnRequest.setProfile(profileToCharge);
40-
txnRequest.setAmount(new BigDecimal(500.00));
40+
txnRequest.setAmount(new BigDecimal(amount.toString()));
4141

4242

4343
CreateTransactionRequest apiRequest = new CreateTransactionRequest();

src/main/java/net/authorize/sample/PaymentTransactions/UpdateSplitTenderGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static ANetApiResponse run(String apiLoginId, String transactionKey) {
2424

2525
// Provide a split tender Id
2626
// 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";
27+
String splitTenderId = "115901";
2828

2929
// Create a request
3030
UpdateSplitTenderGroupRequest request = new UpdateSplitTenderGroupRequest();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static void RunMethod(String methodName)
161161
CreateCustomerProfileFromTransaction.run(apiLoginId, transactionKey);
162162
break;
163163
case "CaptureFundsAuthorizedThroughAnotherChannel":
164-
CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey);
164+
CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, 12.34);
165165
break;
166166
case "CapturePreviouslyAuthorizedAmount":
167167
CapturePreviouslyAuthorizedAmount.run(apiLoginId, transactionKey, transactionId);
@@ -179,7 +179,7 @@ private static void RunMethod(String methodName)
179179
CreateAnApplePayTransaction.run(apiLoginId, transactionKey);
180180
break;
181181
case "ChargeCustomerProfile":
182-
ChargeCustomerProfile.run(apiLoginId, transactionKey, "36731856", "33211899");
182+
ChargeCustomerProfile.run(apiLoginId, transactionKey, "36731856", "33211899" , 10.23);
183183
break;
184184
case "CreateSubscription":
185185
CreateSubscription.run(apiLoginId, transactionKey, (short)12, 10.21);

src/main/java/net/authorize/sample/SampleCodeTest/SampleCodeList.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ PaymentTransactions.CapturePreviouslyAuthorizedAmount 1 1
3535
PaymentTransactions.RefundTransaction 1 0
3636
PaymentTransactions.VoidTransaction 1 1
3737
PaymentTransactions.CreditBankAccount 1 0
38-
PaymentTransactions.ChargeCustomerProfile 1 0
39-
PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 0 0
40-
PaymentTransactions.AuthorizeCreditCard 1 0
38+
PaymentTransactions.ChargeCustomerProfile 1 1
39+
PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel 1 1
40+
PaymentTransactions.AuthorizeCreditCard 1 1
4141
PaymentTransactions.DebitBankAccount 0 1
4242
PaymentTransactions.ChargeTokenizedCreditCard 0 1
43-
PaymentTransactions.UpdateSplitTenderGroup 0 0
43+
PaymentTransactions.UpdateSplitTenderGroup 0 1
4444
TransactionReporting.GetTransactionList 0 1
4545
TransactionReporting.GetUnsettledTransactionList 0 1
4646
TransactionReporting.GetBatchStatistics 0 1
4747
TransactionReporting.GetSettledBatchList 0 1
4848
TransactionReporting.GetTransactionDetails 1 1
4949
ApplePayTransactions.CreateAnApplePayTransaction 0 0
5050
VisaCheckout.DecryptVisaCheckoutData 0 1
51-
VisaCheckout.CreateVisaCheckoutTransaction 0 0
51+
VisaCheckout.CreateVisaCheckoutTransaction 0 0

src/main/java/net/authorize/sample/SampleCodeTest/TestRunner.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import net.authorize.sample.CustomerProfiles.UpdateCustomerShippingAddress;
4747
import net.authorize.sample.CustomerProfiles.ValidateCustomerPaymentProfile;
4848
import net.authorize.sample.PaymentTransactions.AuthorizeCreditCard;
49+
import net.authorize.sample.PaymentTransactions.CaptureFundsAuthorizedThroughAnotherChannel;
4950
import net.authorize.sample.PaymentTransactions.CapturePreviouslyAuthorizedAmount;
5051
import net.authorize.sample.PaymentTransactions.ChargeCreditCard;
5152
import net.authorize.sample.PaymentTransactions.ChargeCustomerProfile;
@@ -374,7 +375,7 @@ public ANetApiResponse TestChargeCustomerProfile()
374375
CreateCustomerProfileResponse response = (CreateCustomerProfileResponse)CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail());
375376
CreateCustomerPaymentProfileResponse paymentProfileResponse = (CreateCustomerPaymentProfileResponse)CreateCustomerPaymentProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId());
376377
CreateTransactionResponse chargeResponse = (CreateTransactionResponse) ChargeCustomerProfile.run(apiLoginId, transactionKey,
377-
response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId());
378+
response.getCustomerProfileId(), paymentProfileResponse.getCustomerPaymentProfileId(), getAmount());
378379
DeleteCustomerProfile.run(apiLoginId, transactionKey, response.getCustomerProfileId());
379380

380381
return chargeResponse;
@@ -469,6 +470,11 @@ public ANetApiResponse TestCreateCustomerProfile()
469470
{
470471
return CreateCustomerProfile.run(apiLoginId, transactionKey, getEmail());
471472
}
473+
474+
public ANetApiResponse TestCaptureFundsAuthorizedThroughAnotherChannel()
475+
{
476+
return CaptureFundsAuthorizedThroughAnotherChannel.run(apiLoginId, transactionKey, getAmount());
477+
}
472478

473479
public ANetApiResponse TestCreateCustomerPaymentProfile()
474480
{

0 commit comments

Comments
 (0)