Skip to content

WIP #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

WIP #68

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/csv-plugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
291 changes: 291 additions & 0 deletions logs/application.log

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions src/main/java/Custom/ProcessPayment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package Custom;

import Api.PaymentsApi;
import Invokers.ApiClient;
import Model.*;
import com.cybersource.authsdk.core.MerchantConfig;
import samples.authentication.Data.Configuration;

import java.util.Properties;

public class ProcessPayment {
private static String responseCode = null;
private static String status = null;
private static Properties merchantProp;
public static boolean userCapture = false;

public static void main(String args[]) throws Exception {
run();
}

public static PtsV2PaymentsPost201Response run() {

CreatePaymentRequest requestObj = new CreatePaymentRequest();

Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation();
clientReferenceInformation.code("TC50171_4");
requestObj.clientReferenceInformation(clientReferenceInformation);

Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation();
processingInformation.capture(false);
if (userCapture) {
processingInformation.capture(true);
}

requestObj.processingInformation(processingInformation);

Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation();
Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard();
paymentInformationCard.number("4111111111111111");
paymentInformationCard.expirationMonth("12");
paymentInformationCard.expirationYear("2031");
paymentInformation.card(paymentInformationCard);

requestObj.paymentInformation(paymentInformation);

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("2222.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo();
orderInformationBillTo.firstName("John");
orderInformationBillTo.lastName("Doe");
orderInformationBillTo.address1("1 Market St");
orderInformationBillTo.locality("san francisco");
orderInformationBillTo.administrativeArea("CA");
orderInformationBillTo.postalCode("94105");
orderInformationBillTo.country("US");
orderInformationBillTo.email("[email protected]");
orderInformationBillTo.phoneNumber("4158880000");
orderInformation.billTo(orderInformationBillTo);

requestObj.orderInformation(orderInformation);

PtsV2PaymentsPost201Response result = null;
try {
merchantProp = Configuration.getMerchantDetails();
ApiClient apiClient = new ApiClient();
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
apiClient.merchantConfig = merchantConfig;

PaymentsApi apiInstance = new PaymentsApi(apiClient);
result = apiInstance.createPayment(requestObj);

responseCode = apiClient.responseCode;
status = apiClient.status;
System.out.println("ResponseCode :" + responseCode);
System.out.println("ResponseMessage :" + status);
System.out.println(result);

} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
69 changes: 69 additions & 0 deletions src/main/java/Custom/RefundPayment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package Custom;

import java.*;
import java.util.*;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;

import com.google.common.base.Strings;
import com.cybersource.authsdk.core.MerchantConfig;

import Api.*;
import Data.Configuration;
import Invokers.ApiClient;
import Invokers.ApiException;
import Model.*;
import samples.Payments.Payments.SimpleAuthorizationInternet;

public class RefundPayment {
private static String responseCode = null;
private static String status = null;
private static Properties merchantProp;

public static void main(String args[]) throws Exception {
run();
}

public static PtsV2PaymentsRefundPost201Response run() {
SimpleAuthorizationInternet.userCapture = true;
PtsV2PaymentsPost201Response paymentResponse = SimpleAuthorizationInternet.run();
String id = paymentResponse.getId();

RefundPaymentRequest requestObj = new RefundPaymentRequest();

Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation();
clientReferenceInformation.code("TEST_OUSSAMA");
requestObj.clientReferenceInformation(clientReferenceInformation);

Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation();
Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("10");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

requestObj.orderInformation(orderInformation);

PtsV2PaymentsRefundPost201Response result = null;
try {
merchantProp = Configuration.getMerchantDetails();
ApiClient apiClient = new ApiClient();
MerchantConfig merchantConfig = new MerchantConfig(merchantProp);
apiClient.merchantConfig = merchantConfig;

RefundApi apiInstance = new RefundApi(apiClient);
result = apiInstance.refundPayment(requestObj, id);

responseCode = apiClient.responseCode;
status = apiClient.status;
System.out.println("ResponseCode :" + responseCode);
System.out.println("ResponseMessage :" + status);
System.out.println(result);

} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
8 changes: 5 additions & 3 deletions src/main/java/Data/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static Properties getMerchantDetails() {

// HTTP_Signature = http_signature and JWT = jwt
props.setProperty("authenticationType", "http_signature");
props.setProperty("merchantID", "testrest");
props.setProperty("merchantID", "mirakl_slush0001");
props.setProperty("runEnvironment", "apitest.cybersource.com");
props.setProperty("requestJsonPath", "src/main/resources/request.json");

Expand All @@ -25,8 +25,10 @@ public static Properties getMerchantDetails() {

props.setProperty("keysDirectory", "src/main/resources");
// HTTP Parameters
props.setProperty("merchantKeyId", "08c94330-f618-42a3-b09d-e1e43be5efda");
props.setProperty("merchantsecretKey", "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=");
props.setProperty("merchantKeyId", "fe0c55d7-2525-4809-93bd-9746d10d5923");
props.setProperty("merchantsecretKey", "5JP/dtU7sJiZ9UrjQBvCXzOBIQwGlef19AVW90hp1Fs=");
props.setProperty("useMetaKey", "false");
props.setProperty("enableClientCert", "false");
// Logging to be enabled or not.
props.setProperty("enableLog", "true");
// Log directory Path
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/samples/Payments/Capture/CapturePayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public static PtsV2PaymentsCapturesPost201Response run() {
CapturePaymentRequest requestObj = new CapturePaymentRequest();

Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation();
clientReferenceInformation.code("TC50171_3");
clientReferenceInformation.code("OUSSAMA_TEST");
requestObj.clientReferenceInformation(clientReferenceInformation);

Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation();
Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("103.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("104.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static PtsV2PaymentsPost201Response run() {
Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard();
paymentInformationCard.number("4111111111111111");
paymentInformationCard.expirationMonth("12");
paymentInformationCard.expirationYear("2021");
paymentInformationCard.expirationYear("2025");
paymentInformationCard.type("001");
paymentInformation.card(paymentInformationCard);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("105.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static PtsV2PaymentsPost201Response run() {
CreatePaymentRequest requestObj = new CreatePaymentRequest();

Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation();
clientReferenceInformation.code("TC50171_3");
clientReferenceInformation.code("TC50171_4");
requestObj.clientReferenceInformation(clientReferenceInformation);

Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation();
Expand All @@ -41,14 +41,14 @@ public static PtsV2PaymentsPost201Response run() {
Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard();
paymentInformationCard.number("4111111111111111");
paymentInformationCard.expirationMonth("12");
paymentInformationCard.expirationYear("2031");
paymentInformationCard.expirationYear("2032");
paymentInformation.card(paymentInformationCard);

requestObj.paymentInformation(paymentInformation);

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("10002.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("106.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("107.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("108.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("109.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static PtsV2PaymentsPost201Response run() {

Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation();
Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails();
orderInformationAmountDetails.totalAmount("102.21");
orderInformationAmountDetails.totalAmount("110.21");
orderInformationAmountDetails.currency("USD");
orderInformation.amountDetails(orderInformationAmountDetails);

Expand Down
Loading