index
int64 0
0
| repo_id
stringlengths 9
205
| file_path
stringlengths 31
246
| content
stringlengths 1
12.2M
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/ObjectHolder.java
|
package com.paypal.api.payments;
public class ObjectHolder {
public static String refundId;
}
| 3,700 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/PaymentHistoryTestCase.java
|
package com.paypal.api.payments;
import java.util.ArrayList;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;
public class PaymentHistoryTestCase {
public static final Integer COUNT = 1;
public static final String NEXTID = "1";
public static PaymentHistory createPaymentHistory() {
List<Payment> payments = new ArrayList<Payment>();
payments.add(PaymentTestCase.createPayment());
PaymentHistory paymentHistory = new PaymentHistory();
paymentHistory.setCount(COUNT);
paymentHistory.setPayments(payments);
paymentHistory.setNextId(NEXTID);
return paymentHistory;
}
@Test(groups = "unit")
public void testConstruction() {
PaymentHistory paymentHistory = PaymentHistoryTestCase
.createPaymentHistory();
Assert.assertEquals(paymentHistory.getCount(), COUNT.intValue());
Assert.assertEquals(paymentHistory.getNextId(), NEXTID);
Assert.assertEquals(paymentHistory.getPayments().size(), 1);
}
@Test(groups = "unit")
public void testTOJSON() {
PaymentHistory paymentHistory = PaymentHistoryTestCase
.createPaymentHistory();
Assert.assertEquals(paymentHistory.toJSON().length() == 0, false);
}
@Test(groups = "unit")
public void testTOString() {
PaymentHistory paymentHistory = PaymentHistoryTestCase
.createPaymentHistory();
Assert.assertEquals(paymentHistory.toString().length() == 0, false);
}
}
| 3,701 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/ItemTestCase.java
|
package com.paypal.api.payments;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ItemTestCase {
public static final String NAME = "Sample Item";
public static final String CURRENCY = "USD";
public static final String PRICE = "8.82";
public static final String TAX = "1.68";
public static final String QUANTITY = "5";
public static final String SKU = "123";
public static Item createItem() {
Item item = new Item();
item.setName(NAME);
item.setCurrency(CURRENCY);
item.setPrice(PRICE);
item.setTax(TAX);
item.setQuantity(QUANTITY);
item.setSku(SKU);
return item;
}
@Test(groups = "unit")
public void testConstruction() {
Item item = createItem();
Assert.assertEquals(item.getName(), NAME);
Assert.assertEquals(item.getCurrency(), CURRENCY);
Assert.assertEquals(item.getPrice(), PRICE);
Assert.assertEquals(item.getTax(), TAX);
Assert.assertEquals(item.getQuantity(), QUANTITY);
Assert.assertEquals(item.getSku(), SKU);
}
@Test(groups = "unit")
public void testTOJSON() {
Item item = createItem();
Assert.assertEquals(item.toJSON().length() == 0, false);
}
@Test(groups = "unit")
public void testTOString() {
Item item = createItem();
Assert.assertEquals(item.toString().length() == 0, false);
}
}
| 3,702 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/PaymentTestCase.java
|
package com.paypal.api.payments;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.paypal.base.rest.PayPalRESTException;
import com.paypal.base.util.TestConstants;
public class PaymentTestCase {
private static final Logger logger = Logger
.getLogger(PaymentTestCase.class);
private String createdPaymentID = null;
public static final String CREATEDTIME = "2013-01-17T18:12:02.347Z";
public static final String CANCELURL = "http://somedomain.com";
public static final String RETURNURL = "http://somedomain.com";
public static final String INTENT = "sale";
public static final String EXPERIENCEPROFILEID = "XP-ABCD-1234-EFGH-5678";
public static final String ID = "12345";
public static Payment payment;
public static Payment createCallPayment() {
Address billingAddress = AddressTestCase.createAddress();
CreditCard creditCard = new CreditCard();
creditCard.setBillingAddress(billingAddress);
creditCard.setCvv2(617);
creditCard.setExpireMonth(01);
creditCard.setExpireYear(2020);
creditCard.setFirstName("Joe");
creditCard.setLastName("Shopper");
creditCard.setNumber("4422009910903049");
creditCard.setType("visa");
ItemList itemList = new ItemList();
List<Item> items = new ArrayList<Item>();
items.add(ItemTestCase.createItem());
itemList.setItems(items);
Details amountDetails = new Details();
amountDetails.setTax("8.40");
amountDetails.setSubtotal("44.10");
amountDetails.setShipping("4.99");
Amount amount = new Amount();
amount.setDetails(amountDetails);
amount.setCurrency("USD");
amount.setTotal("57.49");
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setItemList(itemList);
transaction
.setDescription("This is the payment transaction description.");
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
FundingInstrument fundingInstrument = new FundingInstrument();
fundingInstrument.setCreditCard(creditCard);
List<FundingInstrument> fundingInstrumentList = new ArrayList<FundingInstrument>();
fundingInstrumentList.add(fundingInstrument);
Payer payer = new Payer();
payer.setFundingInstruments(fundingInstrumentList);
payer.setPaymentMethod("credit_card");
Payment payment = new Payment();
payment.setIntent("sale");
// payment.setExperienceProfileId(EXPERIENCEPROFILEID);
payment.setPayer(payer);
payment.setTransactions(transactions);
return payment;
}
public static Payment createPayment() {
Address billingAddress = AddressTestCase.createAddress();
CreditCard creditCard = new CreditCard();
creditCard.setBillingAddress(billingAddress);
creditCard.setCvv2(874);
creditCard.setExpireMonth(11);
creditCard.setExpireYear(2018);
creditCard.setFirstName("Joe");
creditCard.setLastName("Shopper");
creditCard.setNumber("4111111111111111");
creditCard.setType("visa");
Details details = new Details();
details.setShipping("10");
details.setSubtotal("75");
details.setTax("15");
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setTotal("100");
amount.setDetails(details);
Payee payee = new Payee();
payee.setMerchantId("NMXBYHSEL4FEY");
ItemList itemList = new ItemList();
List<Item> items = new ArrayList<Item>();
items.add(ItemTestCase.createItem());
itemList.setItems(items);
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setItemList(itemList);
transaction.setPayee(payee);
transaction
.setDescription("This is the payment transaction description.");
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
FundingInstrument fundingInstrument = new FundingInstrument();
fundingInstrument.setCreditCard(creditCard);
List<FundingInstrument> fundingInstrumentList = new ArrayList<FundingInstrument>();
fundingInstrumentList.add(fundingInstrument);
Payer payer = new Payer();
payer.setFundingInstruments(fundingInstrumentList);
payer.setPaymentMethod("credit_card");
List<Links> links = new ArrayList<Links>();
links.add(LinksTestCase.createLinks());
RedirectUrls redirectUrls = RedirectUrlsTestCase.createRedirectUrls();
Payment payment = new Payment();
payment.setIntent("sale");
payment.setExperienceProfileId(EXPERIENCEPROFILEID);
payment.setId(ID);
payment.setPayer(payer);
payment.setTransactions(transactions);
payment.setCreateTime(CREATEDTIME);
payment.setLinks(links);
payment.setRedirectUrls(redirectUrls);
return payment;
}
public static Payment createPaymentForExecution() {
Details details = new Details();
details.setShipping("10");
details.setSubtotal("75");
details.setTax("15");
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setTotal("100");
amount.setDetails(details);
RedirectUrls redirectUrls = new RedirectUrls();
redirectUrls.setCancelUrl("http://www.hawaii.com");
redirectUrls.setReturnUrl("http://www.hawaii.com");
ItemList itemList = new ItemList();
List<Item> items = new ArrayList<Item>();
items.add(ItemTestCase.createItem());
itemList.setItems(items);
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setItemList(itemList);
transaction
.setDescription("This is the payment transaction description.");
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
Payment payment = new Payment();
payment.setIntent("sale");
payment.setPayer(payer);
payment.setRedirectUrls(redirectUrls);
payment.setTransactions(transactions);
return payment;
}
@Test(groups = "unit")
public void testConstruction() {
Payment payment = createPayment();
Assert.assertEquals(payment.getPayer().getPaymentMethod(),
"credit_card");
Assert.assertEquals(payment.getTransactions().get(0).getAmount()
.getTotal(), "100");
Assert.assertEquals(payment.getIntent(), INTENT);
Assert.assertEquals(payment.getExperienceProfileId(), EXPERIENCEPROFILEID);
Assert.assertEquals(payment.getRedirectUrls().getCancelUrl(),
RedirectUrlsTestCase.CANCELURL);
Assert.assertEquals(payment.getRedirectUrls().getReturnUrl(),
RedirectUrlsTestCase.RETURNURL);
Assert.assertEquals(payment.getId(), ID);
Assert.assertEquals(payment.getCreateTime(), CREATEDTIME);
Assert.assertEquals(payment.getLinks().size(), 1);
}
@Test(groups = "integration")
public void testCreatePaymentAPI() throws PayPalRESTException {
Payment payment = createCallPayment();
Payment createdPayment = payment.create(TestConstants.SANDBOX_CONTEXT);
createdPaymentID = createdPayment.getId();
String json = Payment.getLastResponse();
JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(json);
JsonObject obj = jsonElement.getAsJsonObject();
// State of a created payment object is approved
Assert.assertEquals(obj.get("state").getAsString()
.equalsIgnoreCase("approved"),true);
obj.get("transactions").getAsJsonArray().get(0)
.getAsJsonObject().get("related_resources").getAsJsonArray()
.get(0).getAsJsonObject().get("sale").getAsJsonObject()
.get("id").getAsString();
}
@Test(groups = "integration", dependsOnMethods = { "testCreatePaymentAPI" })
public void testGetPaymentAPI() throws PayPalRESTException {
payment = Payment.get(TestConstants.SANDBOX_CONTEXT, createdPaymentID);
}
@Test(groups = "integration", enabled = false, dependsOnMethods = { "testGetPaymentAPI" })
public void testExecutePayment() throws PayPalRESTException, IOException {
Payment exPayment = createPaymentForExecution();
exPayment = exPayment.create(TestConstants.SANDBOX_CONTEXT);
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
String payerId = in.readLine();
PaymentExecution paymentExecution = new PaymentExecution();
paymentExecution.setPayerId(payerId);
exPayment = exPayment
.execute(TestConstants.SANDBOX_CONTEXT, paymentExecution);
}
@Test(groups = "integration", dependsOnMethods = { "testGetPaymentAPI" })
public void testGetPaymentHistoryAPI() throws PayPalRESTException {
Map<String, String> containerMap = new HashMap<String, String>();
containerMap.put("count", "10");
Payment.list(TestConstants.SANDBOX_CONTEXT, containerMap);
}
@Test(groups = "integration", dependsOnMethods = { "testGetPaymentHistoryAPI" })
public void testFailCreatePaymentAPI() {
Payment payment = new Payment();
try {
payment.create(TestConstants.SANDBOX_CONTEXT);
} catch (PayPalRESTException e) {
Assert.assertEquals(e.getCause().getClass().getSimpleName(),
"HttpErrorException");
}
}
@Test(groups = "integration", dependsOnMethods = { "testFailCreatePaymentAPI" })
public void testFailGetPaymentAPI() {
try {
Payment.get(TestConstants.SANDBOX_CONTEXT, (String) null);
} catch (IllegalArgumentException e) {
Assert.assertTrue(e != null,
"Illegal Argument Exception not thrown for null arguments");
} catch (PayPalRESTException e) {
logger.error("response code: " + e.getResponsecode());
logger.error("message: " + e.getMessage());
Assert.fail();
}
}
@Test(groups = "unit")
public void testTOJSON() {
try {
Payment payment = createPayment();
Assert.assertEquals(payment.toJSON().length() == 0, false);
} catch (IllegalStateException e) {
}
}
@Test(groups = "unit")
public void testTOString() {
try {
Payment payment = createPayment();
Assert.assertEquals(payment.toString().length() == 0, false);
} catch (IllegalStateException e) {
}
}
}
| 3,703 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/PayeeTestCase.java
|
package com.paypal.api.payments;
import org.testng.Assert;
import org.testng.annotations.Test;
public class PayeeTestCase {
public static final String MERCHANTID = "12345";
public static final String EMAIL = "[email protected]";
public static final Phone PHONE = new Phone("1", "716-298-1822");
public static Payee createPayee() {
Payee payee = new Payee();
payee.setMerchantId(MERCHANTID);
payee.setEmail(EMAIL);
payee.setPhone(PHONE);
return payee;
}
@Test(groups = "unit")
public void testConstruction() {
Payee payee = createPayee();
Assert.assertEquals(payee.getMerchantId(), MERCHANTID);
Assert.assertEquals(payee.getEmail(), EMAIL);
Assert.assertEquals(payee.getPhone(), PHONE);
}
@Test(groups = "unit")
public void testTOJSON() {
Payee payee = createPayee();
Assert.assertEquals(payee.toJSON().length()==0, false);
}
@Test(groups = "unit")
public void testTOString() {
Payee payee = createPayee();
Assert.assertEquals(payee.toString().length()==0, false);
}
}
| 3,704 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/SaleTestCase.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalRESTException;
import com.paypal.base.util.TestConstants;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class SaleTestCase {
public static final Logger logger = Logger.getLogger(SaleTestCase.class);
public static final String ID = "12345";
public static final String PARENTPAYMENT = "12345";
public static final String STATE = "Approved";
public static final Amount AMOUNT = AmountTestCase.createAmount("100.00");
public static final String CREATEDTIME = "2013-01-17T18:12:02.347Z";
public String SALE_ID = null;
public static Sale createSale() {
List<Links> links = new ArrayList<Links>();
links.add(LinksTestCase.createLinks());
Sale sale = new Sale();
sale.setAmount(AMOUNT);
sale.setId(ID);
sale.setParentPayment(PARENTPAYMENT);
sale.setState(STATE);
sale.setCreateTime(CREATEDTIME);
sale.setLinks(links);
return sale;
}
@Test(groups = "unit")
public void testConstruction() {
Sale sale = createSale();
Assert.assertEquals(sale.getId(), ID);
Assert.assertEquals(sale.getAmount().getTotal(), "100.00");
Assert.assertEquals(sale.getParentPayment(), PARENTPAYMENT);
Assert.assertEquals(sale.getState(), STATE);
Assert.assertEquals(sale.getCreateTime(), CREATEDTIME);
Assert.assertEquals(sale.getLinks().size(), 1);
}
@Test(groups = "integration")
public void testSaleRefundAPI() throws PayPalRESTException {
Payment payment = PaymentTestCase.createCallPayment();
Payment createdPayment = payment.create(TestConstants.SANDBOX_CONTEXT);
List<Transaction> transactions = createdPayment.getTransactions();
List<RelatedResources> subTransactions = transactions.get(0)
.getRelatedResources();
String id = subTransactions.get(0).getSale().getId();
this.SALE_ID = id;
Sale sale = new Sale();
sale.setId(id);
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setTotal("3");
Refund refund = new Refund();
refund.setAmount(amount);
refund.setSaleId(id);
Refund returnRefund = sale.refund(TestConstants.SANDBOX_CONTEXT, refund);
ObjectHolder.refundId = returnRefund.getId();
Assert.assertEquals(true, "completed".equalsIgnoreCase(returnRefund.getState()));
}
@Test(groups = "integration", dependsOnMethods = { "testSaleRefundAPI" })
public void testGetSale() {
Sale sale = null;
try {
sale = Sale.get(TestConstants.SANDBOX_CONTEXT, this.SALE_ID);
Assert.assertNotNull(sale);
Assert.assertEquals(this.SALE_ID, sale.getId());
} catch (PayPalRESTException ppx) {
Assert.fail();
}
}
@Test(groups = "integration", dependsOnMethods = { "testGetSale" })
public void testSaleRefundAPIForNullRefund() {
Sale sale = new Sale();
Refund refund = null;
try {
sale.refund(TestConstants.SANDBOX_CONTEXT, refund);
} catch (IllegalArgumentException e) {
Assert.assertTrue(e != null, "IllegalArgument exception not thrown for null Refund");
} catch (PayPalRESTException e) {
Assert.fail();
}
}
@Test(groups = "integration", dependsOnMethods = { "testSaleRefundAPIForNullRefund" })
public void testSaleRefundAPIForNullID() {
Sale sale = new Sale();
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setTotal("10");
Refund refund = new Refund();
refund.setAmount(amount);
refund.setSaleId("123");
try {
sale.refund(TestConstants.SANDBOX_CONTEXT, refund);
} catch (IllegalArgumentException e) {
Assert.assertTrue(e != null, "IllegalArgument exception not thrown for null Id");
} catch (PayPalRESTException e) {
Assert.fail();
}
}
@Test(groups = "integration", dependsOnMethods = { "testSaleRefundAPIForNullID" })
public void testGetSaleForNullId() {
try {
Sale.get(TestConstants.SANDBOX_CONTEXT, null);
} catch (IllegalArgumentException e) {
Assert.assertTrue(e != null, "IllegalArgument exception not thrown for null Id");
} catch (PayPalRESTException e) {
Assert.fail();
}
}
@Test
public void testSaleUnknownFileConfiguration() {
try {
Sale.initConfig(new File("unknown.properties"));
} catch (PayPalRESTException e) {
Assert.assertEquals(e.getCause().getClass().getSimpleName(),
"FileNotFoundException");
}
}
@Test
public void testSaleInputStreamConfiguration() {
try {
File testFile = new File(".",
"src/test/resources/sdk_config.properties");
FileInputStream fis = new FileInputStream(testFile);
Sale.initConfig(fis);
} catch (PayPalRESTException e) {
Assert.fail("[sdk_config.properties] stream loading failed");
} catch (FileNotFoundException e) {
Assert.fail("[sdk_config.properties] file is not available");
}
}
@Test
public void testSalePropertiesConfiguration() {
try {
File testFile = new File(".",
"src/test/resources/sdk_config.properties");
Properties props = new Properties();
FileInputStream fis = new FileInputStream(testFile);
props.load(fis);
Sale.initConfig(props);
} catch (FileNotFoundException e) {
Assert.fail("[sdk_config.properties] file is not available");
} catch (IOException e) {
Assert.fail("[sdk_config.properties] file is not loaded into properties");
}
}
@Test(groups = "unit")
public void testTOJSON() {
Sale sale = createSale();
Assert.assertEquals(sale.toJSON().length() == 0, false);
}
@Test(groups = "unit")
public void testTOString() {
Sale sale = createSale();
Assert.assertEquals(sale.toString().length() == 0, false);
}
}
| 3,705 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/EventTypeListTestCase.java
|
package com.paypal.api.payments;
import java.util.ArrayList;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
public class EventTypeListTestCase {
private static final Logger logger = Logger.getLogger(EventTypeListTestCase.class);
public static List<EventType> createAuthEventTypeList() {
List<EventType> eventTypes = new ArrayList<EventType>();
EventType eventType1 = new EventType();
eventType1.setName(WebhooksInputData.availableEvents[1][0]);
eventType1.setDescription(WebhooksInputData.availableEvents[1][1]);
EventType eventType2 = new EventType();
eventType2.setName(WebhooksInputData.availableEvents[2][0]);
eventType2.setDescription(WebhooksInputData.availableEvents[2][1]);
eventTypes.add(eventType1);
eventTypes.add(eventType2);
return eventTypes;
}
public static List<EventType> createAllEventTypeList() {
List<EventType> eventTypes = new ArrayList<EventType>();
for(String[] availableEvent : WebhooksInputData.availableEvents) {
EventType eventType = new EventType();
eventType.setName(availableEvent[0]);
eventType.setDescription(availableEvent[1]);
eventTypes.add(eventType);
}
return eventTypes;
}
@Test(groups = "unit")
public void testCreateAllEventTypeListConstruction() {
List<EventType> eventTypeList = createAllEventTypeList();
for(int i=0; i < eventTypeList.size(); i++) {
Assert.assertEquals(eventTypeList.get(i).getName(), WebhooksInputData.availableEvents[i][0]);
}
}
@Test(groups = "unit")
public void testCreateAuthEventTypeListConstruction() {
List<EventType> eventTypeList = createAuthEventTypeList();
Assert.assertEquals(eventTypeList.get(0).getName(), WebhooksInputData.availableEvents[1][0]);
Assert.assertEquals(eventTypeList.get(1).getName(), WebhooksInputData.availableEvents[2][0]);
}
@Test(groups = "unit")
public void testTOJSON() {
EventTypeList eventTypeList = new EventTypeList();
eventTypeList.setEventTypes(createAllEventTypeList());
Assert.assertEquals(eventTypeList.toJSON().length() == 0, false);
logger.info("EventTypeListJSON = " + eventTypeList.toJSON());
}
@Test(groups = "unit")
public void testTOString() {
EventTypeList eventTypeList = new EventTypeList();
eventTypeList.setEventTypes(createAllEventTypeList());
Assert.assertEquals(eventTypeList.toString().length() == 0, false);
}
}
| 3,706 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/OrderTestCase.java
|
package com.paypal.api.payments;
import com.paypal.base.util.TestConstants;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.paypal.base.rest.PayPalRESTException;
/**
* NOTE: Tests that use this class must be ignored when run in an automated environment because executing an order will require approval via the executed payment's approval_url.
*/
@Test(enabled = false)
public class OrderTestCase {
private static Order order = null;
public static final String ID = "O-2HT09787H36911800";
@Test(groups = "integration", enabled = false)
public void testGetOrder() throws PayPalRESTException {
order = Order.get(TestConstants.SANDBOX_CONTEXT, ID);
}
@Test(groups = "integration", dependsOnMethods = { "testGetOrder" }, enabled = false)
public void testAuthorize() throws PayPalRESTException {
Authorization authorization = order.authorize(TestConstants.SANDBOX_CONTEXT);
Assert.assertEquals(authorization.getState(), "Pending");
}
@Test(groups = "integration", dependsOnMethods = { "testAuthorize" }, enabled = false)
public void testCapture() throws PayPalRESTException {
Capture capture = order.capture(TestConstants.SANDBOX_CONTEXT, CaptureTestCase.createCapture());
Assert.assertEquals(capture.getState(), "Pending");
}
@Test(groups = "integration", dependsOnMethods = { "testCapture" }, enabled = false)
public void testDoVoid() throws PayPalRESTException {
order = order.doVoid(TestConstants.SANDBOX_CONTEXT);
Assert.assertEquals(order.getState(), "voided");
}
}
| 3,707 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/TransactionsTestCase.java
|
package com.paypal.api.payments;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TransactionsTestCase {
public static final Amount AMOUNT = AmountTestCase.createAmount("100.00");
public static Transactions createTransactions() {
Transactions transactions = new Transactions();
transactions.setAmount(AMOUNT);
return transactions;
}
@Test(groups = "unit")
public void testConstruction() {
Transactions transactions = TransactionsTestCase.createTransactions();
Assert.assertEquals(transactions.getAmount().getTotal(), "100.00");
}
@Test(groups = "unit")
public void testTOJSON() {
Transactions transactions = TransactionsTestCase.createTransactions();
Assert.assertEquals(transactions.toJSON().length() == 0, false);
}
@Test(groups = "unit")
public void testTOString() {
Transactions transactions = TransactionsTestCase.createTransactions();
Assert.assertEquals(transactions.toString().length() == 0, false);
}
}
| 3,708 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/TemplateTestCase.java
|
package com.paypal.api.payments;
import static com.paypal.base.util.TestConstants.SANDBOX_CONTEXT;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.UUID;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
import com.paypal.base.rest.JSONFormatter;
import com.paypal.base.rest.PayPalRESTException;
@Test
public class TemplateTestCase {
private static final Logger logger = Logger
.getLogger(TemplateTestCase.class);
private String id = null;
public Template loadInvoiceTemplate() {
try {
BufferedReader br = new BufferedReader(new FileReader(new File(
this.getClass().getClassLoader().getResource("template_test.json").getFile())));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.getProperty("line.separator"));
line = br.readLine();
}
br.close();
return JSONFormatter.fromJSON(sb.toString(), Template.class);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Test(groups = "integration", enabled=true)
public void testCreateInvoiceTemplate() throws PayPalRESTException {
Template template = loadInvoiceTemplate();
String templateName = UUID.randomUUID().toString();
// Updated name as it is unique
template.setName(templateName);
try {
template = template.create(SANDBOX_CONTEXT);
} catch (PayPalRESTException ex) {
if (ex.getResponsecode() == 400 && ex.getDetails().getMessage().contains("Exceed maximum number")) {
// This could be because we have reached the maximum number of templates possible per app.
Templates templates = Template.getAll(SANDBOX_CONTEXT);
for (Template templ : templates.getTemplates()) {
if (!templ.getIsDefault()) {
try {
templ.delete(SANDBOX_CONTEXT);
} catch (Exception e) {
// We tried our best. We will continue.
continue;
}
}
}
template = template.create(SANDBOX_CONTEXT);
}
}
logger.info("Invoice template created: ID=" + template.getTemplateId());
this.id = template.getTemplateId();
Assert.assertEquals(templateName, template.getName());
}
@Test(groups = "integration", enabled=true, dependsOnMethods = { "testCreateInvoiceTemplate" })
public void testUpdateInvoiceTemplate() throws PayPalRESTException {
Template template = Template.get(SANDBOX_CONTEXT, this.id);
// change the note
template.getTemplateData().setNote("Something else");
// BUG: Custom is required to be manually removed.
template.setCustom(null);
template.update(SANDBOX_CONTEXT);
logger.info("Invoice template returned: ID=" + template.getTemplateId());
this.id = template.getTemplateId();
Template updatedTemplate = Template.get(SANDBOX_CONTEXT, this.id);
Assert.assertEquals(updatedTemplate.getTemplateData().getNote(), template.getTemplateData().getNote());
}
@Test(groups = "integration", enabled=true, dependsOnMethods = { "testCreateInvoiceTemplate" })
public void testGetInvoiceTemplate() throws PayPalRESTException {
Template template = Template.get(SANDBOX_CONTEXT, this.id);
logger.info("Invoice template returned: ID=" + template.getTemplateId());
this.id = template.getTemplateId();
}
@Test(groups = "integration", enabled=true, dependsOnMethods = { "testGetInvoiceTemplate" })
public void testDeleteInvoiceTemplate() throws PayPalRESTException {
Template template = Template.get(SANDBOX_CONTEXT, this.id);
template.delete(SANDBOX_CONTEXT);
}
}
| 3,709 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/AmountTestCase.java
|
package com.paypal.api.payments;
import org.testng.Assert;
import org.testng.annotations.Test;
public class AmountTestCase {
public static final String CURRENCY = "USD";
public static final Details AMOUNTDETAILS = DetailsTestCase
.createDetails();
public static Amount createAmount(String total) {
Amount amount = new Amount();
amount.setCurrency(CURRENCY);
amount.setTotal(total);
amount.setDetails(AMOUNTDETAILS);
return amount;
}
@Test(groups = "unit")
public void testConstruction() {
Amount amount = createAmount("1000.00");
Assert.assertEquals(amount.getTotal(), "1000.00");
Assert.assertEquals(amount.getCurrency(), CURRENCY);
Assert.assertEquals(amount.getDetails().getFee(),
DetailsTestCase.FEE);
}
@Test(groups = "unit")
public void testTOJSON() {
Amount amount = createAmount("12.25");
Assert.assertEquals(amount.toJSON().length() == 0, false);
}
@Test
public void testTOString() {
Amount amount = createAmount("12.25");
Assert.assertEquals(amount.toString().length() == 0, false);
}
}
| 3,710 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/EventTestCase.java
|
package com.paypal.api.payments;
import java.util.ArrayList;
import java.util.List;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
public class EventTestCase {
private static final Logger logger = Logger.getLogger(EventTestCase.class);
public static final String RESOURCETYPE_AUTHORIZATION = "authorization";
public static final String EVENT_ID = "WH-SDK-1S115631EN580315E-9KH94552VF7913711";
public static final String EVENT_SUMMARY = "A successful payment authorization was created";
public static final String QUERY_PARAMS = "?page_size=10&start_time=2014-11-11T03:00:01Z";
public static final String EVENT_ID_SANDBOX = "WH-7J43600981584542E-9HV9453863280901M";
public static Event createEvent() {
Event event = new Event();
event.setCreateTime(new java.util.Date().toString());
event.setEventType(WebhooksInputData.availableEvents[1][0]);
event.setId(EVENT_ID);
event.setResourceType(RESOURCETYPE_AUTHORIZATION);
event.setSummary(EVENT_SUMMARY);
return event;
}
public static Event createSaleEvent() {
Event event = new Event();
event.setCreateTime(new java.util.Date().toString());
event.setEventType(WebhooksInputData.availableEvents[4][0]);
event.setId(EVENT_ID);
event.setResourceType(RESOURCETYPE_AUTHORIZATION);
event.setSummary(EVENT_SUMMARY);
return event;
}
@Test(groups = "unit")
public void testEventConstruction() {
Event event = createEvent();
Event saleEvent = createSaleEvent();
Assert.assertEquals(event.getEventType(), WebhooksInputData.availableEvents[1][0]);
Assert.assertEquals(event.getId(), EVENT_ID);
Assert.assertEquals(event.getResourceType(), RESOURCETYPE_AUTHORIZATION);
Assert.assertEquals(event.getSummary(), EVENT_SUMMARY);
Assert.assertEquals(saleEvent.getEventType(), WebhooksInputData.availableEvents[4][0]);
Assert.assertEquals(saleEvent.getId(), EVENT_ID);
Assert.assertEquals(saleEvent.getResourceType(), RESOURCETYPE_AUTHORIZATION);
Assert.assertEquals(saleEvent.getSummary(), EVENT_SUMMARY);
}
@Test(groups = "unit")
public void testTOJSON() {
Event event = createEvent();
Assert.assertEquals(event.toJSON().length() == 0, false);
logger.info("EventJSON = " + event.toJSON());
}
@Test(groups = "unit")
public void testTOString() {
Event event = createEvent();
Assert.assertEquals(event.toString().length() == 0, false);
}
/**
* Creates a Payment with AuthorizeIntent and PayPal as Sale method
*/
@Test(groups = "integration")
public Payment createPaymentWithAuthorizeIntent() {
Details details = new Details();
details.setShipping("10");
details.setSubtotal("80");
details.setTax("10");
Amount amount = new Amount();
amount.setCurrency("USD");
amount.setTotal("100");
amount.setDetails(details);
RedirectUrls redirectUrls = new RedirectUrls();
redirectUrls.setCancelUrl("http://www.yahoo.com");
redirectUrls.setReturnUrl("http://www.yahoo.com");
ShippingAddress shippingAddress = new ShippingAddress();
shippingAddress.setRecipientName("Paypal SDK DEV");
shippingAddress.setCountryCode("US");
shippingAddress.setPostalCode("95131");
shippingAddress.setState("CA");
shippingAddress.setCity("San Jose");
shippingAddress.setLine1("2200 N 1st");
shippingAddress.setLine2("building 17");
ItemList itemList = new ItemList();
List<Item> items = new ArrayList<Item>();
Item item = new Item();
item.setName("Rubik's Cube");
item.setCurrency("USD");
item.setPrice("8");
item.setQuantity("10");
item.setSku("TOYS-RC-548");
items.add(item);
itemList.setItems(items);
itemList.setShippingAddress(shippingAddress);
Transaction transaction = new Transaction();
transaction.setAmount(amount);
transaction.setItemList(itemList);
transaction.setDescription("This is the payment transaction description.");
List<Transaction> transactions = new ArrayList<Transaction>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod("paypal");
Payment payment = new Payment();
payment.setIntent("authorize");
payment.setPayer(payer);
payment.setRedirectUrls(redirectUrls);
payment.setTransactions(transactions);
logger.info(payment.toJSON());
return payment;
}
}
| 3,711 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/BillingAgreementTestCase.java
|
package com.paypal.api.payments;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Random;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.paypal.base.rest.JSONFormatter;
import com.paypal.base.rest.PayPalRESTException;
import com.paypal.base.util.TestConstants;
public class BillingAgreementTestCase {
private String id = null;
private Agreement agreement = null;
public static Agreement loadAgreement() {
try {
BufferedReader br = new BufferedReader(new FileReader("src/test/resources/billingagreement_create.json"));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.getProperty("line.separator"));
line = br.readLine();
}
br.close();
return JSONFormatter.fromJSON(sb.toString(), Agreement.class);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Test(groups = "integration")
public void testCreateAgreement() throws PayPalRESTException, MalformedURLException, UnsupportedEncodingException {
// first, set up plan to be included in the agreement
Plan plan = new Plan();
plan.setId("P-8JY85466CB547405SOESMNSI");
// construct an agreement and add the above plan to it
Agreement agreement = loadAgreement();
agreement.setPlan(plan);
agreement.setShippingAddress(null);
agreement = agreement.create(TestConstants.SANDBOX_CONTEXT);
System.out.println("agreement.getId():"+agreement.getId());
this.id = agreement.getId();
System.out.println("Test:" + agreement.getId());
Assert.assertNull(agreement.getId());
Assert.assertNotNull(agreement.getToken());
Assert.assertEquals(this.id, agreement.getId());
}
@Test(groups = "integration", dependsOnMethods = {"testCreateAgreement"})
public void testExecuteAgreement() throws PayPalRESTException {
Agreement agreement = new Agreement();
agreement.setToken("EC-4WP43347M2969501K");
this.agreement = Agreement.execute(TestConstants.SANDBOX_CONTEXT,agreement.getToken());
Assert.assertEquals("I-JJRBKD609M69", this.agreement.getId());
}
@Test(enabled=false, groups = "integration", dependsOnMethods = {"testExecuteAgreement"})
public void testUpdateAgreement() throws PayPalRESTException {
// set up changes to update with randomized string as description
Agreement newAgreement = new Agreement();
Random random = new Random();
String newDescription = String.valueOf(random.nextLong());
newAgreement.setDescription(newDescription);
// create a patch object and set value to the above updated agreement
Patch patch = new Patch();
patch.setOp("replace");
patch.setPath("/");
patch.setValue(newAgreement);
// build PatchRequest which is an array of Patch
List<Patch> patchRequest = new ArrayList<Patch>();
patchRequest.add(patch);
Agreement updatedAgreement = this.agreement.update(TestConstants.SANDBOX_CONTEXT, patchRequest);
Assert.assertNotSame(agreement.getDescription(), updatedAgreement.getDescription());
Assert.assertEquals(updatedAgreement.getId(), this.agreement.getId());
Assert.assertEquals(newAgreement.getDescription(), updatedAgreement.getDescription());
}
@Test(groups = "integration", dependsOnMethods = {"testExecuteAgreement"})
public void testRetrieveAgreement() throws PayPalRESTException {
Agreement agreement = Agreement.get(TestConstants.SANDBOX_CONTEXT, "I-JJRBKD609M69");
Assert.assertEquals("I-JJRBKD609M69", agreement.getId());
Assert.assertEquals("2019-06-17T07:00:00Z", agreement.getStartDate());
Assert.assertNotNull(agreement.getPlan());
}
@Test(groups = "integration", dependsOnMethods = {"testCreateAgreement"})
public void testSearchAgreement() throws PayPalRESTException {
Date startDate = new GregorianCalendar(2014, 10, 1).getTime();
Date endDate = new GregorianCalendar(2014, 10, 14).getTime();
AgreementTransactions transactions = Agreement.transactions(TestConstants.SANDBOX_CONTEXT, "I-9STXMKR58UNN", startDate, endDate);
Assert.assertNotNull(transactions);
Assert.assertNotNull(transactions.getAgreementTransactionList());
}
/**
* The following tests are disabled due to them requiring an active billing agreement.
*
* @throws PayPalRESTException
*/
@Test(enabled=false, groups = "integration", dependsOnMethods = {"testRetrieveAgreement"})
public void testSuspendAgreement() throws PayPalRESTException {
String agreementId = "";
Agreement agreement = Agreement.get(TestConstants.SANDBOX_CONTEXT, agreementId);
System.out.println("agreement state: " + agreement.getPlan().getState());
AgreementStateDescriptor agreementStateDescriptor = new AgreementStateDescriptor();
agreementStateDescriptor.setNote("Suspending the agreement.");
agreement.suspend(TestConstants.SANDBOX_CONTEXT, agreementStateDescriptor);
Agreement suspendedAgreement = Agreement.get(TestConstants.SANDBOX_CONTEXT, "I-ASXCM9U5MJJV");
Assert.assertEquals("SUSPENDED", suspendedAgreement.getPlan().getState());
}
@Test(enabled=false, groups = "integration", dependsOnMethods = {"testSuspendAgreement"})
public void testReactivateAgreement() throws PayPalRESTException {
String agreementId = "";
Agreement agreement = Agreement.get(TestConstants.SANDBOX_CONTEXT, agreementId);
AgreementStateDescriptor stateDescriptor = new AgreementStateDescriptor();
stateDescriptor.setNote("Re-activating the agreement");
agreement.reActivate(TestConstants.SANDBOX_CONTEXT, stateDescriptor);
}
@Test(enabled=false, groups = "integration", dependsOnMethods = {"testReactivateAgreement"})
public void testCancelAgreement() throws PayPalRESTException {
String agreementId = "";
Agreement agreement = Agreement.get(TestConstants.SANDBOX_CONTEXT, agreementId);
AgreementStateDescriptor stateDescriptor = new AgreementStateDescriptor();
stateDescriptor.setNote("Cancelling the agreement");
agreement.cancel(TestConstants.SANDBOX_CONTEXT, stateDescriptor);
}
}
| 3,712 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/WebhooksInputData.java
|
package com.paypal.api.payments;
import java.util.ArrayList;
import java.util.List;
public class WebhooksInputData {
public static final String[][] availableEvents = {
{"PAYMENT.CAPTURE.REFUNDED", "A capture payment was refunded"},
{"PAYMENT.AUTHORIZATION.VOIDED", "A payment authorization was voided"},
{"PAYMENT.AUTHORIZATION.CREATED", "A payment authorization was created"},
{"PAYMENT.SALE.COMPLETED", "A sale payment was completed"},
{"PAYMENT.SALE.REFUNDED", "A sale payment was refunded"},
{"PAYMENT.SALE.REVERSED", "A sale payment was reversed"},
{"PAYMENT.CAPTURE.REVERSED", "A capture payment was reversed"}
};
public static final String WEBHOOK_URL = "https://github.com/paypal/";
public static final String WEBHOOK_HATEOAS_URL = "https://api.sandbox.paypal.com/v1/notifications/webhooks/";
public static final String CLIENT_ID = "AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS";
public static final String CLIENT_SECRET = "EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL";
public static final String EVENT_ID = "WH-SDK-1S115631EN580315E-9KH94552VF7913711";
public static final String LINK_HREF = "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/" + EVENT_ID;
public static final String LINK_HREF_RESEND = LINK_HREF + "/resend";
public static final String LINK_REL_SELF = "self";
public static final String LINK_REL_RESEND = "resend";
public static final String LINK_METHOD_GET = "GET";
public static final String LINK_METHOD_POST = "POST";
/**
* Static method top generate List of Links
*/
public static List<Links> createLinksList() {
List<Links> linksList = new ArrayList<Links>();
Links link1 = new Links();
link1.setHref(LINK_HREF);
link1.setRel(LINK_REL_SELF);
link1.setMethod(LINK_METHOD_GET);
Links link2 = new Links();
link2.setHref(LINK_HREF_RESEND);
link2.setRel(LINK_REL_RESEND);
link2.setMethod(LINK_METHOD_POST);
linksList.add(link1);
linksList.add(link2);
return linksList;
}
}
| 3,713 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/api/payments/WebProfileTestCase.java
|
package com.paypal.api.payments;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.paypal.base.rest.JSONFormatter;
import com.paypal.base.rest.PayPalRESTException;
import com.paypal.base.util.TestConstants;
public class WebProfileTestCase {
private String id = null;
public static WebProfile loadWebProfile() {
try {
BufferedReader br = new BufferedReader(new FileReader("src/test/resources/webexperience_create.json"));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.getProperty("line.separator"));
line = br.readLine();
}
br.close();
return JSONFormatter.fromJSON(sb.toString(), WebProfile.class);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Test(groups = "integration")
public void testCreateWebProfile() throws PayPalRESTException {
Random random = new Random();
long randomNumber = random.nextLong();
WebProfile webProfile = loadWebProfile();
webProfile.setName(webProfile.getName() + String.valueOf(randomNumber));
CreateProfileResponse response = webProfile.create(TestConstants.SANDBOX_CONTEXT);
this.id = response.getId();
Assert.assertNotNull(response.getId());
}
@Test(groups = "integration", dependsOnMethods = { "testCreateWebProfile" })
public void testRetrieveWebProfile() throws PayPalRESTException {
WebProfile webProfile = WebProfile.get(TestConstants.SANDBOX_CONTEXT, this.id);
Assert.assertEquals(this.id, webProfile.getId());
}
@Test(groups = "integration", dependsOnMethods = { "testCreateWebProfile" })
public void testListWebProfiles() throws PayPalRESTException {
List<WebProfile> webProfileList = WebProfile.getList(TestConstants.SANDBOX_CONTEXT);
Assert.assertTrue(webProfileList.size() > 0);
}
@Test(groups = "integration", dependsOnMethods = { "testCreateWebProfile" })
public void testUpdateWebProfile() throws PayPalRESTException {
Random random = new Random();
long randomNumber = random.nextLong();
String newName = "YeowZa! T-Shirt Shop" + String.valueOf(randomNumber);
WebProfile webProfile = loadWebProfile();
webProfile.setId(this.id);
webProfile.setName(newName);
webProfile.update(TestConstants.SANDBOX_CONTEXT);
webProfile = WebProfile.get(TestConstants.SANDBOX_CONTEXT, this.id);
Assert.assertEquals(webProfile.getName(), newName);
}
}
| 3,714 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/ConnectionManagerTest.java
|
package com.paypal.base;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class ConnectionManagerTest {
ConnectionManager conn;
HttpConnection http;
@BeforeClass
public void beforeClass() {
conn = ConnectionManager.getInstance();
http = conn.getConnection();
}
@Test
public void getConnectionTest() {
Assert.assertNotNull(http);
}
@Test
public void getConnectionWithHttpConfigurationForGoogleAppEngineTest() {
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setGoogleAppEngine(true);
Assert.assertEquals(conn.getConnection(httpConfig).getClass(),
GoogleAppEngineHttpConnection.class);
}
@Test
public void getConnectionWithHttpConfigurationForDefauktTest() throws Exception {
HttpConfiguration httpConfig = new HttpConfiguration();
Assert.assertEquals(conn.getConnection(httpConfig).getClass(),
DefaultHttpConnection.class);
conn.configureCustomSslContext(SSLUtil.getSSLContext(null));
Assert.assertEquals(conn.getConnection(httpConfig).getClass(),
DefaultHttpConnection.class);
conn.configureCustomSslContext(null);
}
@AfterClass
public void afterClass() {
conn = null;
http = null;
}
}
| 3,715 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/HttpConnectionTest.java
|
package com.paypal.base;
import java.io.BufferedReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.ExpectedExceptions;
import org.testng.annotations.Test;
import com.paypal.base.HttpConfiguration.FollowRedirect;
import com.paypal.base.exception.ClientActionRequiredException;
import com.paypal.base.exception.HttpErrorException;
import com.paypal.base.exception.InvalidResponseDataException;
import static com.paypal.base.HttpConfiguration.FollowRedirect.NO_DO_NOT_FOLLOW_REDIRECT;
public class HttpConnectionTest {
HttpConnection connection;
HttpConfiguration httpConfiguration;
@BeforeClass
public void beforeClass() throws MalformedURLException, IOException {
ConnectionManager connectionMgr = ConnectionManager.getInstance();
connection = connectionMgr.getConnection();
httpConfiguration = new HttpConfiguration();
}
@Test(expectedExceptions = MalformedURLException.class)
public void checkMalformedURLExceptionTest() throws Exception {
httpConfiguration.setEndPointUrl("ww.paypal.in");
connection.createAndconfigureHttpConnection(httpConfiguration);
}
@Test(expectedExceptions = InvocationTargetException.class)
public void readMethodTest() throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException, IOException {
Method readMethod = HttpConnection.class.getDeclaredMethod("read",
BufferedReader.class);
readMethod.setAccessible(true);
BufferedReader br = null;
readMethod.invoke(connection, br);
}
@Test
public void executeTest() throws InvalidResponseDataException,
HttpErrorException, ClientActionRequiredException, IOException,
InterruptedException {
httpConfiguration
.setEndPointUrl("https://svcs.sandbox.paypal.com/AdaptivePayments/ConvertCurrency");
connection.createAndconfigureHttpConnection(httpConfiguration);
String response = connection.execute("url", "payload", null);
Assert.assertTrue(response.contains("<ack>Failure</ack>"));
}
@Test(expectedExceptions = HttpErrorException.class,
expectedExceptionsMessageRegExp = "Response code: 500\tError response: Internal server error..*")
public void Http500Test() throws InvalidResponseDataException,
HttpErrorException, ClientActionRequiredException, IOException,
InterruptedException {
httpConfiguration
.setEndPointUrl("https://svcs.sandbox.paypal.com/AdaptivePayments");
connection.createAndconfigureHttpConnection(httpConfiguration);
connection.execute("url", "payload", null);
}
@Test(expectedExceptions = ClientActionRequiredException.class,
expectedExceptionsMessageRegExp = ".*esponse code: 302.*")
public void Http3xxTest() throws InvalidResponseDataException,
HttpErrorException, ClientActionRequiredException, IOException,
InterruptedException {
httpConfiguration.setInstanceFollowRedirects(NO_DO_NOT_FOLLOW_REDIRECT);
httpConfiguration
.setEndPointUrl("https://www.sandbox.paypal.com/wdfunds");
connection.createAndconfigureHttpConnection(httpConfiguration);
connection.execute("url", "payload", null);
}
// Expecting this test to have a certificate issue that prevents connection
// Example: unable to find valid certification path to requested target
@Test(expectedExceptions = HttpErrorException.class,
expectedExceptionsMessageRegExp = "Response code: -1\tError response: .+")
public void connectionFailureTest() throws InvalidResponseDataException,
HttpErrorException, ClientActionRequiredException, IOException,
InterruptedException {
httpConfiguration
.setEndPointUrl("https://example.com/AdaptivePayments/ConvertCurrency");
connection.createAndconfigureHttpConnection(httpConfiguration);
connection.execute("url", "payload", null);
}
@AfterClass
public void afterClass() {
connection = null;
httpConfiguration = null;
}
}
| 3,716 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/SSLUtilTest.java
|
package com.paypal.base;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.util.HashMap;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.paypal.api.payments.Event;
import com.paypal.base.exception.SSLConfigurationException;
import com.paypal.base.rest.APIContext;
import com.paypal.base.rest.PayPalRESTException;
public class SSLUtilTest {
@Test
public void getSSLContextTest() throws SSLConfigurationException {
Assert.assertNotNull(SSLUtil.getSSLContext(null));
}
@Test
public void setupClientSSLTest() throws SSLConfigurationException {
Assert.assertNotNull(SSLUtil.setupClientSSL(
UnitTestConstants.CERT_PATH, UnitTestConstants.CERT_PASSWORD));
}
@Test(expectedExceptions = SSLConfigurationException.class)
public void setupClientSSLExceptionTest() throws Exception {
Assert.assertNotNull(SSLUtil.setupClientSSL("src/sdk_cert.p12",
UnitTestConstants.CERT_PASSWORD));
}
@Test(expectedExceptions = SSLConfigurationException.class)
public void setupClientSSLNoSuchKeyExceptionTest() throws Exception {
Assert.assertNotNull(SSLUtil.setupClientSSL("src/sdk_cert.p12",
null));
}
@Test
public void testValidateWebhook() {
Map<String, String> headers = new HashMap<String, String>();
APIContext apiContext = new APIContext();
Map<String, String> configs = new HashMap<String, String>();
configs.put(Constants.PAYPAL_WEBHOOK_ID, "3RN13029J36659323");
apiContext.setConfigurationMap(configs);
headers.put(Constants.PAYPAL_HEADER_CERT_URL, "https://api.sandbox.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-a5cafa77");
headers.put(Constants.PAYPAL_HEADER_TRANSMISSION_ID, "b2384410-f8d2-11e4-8bf3-77339302725b");
headers.put(Constants.PAYPAL_HEADER_TRANSMISSION_TIME, "2015-05-12T18:14:14Z");
headers.put(Constants.PAYPAL_HEADER_AUTH_ALGO, "SHA256withRSA");
headers.put(Constants.PAYPAL_HEADER_TRANSMISSION_SIG, "vSOIQFIZQHv8G2vpbOpD/4fSC4/MYhdHyv+AmgJyeJQq6q5avWyHIe/zL6qO5hle192HSqKbYveLoFXGJun2od2zXN3Q45VBXwdX3woXYGaNq532flAtiYin+tQ/0pNwRDsVIufCxa3a8HskaXy+YEfXNnwCSL287esD3HgOHmuAs0mYKQdbR4e8Evk8XOOQaZzGeV7GNXXz19gzzvyHbsbHmDz5VoRl9so5OoHqvnc5RtgjZfG8KA9lXh2MTPSbtdTLQb9ikKYnOGM+FasFMxk5stJisgmxaefpO9Q1qm3rCjaJ29aAOyDNr3Q7WkeN3w4bSXtFMwyRBOF28pJg9g==");
String requestBody = "{\"id\":\"WH-2W7266712B616591M-36507203HX6402335\",\"create_time\":\"2015-05-12T18:14:14Z\",\"resource_type\":\"sale\",\"event_type\":\"PAYMENT.SALE.COMPLETED\",\"summary\":\"Payment completed for $ 20.0 USD\",\"resource\":{\"id\":\"7DW85331GX749735N\",\"create_time\":\"2015-05-12T18:13:18Z\",\"update_time\":\"2015-05-12T18:13:36Z\",\"amount\":{\"total\":\"20.00\",\"currency\":\"USD\"},\"payment_mode\":\"INSTANT_TRANSFER\",\"state\":\"completed\",\"protection_eligibility\":\"ELIGIBLE\",\"protection_eligibility_type\":\"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE\",\"parent_payment\":\"PAY-1A142943SV880364LKVJEFPQ\",\"transaction_fee\":{\"value\":\"0.88\",\"currency\":\"USD\"},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/payments/sale/7DW85331GX749735N\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/payments/sale/7DW85331GX749735N/refund\",\"rel\":\"refund\",\"method\":\"POST\"},{\"href\":\"https://api.sandbox.paypal.com/v1/payments/payment/PAY-1A142943SV880364LKVJEFPQ\",\"rel\":\"parent_payment\",\"method\":\"GET\"}]},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2W7266712B616591M-36507203HX6402335\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2W7266712B616591M-36507203HX6402335/resend\",\"rel\":\"resend\",\"method\":\"POST\"}]}";
try {
Event.validateReceivedEvent(apiContext, headers, requestBody);
} catch (PayPalRESTException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SignatureException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| 3,717 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/HttpConfigurationTest.java
|
package com.paypal.base;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class HttpConfigurationTest {
HttpConfiguration httpConf;
@BeforeClass
public void beforeClass() {
httpConf = new HttpConfiguration();
}
@AfterClass
public void afterClass() {
httpConf = null;
}
@Test(priority = 0)
public void getConnectionTimeoutTest() {
Assert.assertEquals(httpConf.getConnectionTimeout(), 0);
}
@Test(priority = 1)
public void getEndPointUrlTest() {
Assert.assertEquals(httpConf.getEndPointUrl(), null);
}
@Test(priority = 2)
public void getMaxHttpConnectionTest() {
Assert.assertEquals(httpConf.getMaxHttpConnection(), 10);
}
@Test(priority = 3)
public void getMaxRetryTest() {
Assert.assertEquals(httpConf.getMaxRetry(), 2);
}
@Test(priority = 4)
public void getProxyHostTest() {
Assert.assertEquals(httpConf.getProxyHost(), null);
}
@Test(priority = 5)
public void getProxyPortTest() {
Assert.assertEquals(httpConf.getProxyPort(), -1);
}
@Test(priority = 6)
public void getReadTimeoutTest() {
Assert.assertEquals(httpConf.getReadTimeout(), 0);
}
@Test(priority = 7)
public void getRetryDelayTest() {
Assert.assertEquals(httpConf.getRetryDelay(), 1000);
}
@Test(priority = 9)
public void isProxySetTest() {
Assert.assertEquals(httpConf.isProxySet(), false);
}
@Test(priority = 11)
public void setAndGetConnectionTimeoutTest() {
httpConf.setConnectionTimeout(5000);
Assert.assertEquals(httpConf.getConnectionTimeout(), 5000);
}
@Test(priority = 12)
public void setAndGetEndPointUrlTest() {
httpConf.setEndPointUrl("https://svcs.sandbox.paypal.com/Invoice/CreateInvoice");
Assert.assertEquals(httpConf.getEndPointUrl(),
"https://svcs.sandbox.paypal.com/Invoice/CreateInvoice");
}
@Test(priority = 14)
public void setAndGetMaxHttpConnectionTest() {
httpConf.setMaxHttpConnection(3);
Assert.assertEquals(httpConf.getMaxHttpConnection(), 3);
}
@Test(priority = 15)
public void setAndGetMaxRetryTest() {
httpConf.setMaxRetry(2);
Assert.assertEquals(httpConf.getMaxRetry(), 2);
}
@Test(priority = 16)
public void setAndGetProxyHostTest() {
httpConf.setProxyHost(null);
Assert.assertEquals(httpConf.getProxyHost(), null);
}
@Test(priority = 17)
public void setAndGetProxyPortTest() {
httpConf.setProxyPort(8080);
Assert.assertEquals(httpConf.getProxyPort(), 8080);
}
@Test(priority = 18)
public void setAndIsProxySetTest() {
httpConf.setProxySet(true);
Assert.assertEquals(httpConf.isProxySet(), true);
}
@Test(priority = 19)
public void setAndGetReadTimeoutTest() {
httpConf.setReadTimeout(10);
Assert.assertEquals(httpConf.getReadTimeout(), 10);
}
@Test(priority = 20)
public void setAndGetRetryDelayTest() {
httpConf.setRetryDelay(30);
Assert.assertEquals(httpConf.getRetryDelay(), 30);
}
@Test(priority = 21)
public void setAndGetProxyUserName() {
httpConf.setProxyUserName("proxyUser");
Assert.assertEquals(httpConf.getProxyUserName(), "proxyUser");
}
@Test(priority = 22)
public void setAndGetProxyPassword() {
httpConf.setProxyPassword("proxyPassword");
Assert.assertEquals(httpConf.getProxyPassword(), "proxyPassword");
}
}
| 3,718 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/DefaultHttpConnectionTest.java
|
package com.paypal.base;
import java.io.IOException;
import java.net.MalformedURLException;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.paypal.base.exception.SSLConfigurationException;
public class DefaultHttpConnectionTest {
DefaultHttpConnection defaultHttpConnection;
HttpConfiguration httpConfiguration;
@BeforeClass
public void beforeClass() {
defaultHttpConnection = new DefaultHttpConnection();
httpConfiguration = new HttpConfiguration();
}
@AfterClass
public void afterClass() {
defaultHttpConnection = null;
httpConfiguration = null;
}
@Test(expectedExceptions = MalformedURLException.class)
public void checkMalformedURLExceptionTest() throws Exception {
httpConfiguration.setEndPointUrl("ww.paypal.in");
defaultHttpConnection
.createAndconfigureHttpConnection(httpConfiguration);
}
@Test(expectedExceptions = SSLConfigurationException.class)
public void checkSSLConfigurationExceptionTest()
throws SSLConfigurationException {
defaultHttpConnection.setupClientSSL("certPath", "certKey");
}
@Test(dataProvider = "configParamsForProxy", dataProviderClass = DataProviderClass.class)
public void createAndConfigureHttpConnectionForProxyTest(
ConfigManager config) throws IOException {
httpConfiguration.setGoogleAppEngine(Boolean.parseBoolean(config.getConfigurationMap().get(Constants.GOOGLE_APP_ENGINE)));
if (Boolean.parseBoolean(config.getConfigurationMap().get(Constants.USE_HTTP_PROXY))) {
httpConfiguration.setProxyPort(Integer.parseInt(config.getConfigurationMap().get(Constants.HTTP_PROXY_PORT)));
httpConfiguration.setProxyHost(config.getConfigurationMap().get(Constants.HTTP_PROXY_HOST));
httpConfiguration.setProxyUserName(config.getConfigurationMap().get(Constants.HTTP_PROXY_USERNAME));
httpConfiguration.setProxyPassword(config.getConfigurationMap().get(Constants.HTTP_PROXY_PASSWORD));
}
httpConfiguration.setConnectionTimeout(Integer.parseInt(config.getConfigurationMap().get(Constants.HTTP_CONNECTION_TIMEOUT)));
httpConfiguration.setMaxRetry(Integer.parseInt(config.getConfigurationMap().get(Constants.HTTP_CONNECTION_RETRY)));
httpConfiguration.setReadTimeout(Integer.parseInt(config.getConfigurationMap().get(Constants.HTTP_CONNECTION_READ_TIMEOUT)));
httpConfiguration.setMaxHttpConnection(Integer.parseInt(config.getConfigurationMap().get(Constants.HTTP_CONNECTION_MAX_CONNECTION)));
httpConfiguration
.setEndPointUrl("https://svcs.sandbox.paypal.com/AdaptivePayments/ConvertCurrency");
defaultHttpConnection
.createAndconfigureHttpConnection(httpConfiguration);
Assert.assertEquals(
Integer.parseInt(System.getProperty("http.maxConnections")),
httpConfiguration.getMaxHttpConnection());
}
}
| 3,719 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/OpenIdTest.java
|
package com.paypal.base;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
import com.paypal.api.openidconnect.CreateFromAuthorizationCodeParameters;
import com.paypal.api.openidconnect.CreateFromRefreshTokenParameters;
import com.paypal.api.openidconnect.Session;
import com.paypal.api.openidconnect.Tokeninfo;
import com.paypal.api.openidconnect.Userinfo;
import com.paypal.base.rest.APIContext;
import com.paypal.base.rest.OAuthTokenCredential;
import com.paypal.base.rest.PayPalRESTException;
public class OpenIdTest {
private static final Logger logger = Logger.getLogger(OpenIdTest.class);
private Tokeninfo info;
Map<String, String> configurationMap = new HashMap<String, String>();
public OpenIdTest() {
// configurationMap.put(Constants.CLIENT_ID, "");
// configurationMap.put(Constants.CLIENT_SECRET, "");
configurationMap.put("mode", "sandbox");
}
private static String generateAccessToken() throws PayPalRESTException {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put("service.EndPoint",
"https://api.sandbox.paypal.com");
OAuthTokenCredential merchantTokenCredential = new OAuthTokenCredential(
"AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd", "EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX", configurationMap);
return merchantTokenCredential.getAccessToken();
}
@Test(groups = "integration", enabled = false)
public void testCreateFromAuthorizationCodeDynamic()
throws PayPalRESTException, UnsupportedEncodingException {
CreateFromAuthorizationCodeParameters param = new CreateFromAuthorizationCodeParameters();
param.setClientID("AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd");
param.setClientSecret("EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX");
param.setCode("uda60BSsvnjRigULcO5J9vb-t85kqR9eGMdVpQ1oyQqOS7vjv8Y2WcYOvNq1WAxSPuxTzS7zlMB03h_KQUVWcrz2cKu8cNfc5tqSB_-duFi6Iuwq3Iie0ouOxmlBstHHzx200VIAMxgqU9bWOycRNxc78iqNhfkA_xGkPglTGal3kqJN");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(configurationMap);
info = Tokeninfo.createFromAuthorizationCode(apiContext, param);
logger.info("Generated Access Token : " + info.getAccessToken());
logger.info("Generated Refresh Token: " + info.getRefreshToken());
}
@Test(dependsOnMethods = { "testCreateFromAuthorizationCodeDynamic" }, enabled = false)
public void testCreateFromRefreshTokenDynamic() throws PayPalRESTException {
CreateFromRefreshTokenParameters param = new CreateFromRefreshTokenParameters();
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(configurationMap);
param.setClientID("AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd");
param.setClientSecret("EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX");
info = info.createFromRefreshToken(apiContext, param);
logger.info("Regenerated Access Token: " + info.getAccessToken());
logger.info("Refresh Token: " + info.getRefreshToken());
}
@Test(groups = "integration")
public void testUserinfoDynamic() throws PayPalRESTException {
APIContext apiContext = new APIContext(generateAccessToken());
apiContext.setConfigurationMap(configurationMap);
Userinfo userInfo = Userinfo.getUserinfo(apiContext);
Assert.assertNotNull(userInfo.getUserId());
logger.info("User ID: " + userInfo.getUserId());
logger.info("User Info Email: " + userInfo.getEmail());
logger.info("User Info Account Type: " + userInfo.getAccountType());
logger.info("User Info Name: " + userInfo.getGivenName());
}
@Test(expectedExceptions = PayPalRESTException.class)
public void testCreateFromAuthorizationCodeDynamicError()
throws PayPalRESTException, UnsupportedEncodingException {
CreateFromAuthorizationCodeParameters param = new CreateFromAuthorizationCodeParameters();
Tokeninfo.createFromAuthorizationCode(null, param);
}
@Test()
public void testRedirectURL() {
Map<String, String> m = new HashMap<String, String>();
m.put("openid.RedirectUri",
"https://www.paypal.com");
m.put("clientId", "ANdfsalkoiarT");
List<String> l = new ArrayList<String>();
l.add("openid");
l.add("profile");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String redirectURL = Session.getRedirectURL("http://google.com", l,
apiContext);
logger.info("Redirect URL: " + redirectURL);
Assert.assertEquals(
redirectURL,
"https://www.paypal.com/signin/authorize?client_id=ANdfsalkoiarT&response_type=code&scope=openid+profile+&redirect_uri=http%3A%2F%2Fgoogle.com");
}
@Test()
public void testRedirectURLClientCredentials() {
Map<String, String> m = new HashMap<String, String>();
m.put("openid.RedirectUri",
"https://www.paypal.com");
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.setClientID("ANdfsalkoiarT");
List<String> l = new ArrayList<String>();
l.add("openid");
l.add("profile");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String redirectURL = Session.getRedirectURL("http://google.com", l,
apiContext, clientCredentials);
logger.info("Redirect URL: " + redirectURL);
Assert.assertEquals(
redirectURL,
"https://www.paypal.com/signin/authorize?client_id=ANdfsalkoiarT&response_type=code&scope=openid+profile+&redirect_uri=http%3A%2F%2Fgoogle.com");
}
@Test()
public void testRedirectURLClientCredentialsSandbox() {
Map<String, String> m = new HashMap<String, String>();
m.put("mode", "sandbox");
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.setClientID("ANdfsalkoiarT");
List<String> l = new ArrayList<String>();
l.add("openid");
l.add("profile");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String redirectURL = Session.getRedirectURL("http://google.com", l,
apiContext, clientCredentials);
logger.info("Redirect URL: " + redirectURL);
Assert.assertEquals(
redirectURL,
"https://www.sandbox.paypal.com/signin/authorize?client_id=ANdfsalkoiarT&response_type=code&scope=openid+profile+&redirect_uri=http%3A%2F%2Fgoogle.com");
}
@Test()
public void testRedirectURLClientCredentialsLive() {
Map<String, String> m = new HashMap<String, String>();
m.put("mode", "live");
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.setClientID("ANdfsalkoiarT");
List<String> l = new ArrayList<String>();
l.add("openid");
l.add("profile");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String redirectURL = Session.getRedirectURL("http://google.com", l,
apiContext, clientCredentials);
logger.info("Redirect URL: " + redirectURL);
Assert.assertEquals(
redirectURL,
"https://www.paypal.com/signin/authorize?client_id=ANdfsalkoiarT&response_type=code&scope=openid+profile+&redirect_uri=http%3A%2F%2Fgoogle.com");
}
@Test(expectedExceptions = RuntimeException.class)
public void testRedirectURLError() {
Map<String, String> m = new HashMap<String, String>();
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.setClientID("ANdfsalkoiarT");
List<String> l = new ArrayList<String>();
l.add("openid");
l.add("profile");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
Session.getRedirectURL("http://google.com", l, apiContext,
clientCredentials);
}
@Test(expectedExceptions = RuntimeException.class)
public void testLogoutURLError() {
Map<String, String> m = new HashMap<String, String>();
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String logoutURL = Session.getLogoutUrl("http://google.com", "tokenId",
apiContext);
logger.info("Redirect URL: " + logoutURL);
Assert.assertEquals(
logoutURL,
"https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession?id_token=tokenId&redirect_uri=http%3A%2F%2Fgoogle.com&logout=true");
}
@Test()
public void testLogoutURL() {
Map<String, String> m = new HashMap<String, String>();
m.put("openid.RedirectUri",
"https://www.paypal.com");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String logoutURL = Session.getLogoutUrl("http://google.com", "tokenId",
apiContext);
logger.info("Logout URL: " + logoutURL);
Assert.assertEquals(
logoutURL,
"https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession?id_token=tokenId&redirect_uri=http%3A%2F%2Fgoogle.com&logout=true");
}
@Test()
public void testLogoutURLSandbox() {
Map<String, String> m = new HashMap<String, String>();
m.put("mode", "sandbox");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String logoutURL = Session.getLogoutUrl("http://google.com", "tokenId",
apiContext);
logger.info("Logout URL: " + logoutURL);
Assert.assertEquals(
logoutURL,
"https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession?id_token=tokenId&redirect_uri=http%3A%2F%2Fgoogle.com&logout=true");
}
@Test()
public void testLogoutURLLive() {
Map<String, String> m = new HashMap<String, String>();
m.put("mode", "live");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(m);
String logoutURL = Session.getLogoutUrl("http://google.com", "tokenId",
apiContext);
logger.info("Logout URL: " + logoutURL);
Assert.assertEquals(
logoutURL,
"https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession?id_token=tokenId&redirect_uri=http%3A%2F%2Fgoogle.com&logout=true");
}
}
| 3,720 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/ValidateCertTest.java
|
package com.paypal.base;
import com.paypal.api.payments.Event;
import com.paypal.base.rest.APIContext;
import com.paypal.base.rest.PayPalRESTException;
import com.paypal.base.rest.PayPalResource;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.testng.PowerMockTestCase;
import org.testng.Assert;
import org.testng.IObjectFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.ObjectFactory;
import org.testng.annotations.Test;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.util.HashMap;
import java.util.Map;
import static org.powermock.api.support.membermodification.MemberModifier.stub;
@PrepareForTest(SSLUtil.class)
@PowerMockIgnore({"javax.management.*", "javax.net.ssl.*", "javax.security.*"})
public class ValidateCertTest extends PowerMockTestCase {
Map<String, String> headers, configs;
APIContext apiContext;
String requestBody;
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}
@BeforeMethod
public void setUp() throws Exception {
InputStream testClientCertStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testClientCert.crt");
stub(PowerMockito.method(SSLUtil.class, "downloadCertificateFromPath", String.class, Map.class)).toReturn(testClientCertStream);
// Settings some default values before each methods
headers = new HashMap<String, String>();
configs = new HashMap<String, String>();
apiContext = new APIContext();
//configs.put(Constants.PAYPAL_TRUST_CERT_URL, "DigiCertSHA2ExtendedValidationServerCA.crt");
configs.put(Constants.PAYPAL_WEBHOOK_ID, "96605875FF6516633");
apiContext.setConfigurationMap(configs);
headers.put(Constants.PAYPAL_HEADER_CERT_URL, "https://api.sandbox.paypal.com/v1/notifications/test");
headers.put(Constants.PAYPAL_HEADER_TRANSMISSION_ID, "071f7d20-1584-11e7-abf0-6b62a8a99ac4");
headers.put(Constants.PAYPAL_HEADER_TRANSMISSION_TIME, "2017-03-30T20:04:05Z");
headers.put(Constants.PAYPAL_HEADER_AUTH_ALGO, "SHA256withRSA");
headers.put(Constants.PAYPAL_HEADER_TRANSMISSION_SIG, "aBjgm5/xljRYu3G64Q0axISrP2xcy7WbW1u4UTCKnQvyprOZ1a1BBmqn2Jdr6ce8E76I3Ti/AL9y4VYSHyGSEaoE6dVQcCDebLbOXLH0fjTAbTc1/rmfdWmsk0DPltW84Y8W8jOHe3CLWDOwg5zmozyt+AceG2x5eOiw7mLSycaEoj/5RG+dOIWXnmWcLEArbG3VFshy0wuhZrKuGa9C/bD4Ku+Y9gK7Bv5I5IuGRVnTGpcFnVG0KxOyJxccLGyBVCIUMY5IZS7LkmJszQ3HZZFDTNihvgJHECSLwLhzUaysIye5G6CbbLdtAmeeb6wiDciEAvr2dFf+SplOR4Lrng==");
requestBody = "{\"id\":\"WH-2MW4820926242972J-6SG447389E205703U\",\"event_version\":\"1.0\",\"create_time\":\"2017-03-30T20:04:05.613Z\",\"resource_type\":\"plan\",\"event_type\":\"BILLING.PLAN.CREATED\",\"summary\":\"A billing plan was created\",\"resource\":{\"merchant_preferences\":{\"setup_fee\":{\"currency\":\"USD\",\"value\":\"1\"},\"return_url\":\"https://www.mta.org/wp-content/plugins/AMS/api/Paypal/paypal/rest-api-sdk-php/sample/billing/ExecuteAgreement.php?success=true\",\"cancel_url\":\"https://www.mta.org/wp-content/plugins/AMS/api/Paypal/paypal/rest-api-sdk-php/sample/billing/ExecuteAgreement.php?success=false\",\"auto_bill_amount\":\"YES\",\"initial_fail_amount_action\":\"CONTINUE\",\"max_fail_attempts\":\"0\"},\"update_time\":\"2017-03-30T20:04:05.587Z\",\"create_time\":\"2017-03-30T20:04:05.587Z\",\"name\":\"T-Shirt of the Month Club Plan\",\"description\":\"Template creation.\",\"links\":[{\"href\":\"api.sandbox.paypal.com/v1/payments/billing-plans/P-2U911356NH683973BEDIWKUY\",\"rel\":\"self\",\"method\":\"GET\"}],\"payment_definitions\":[{\"name\":\"Regular Payments\",\"type\":\"REGULAR\",\"frequency\":\"Month\",\"frequency_interval\":\"2\",\"amount\":{\"currency\":\"USD\",\"value\":\"100\"},\"cycles\":\"12\",\"charge_models\":[{\"type\":\"SHIPPING\",\"amount\":{\"currency\":\"USD\",\"value\":\"10\"},\"id\":\"CHM-6H655806YS685182XEDIWKUY\"}],\"id\":\"PD-5N450756VM995270VEDIWKUY\"}],\"id\":\"P-2U911356NH683973BEDIWKUY\",\"state\":\"CREATED\",\"type\":\"FIXED\"},\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2MW4820926242972J-6SG447389E205703U\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-2MW4820926242972J-6SG447389E205703U/resend\",\"rel\":\"resend\",\"method\":\"POST\"}]}";
}
@Test(groups = "unit")
public void testValidEndpoint() throws InvalidKeyException, NoSuchAlgorithmException, SignatureException {
try {
boolean result = Event.validateReceivedEvent(apiContext, headers, requestBody);
Assert.assertTrue(result);
} catch (PayPalRESTException e) {
e.printStackTrace();
}
}
@Test(groups = "unit", expectedExceptions = PayPalRESTException.class, expectedExceptionsMessageRegExp = "webhook.id cannot be null" )
public void testMissingWebhookId() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
//configs.remove(Constants.PAYPAL_WEBHOOK_ID);
//apiContext.setConfigurationMap(configs);
apiContext.getConfigurationMap().remove(Constants.PAYPAL_WEBHOOK_ID);
if (PayPalResource.getConfigurations() != null && PayPalResource.getConfigurations().containsKey(Constants.PAYPAL_WEBHOOK_ID)) {
PayPalResource.getConfigurations().remove(Constants.PAYPAL_WEBHOOK_ID);
}
Event.validateReceivedEvent(apiContext, headers, requestBody);
}
@Test(groups = "unit")
public void testInvalidWebhookId() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
configs.put(Constants.PAYPAL_WEBHOOK_ID, "NotToBeFound");
apiContext.setConfigurationMap(configs);
boolean result = Event.validateReceivedEvent(apiContext, headers, requestBody);
Assert.assertFalse(result);
}
@Test(groups = "unit")
public void testDefaultCert() throws Exception {
boolean result = Event.validateReceivedEvent(apiContext, headers, requestBody);
Assert.assertTrue(result);
}
@Test(groups = "unit", expectedExceptions= PayPalRESTException.class, expectedExceptionsMessageRegExp="Certificate Not Found")
public void testInvalidTrustCertLocation() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
configs.put(Constants.PAYPAL_TRUST_CERT_URL, "InvalidCertLocation.crt");
apiContext.setConfigurationMap(configs);
Event.validateReceivedEvent(apiContext, headers, requestBody);
}
@Test(groups = "unit")
public void testInvalidAuthType() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
configs.put(Constants.PAYPAL_WEBHOOK_CERTIFICATE_AUTHTYPE, "Invalid");
apiContext.setConfigurationMap(configs);
Event.validateReceivedEvent(apiContext, headers, requestBody);
}
@Test(groups = "unit")
public void testInvalidRequestBody() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
requestBody = "{ something invalid }";
Event.validateReceivedEvent(apiContext, headers, requestBody);
}
@Test(groups = "unit", expectedExceptions= NoSuchAlgorithmException.class, expectedExceptionsMessageRegExp="NotToBeFound Signature not available")
public void testInvalidAuthAlgo() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
headers.put(Constants.PAYPAL_HEADER_AUTH_ALGO, "NotToBeFound");
Event.validateReceivedEvent(apiContext, headers, requestBody);
}
@Test(groups = "unit", expectedExceptions = PayPalRESTException.class, expectedExceptionsMessageRegExp = "Headers cannot be null")
public void testEmptyHeaders() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
Event.validateReceivedEvent(apiContext, null, requestBody);
}
@Test(groups = "unit")
public void testEmptyRequestBody() throws PayPalRESTException, InvalidKeyException, NoSuchAlgorithmException, SignatureException {
Assert.assertFalse(Event.validateReceivedEvent(apiContext, headers, null));
}
}
| 3,721 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/UnitTestConstants.java
|
package com.paypal.base;
/**
*
* constants used for testing
*
*/
public class UnitTestConstants {
/**
* mimics the API User details in properties file. Replace account details
* with the one you are using to make API call
*
*/
public static final String API_USER_NAME = "jb-us-seller_api1.paypal.com";
public static final String API_PASSWORD = "WX4WTU3S8MY44S7F";
public static final String API_SIGNATURE = "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy";
public static final String APP_ID = "APP-80W284485P519543T";
public static final String API_ENDPOINT = "https://svcs.sandbox.paypal.com/";
public static final String ACCESS_TOKEN = "AhARVvVPBOlOICu1xkH29I53ZvD.0p-vYauZhyWnKxMb5861PXG82Q";
public static final String TOKEN_SECRET = "Ctsch..an4Bgx0I75X8CTNxqRn8";
/**
* Replace with your resource details
*
*/
public static final String FILE_PATH = "/sdk_config.properties";
public static final String CERT_PATH = "src/test/resources/sdk-cert.p12";
public static final String CERT_PASSWORD = "password";
}
| 3,722 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/DataProviderClass.java
|
package com.paypal.base;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.testng.annotations.DataProvider;
@SuppressWarnings("deprecation")
public class DataProviderClass {
static ConfigManager conf;
@DataProvider(name = "configParams")
public static Object[][] configParams() throws FileNotFoundException,
IOException {
conf = ConfigManager.getInstance();
InputStream in = DataProviderClass.class
.getResourceAsStream("/sdk_config.properties");
conf.load(in);
return new Object[][] { new Object[] { conf } };
}
@DataProvider(name = "configParamsForSoap")
public static Object[][] configParamsForSoap()
throws FileNotFoundException, IOException {
conf = ConfigManager.getInstance();
InputStream in = DataProviderClass.class
.getResourceAsStream("/sdk_config_soap.properties");
conf.load(in);
return new Object[][] { new Object[] { conf } };
}
@DataProvider(name = "configParamsForProxy")
public static Object[][] configParamsForProxy()
throws FileNotFoundException, IOException {
conf = ConfigManager.getInstance();
InputStream in = DataProviderClass.class
.getResourceAsStream("/sdk_config_proxy.properties");
conf.load(in);
return new Object[][] { new Object[] { conf } };
}
}
| 3,723 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/NVPUtilTest.java
|
package com.paypal.base;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
public class NVPUtilTest {
@Test
public void decodeTest() throws UnsupportedEncodingException {
String nvpString = "responseEnvelope.timestamp=2011-05-17T21%3A24%3A44.279-07%3A00&responseEnvelope.ack=Success&responseEnvelope.correlationId=ca0c236593634&responseEnvelope.build=1901705&invoiceID=INV2-AAWE-TAQW-7UXT-ZHBY&invoiceNumber=INV-00404";
Map<String, String> map = NVPUtil.decode(nvpString);
Assert.assertEquals(6, map.size());
assert (map.containsValue("Success"));
assert (map.containsKey("invoiceID"));
assert (map.containsKey("invoiceNumber"));
Assert.assertEquals("INV2-AAWE-TAQW-7UXT-ZHBY", map.get("invoiceID"));
Assert.assertEquals("INV-00404", map.get("invoiceNumber"));
}
@Test
public void encodeTest() throws UnsupportedEncodingException {
String value = "[email protected]";
Assert.assertEquals("jbui-us-personal1%40paypal.com",
NVPUtil.encodeUrl(value));
}
}
| 3,724 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/ConfigurationUtil.java
|
package com.paypal.base;
import java.util.HashMap;
import java.util.Map;
public class ConfigurationUtil {
public static Map<String, String> getSignatureConfiguration() {
Map<String, String> initMap = new HashMap<String, String>();
initMap.put("acct1.UserName", "jb-us-seller_api1.paypal.com");
initMap.put("acct1.Password", "WX4WTU3S8MY44S7F");
initMap.put("acct1.Signature",
"AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
initMap.put("acct1.AppId", "APP-80W284485P519543T");
initMap.put("mode", "sandbox");
return initMap;
}
public static Map<String, String> getCertificateConfiguration() {
Map<String, String> initMap = new HashMap<String, String>();
initMap.put("acct2.UserName", "certuser_biz_api1.paypal.com");
initMap.put("acct2.Password", "D6JNKKULHN3G5B8A");
initMap.put("acct2.CertKey", "password");
initMap.put("acct2.CertPath", "src/test/resources/sdk-cert.p12");
initMap.put("acct2.AppId", "APP-80W284485P519543T");
initMap.put("mode", "sandbox");
return initMap;
}
}
| 3,725 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/GoogleAppEngineHttpConnectionTest.java
|
package com.paypal.base;
import com.paypal.base.exception.HttpErrorException;
import com.paypal.base.exception.InvalidResponseDataException;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.HashMap;
import static org.mockito.Mockito.*;
public class GoogleAppEngineHttpConnectionTest {
GoogleAppEngineHttpConnection googleAppEngineHttpConnection;
HttpConfiguration httpConfiguration;
@BeforeMethod
public void setup() {
googleAppEngineHttpConnection = new GoogleAppEngineHttpConnection();
httpConfiguration = new HttpConfiguration();
}
@Test(expectedExceptions = MalformedURLException.class)
public void checkMalformedURLExceptionTest() throws Exception {
httpConfiguration.setEndPointUrl("ww.paypal.in");
googleAppEngineHttpConnection
.createAndconfigureHttpConnection(httpConfiguration);
}
@Test
public void testCreateAndConfigureHttpConnection_setsRequestMethodToPost() throws IOException {
httpConfiguration.setEndPointUrl("http://www.paypal.com");
httpConfiguration.setHttpMethod("PATCH");
GoogleAppEngineHttpConnection googleAppEngineHttpConnection = spy(GoogleAppEngineHttpConnection.class);
doCallRealMethod().when(googleAppEngineHttpConnection).createAndconfigureHttpConnection((HttpConfiguration) any());
googleAppEngineHttpConnection.createAndconfigureHttpConnection(httpConfiguration);
Assert.assertEquals("POST", googleAppEngineHttpConnection.connection.getRequestMethod());
}
@Test
public void testExecuteWithStream_usesPostInsteadOfPatchAndAddsOverrideHeader() throws InterruptedException, HttpErrorException, InvalidResponseDataException, IOException {
httpConfiguration.setEndPointUrl("http://www.paypal.com");
httpConfiguration.setHttpMethod("PATCH");
GoogleAppEngineHttpConnection googleAppEngineHttpConnection = spy(GoogleAppEngineHttpConnection.class);
doCallRealMethod().when(googleAppEngineHttpConnection).createAndconfigureHttpConnection((HttpConfiguration) any());
try {
googleAppEngineHttpConnection.createAndconfigureHttpConnection(httpConfiguration);
googleAppEngineHttpConnection.executeWithStream(null, "payload", new HashMap<String, String>());
} catch (Exception ex) {
// Do nothing
}
verify(googleAppEngineHttpConnection).setHttpHeaders(new HashMap<String, String>() {{
put("X-HTTP-Method-Override", "PATCH");
}});
Assert.assertEquals("POST", googleAppEngineHttpConnection.connection.getRequestMethod());
}
}
| 3,726 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/ConfigManagerTest.java
|
package com.paypal.base;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.testng.Assert;
import org.testng.annotations.Test;
@SuppressWarnings("deprecation")
public class ConfigManagerTest {
@Test(dataProvider = "configParams", dataProviderClass = DataProviderClass.class)
public void loadTest(ConfigManager conf) {
Assert.assertEquals(conf.isPropertyLoaded(), true);
}
@Test(dataProvider = "configParams", dataProviderClass = DataProviderClass.class)
public void getValuesByCategoryTest(ConfigManager conf) {
Map<String, String> map = conf.getValuesByCategory("acct");
Iterator<String> itr = map.keySet().iterator();
while (itr.hasNext()) {
assert (((String) itr.next()).contains("acct"));
}
}
@Test(dataProvider = "configParams", dataProviderClass = DataProviderClass.class)
public void getNumOfAcctTest(ConfigManager conf) {
Set<String> set = conf.getNumOfAcct();
Iterator<String> itr = set.iterator();
while (itr.hasNext()) {
assert (((String) itr.next()).contains("acct"));
}
}
}
| 3,727 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/credential/TokenAuthorizationTest.java
|
package com.paypal.base.credential;
import org.testng.annotations.Test;
public class TokenAuthorizationTest {
@Test(expectedExceptions = IllegalArgumentException.class)
public void illegalArgumentExceptionTest() {
new TokenAuthorization(null, null);
}
}
| 3,728 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/util/TestConstants.java
|
package com.paypal.base.util;
import com.paypal.base.rest.APIContext;
public class TestConstants {
public static final String SANDBOX_CLIENT_ID = "AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS";
public static final String SANDBOX_CLIENT_SECRET = "EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL";
public static final APIContext SANDBOX_CONTEXT = new APIContext(SANDBOX_CLIENT_ID, SANDBOX_CLIENT_SECRET, "sandbox");
}
| 3,729 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/rest/PayPalResourceTestCase.java
|
package com.paypal.base.rest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.paypal.base.ClientCredentials;
import com.paypal.base.Constants;
public class PayPalResourceTestCase {
@Test
public void testUnknownFileConfiguration() {
try {
PayPalResource.initConfig(new File("unknown.properties"));
} catch (PayPalRESTException e) {
Assert.assertEquals(e.getCause().getClass().getSimpleName(),
"FileNotFoundException");
}
}
@Test
public void testInputStreamConfiguration() {
try {
File testFile = new File(".",
"src/test/resources/sdk_config.properties");
FileInputStream fis = new FileInputStream(testFile);
PayPalResource.initConfig(fis);
} catch (PayPalRESTException e) {
Assert.fail("[sdk_config.properties] stream loading failed");
} catch (FileNotFoundException e) {
Assert.fail("[sdk_config.properties] file is not available");
}
}
@Test
public void testPropertiesConfiguration() {
try {
File testFile = new File(".",
"src/test/resources/sdk_config.properties");
Properties props = new Properties();
FileInputStream fis = new FileInputStream(testFile);
props.load(fis);
PayPalResource.initConfig(props);
} catch (FileNotFoundException e) {
Assert.fail("[sdk_config.properties] file is not available");
} catch (IOException e) {
Assert.fail("[sdk_config.properties] file is not loaded into properties");
}
}
@Test
public void testClientCredentials() {
try {
// Init configuration from file
File testFile = new File(getClass().getClassLoader().getResource("sdk_config.properties").getFile());
Properties props = new Properties();
FileInputStream fis = new FileInputStream(testFile);
props.load(fis);
PayPalResource.initConfig(props);
// Check if ClientCredentials is constructed correctly
ClientCredentials clientCredentials = PayPalResource.getCredential();
Assert.assertEquals(props.getProperty(Constants.CLIENT_ID), clientCredentials.getClientID());
Assert.assertEquals(props.getProperty(Constants.CLIENT_SECRET), clientCredentials.getClientSecret());
} catch (FileNotFoundException e) {
Assert.fail("[sdk_config.properties] file is not available");
} catch (IOException e) {
Assert.fail("[sdk_config.properties] file is not loaded into properties");
}
}
}
| 3,730 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/rest/PayPalRESTExceptionTestCase.java
|
package com.paypal.base.rest;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.paypal.api.payments.Error;
import com.paypal.base.exception.HttpErrorException;
public class PayPalRESTExceptionTestCase {
public static final String NAME = "VALIDATION_ERROR";
public static final String MESSAGE = "Invalid request - see details";
public static final String INFORMATION_LINK = "https://developer.paypal.com/docs/api/#VALIDATION_ERROR";
public static final String DEBUG_ID = "5c16c7e108c14";
public static final String DETAILS_FIELD = "number";
public static final String DETAILS_ISSUE = "Value is invalid";
public static final int RESPONSE_CODE = 400;
public static Error loadError() {
try {
BufferedReader br = new BufferedReader(new FileReader("src/test/resources/error.json"));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.getProperty("line.separator"));
line = br.readLine();
}
br.close();
return JSONFormatter.fromJSON(sb.toString(), Error.class);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Test(groups = "unit")
public void testCreateFromHttpErrorException(){
Error error = loadError();
HttpErrorException httpErrorException = new HttpErrorException(RESPONSE_CODE, error.toJSON(), error.getMessage(), null);
PayPalRESTException ppre = PayPalRESTException.createFromHttpErrorException(httpErrorException);
Assert.assertNotNull(ppre);
Assert.assertNotNull(ppre.getDetails());
Assert.assertEquals(ppre.getResponsecode(), RESPONSE_CODE);
error = ppre.getDetails();
Assert.assertNotNull(error);
Assert.assertEquals(error.getName(), NAME);
Assert.assertEquals(error.getMessage(), MESSAGE);
Assert.assertEquals(error.getInformationLink(), INFORMATION_LINK);
Assert.assertEquals(error.getDebugId(), DEBUG_ID);
Assert.assertNotNull(error.getDetails());
Assert.assertEquals(error.getDetails().size(), 1);
Assert.assertEquals(error.getDetails().get(0).getField(), DETAILS_FIELD);
Assert.assertEquals(error.getDetails().get(0).getIssue(), DETAILS_ISSUE);
}
}
| 3,731 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/rest/RESTAPICallPreHandlerTest.java
|
package com.paypal.base.rest;
import com.paypal.base.Constants;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
public class RESTAPICallPreHandlerTest {
@Test
public void getBaseURL_returnsServiceEndpointIfSet() throws MalformedURLException {
Map<String, String> configurations = new HashMap<String, String>();
configurations.put(Constants.ENDPOINT, "https://www.example.com/abc");
RESTAPICallPreHandler restapiCallPreHandler = new RESTAPICallPreHandler(configurations);
URL result = restapiCallPreHandler.getBaseURL();
assertNotNull(result);
assertEquals(result.getHost(), "www.example.com");
assertEquals(result.getPath(), "/abc/");
}
@Test
public void getBaseURL_usesModeEndpointIfServiceEndpointNotSet() throws MalformedURLException {
Map<String, String> configurations = new HashMap<String, String>();
configurations.put(Constants.MODE, "sandbox");
RESTAPICallPreHandler restapiCallPreHandler = new RESTAPICallPreHandler(configurations);
URL result = restapiCallPreHandler.getBaseURL();
assertNotNull(result);
assertEquals(result.getHost(), "api.sandbox.paypal.com");
assertEquals(result.getPath(), "/");
}
@Test(expectedExceptions = MalformedURLException.class, expectedExceptionsMessageRegExp = "service\\.EndPoint not set \\(OR\\) mode not configured to sandbox\\/live ")
public void getBaseURL_throwsExceptionIfBothModeAndServiceEndpointNotSet() throws MalformedURLException {
Map<String, String> configurations = new HashMap<String, String>();
RESTAPICallPreHandler restapiCallPreHandler = new RESTAPICallPreHandler(configurations);
restapiCallPreHandler.getBaseURL();
}
}
| 3,732 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/rest/RESTConfigurationTestCase.java
|
package com.paypal.base.rest;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
public class RESTConfigurationTestCase {
@Test()
public void testRESTConfiguration() {
try {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put("service.EndPoint", "https://localhost.sandbox.paypal.com");
RESTAPICallPreHandler restConfiguration = new RESTAPICallPreHandler(configurationMap);
restConfiguration.setResourcePath("/a/b/c");
URL url = restConfiguration.getBaseURL();
Assert.assertEquals(true, url.toString().endsWith("/"));
} catch (MalformedURLException e) {
Assert.fail();
}
}
@Test(dependsOnMethods = { "testRESTConfiguration" })
public void testRESTHeaderConfiguration() {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put("service.EndPoint", "https://localhost.sandbox.paypal.com");
RESTAPICallPreHandler restConfiguration = new RESTAPICallPreHandler(configurationMap);
restConfiguration.setResourcePath("/a/b/c");
Map<String, String> headers = restConfiguration.getHeaderMap();
Assert.assertEquals(headers.size() != 0, true);
String header = headers.get("User-Agent");
String[] hdrs = header.split("\\(");
hdrs = hdrs[1].split(";");
Assert.assertEquals(hdrs.length >= 4, true);
}
@Test(dependsOnMethods = { "testRESTHeaderConfiguration" })
public void testRESTConfigurationURL() {
try {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put("service.EndPoint", "https://localhost.sandbox.paypal.com");
RESTAPICallPreHandler restConfiguration = new RESTAPICallPreHandler(configurationMap);
restConfiguration.setResourcePath("/a/b/c");
String urlString = "https://sample.com";
restConfiguration.setUrl(urlString);
URL returnURL = restConfiguration.getBaseURL();
Assert.assertEquals(true, returnURL.toString().endsWith("/"));
} catch (MalformedURLException e) {
Assert.fail();
}
}
}
| 3,733 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/rest/OAuthTokenCredentialTestCase.java
|
package com.paypal.base.rest;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import com.paypal.base.Constants;
import com.paypal.base.HttpConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;
import com.paypal.base.exception.HttpErrorException;
import static com.paypal.base.Constants.HTTP_CONNECTION_TIMEOUT;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
public class OAuthTokenCredentialTestCase {
private static final Logger logger = Logger
.getLogger(OAuthTokenCredentialTestCase.class);
String clientID;
String clientSecret;
@BeforeClass
public void beforeClass() {
clientID = "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM";
clientSecret = "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM";
}
@Test(priority = 20, groups = "integration")
public void testGetAccessToken() throws PayPalRESTException {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put("service.EndPoint",
"https://api.sandbox.paypal.com");
OAuthTokenCredential merchantTokenCredential = new OAuthTokenCredential(
clientID, clientSecret, configurationMap);
String accessToken = merchantTokenCredential.getAccessToken();
logger.info("Generated Access Token = " + accessToken);
Assert.assertEquals(true, accessToken.length() > 0);
Assert.assertEquals(true, merchantTokenCredential.expiresIn() > 0);
}
@Test(dependsOnMethods = { "testGetAccessToken" }, groups = "integration")
public void testErrorAccessToken() {
try {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put("service.EndPoint",
"https://localhost.sandbox.paypal.com");
OAuthTokenCredential merchantTokenCredential = new OAuthTokenCredential(
clientID, clientSecret, configurationMap);
merchantTokenCredential.getAccessToken();
} catch (PayPalRESTException e) {
Assert.assertEquals(true, e.getCause() instanceof HttpErrorException);
}
}
@Test
public void getOAuthHttpConfiguration_returnsServiceEndpointIfSet() throws MalformedURLException {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put(Constants.OAUTH_ENDPOINT,
"https://oauth.example.com/abc");
HttpConfiguration result = new OAuthTokenCredential("abc", "def", configurationMap).getOAuthHttpConfiguration();
assertNotNull(result);
assertEquals(result.getEndPointUrl(), "https://oauth.example.com/abc/v1/oauth2/token");
}
@Test
public void getOAuthHttpConfiguration_usesModeEndpointIfServiceEndpointNotSet() throws MalformedURLException {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put(Constants.MODE, "sandbox");
HttpConfiguration result = new OAuthTokenCredential("abc", "def", configurationMap).getOAuthHttpConfiguration();
assertNotNull(result);
assertEquals(result.getEndPointUrl(), "https://api.sandbox.paypal.com/v1/oauth2/token");
}
@Test(expectedExceptions = MalformedURLException.class, expectedExceptionsMessageRegExp = "oauth\\.Endpoint, mode or service\\.EndPoint not set not configured to sandbox\\/live ")
public void getOAuthHttpConfiguration_throwsExceptionIfBothModeAndServiceEndpointNotSet() throws MalformedURLException {
new OAuthTokenCredential("abc", "def", new HashMap<String, String>()).getOAuthHttpConfiguration();
}
@Test
public void getOAuthHttpConfiguration_setsTimeoutConfigurationIfPresent() throws MalformedURLException {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put(Constants.MODE, "sandbox");
configurationMap.put(HTTP_CONNECTION_TIMEOUT, "99");
HttpConfiguration httpConfiguration = new OAuthTokenCredential("abc", "def", configurationMap).getOAuthHttpConfiguration();
Assert.assertNotNull(httpConfiguration);
Assert.assertEquals(httpConfiguration.getConnectionTimeout(), 99);
}
}
| 3,734 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/test/java/com/paypal/base/rest/RESTUtilTest.java
|
package com.paypal.base.rest;
import java.util.HashMap;
import java.util.Map;
import org.testng.Assert;
import org.testng.annotations.Test;
public class RESTUtilTest {
@Test()
public void testFormatURIPathForNull() {
String nullString = RESTUtil.formatURIPath((String) null,
(Object[]) null);
Assert.assertNull(nullString);
}
@Test(dependsOnMethods = { "testFormatURIPathForNull" })
public void testFormatURIPathNoPattern() {
String pattern = "/a/b/c";
String uriPath = RESTUtil.formatURIPath(pattern, (Object[]) null);
Assert.assertEquals(uriPath, pattern);
}
@Test(dependsOnMethods = { "testFormatURIPathNoPattern" })
public void testFormatURIPathNoQS() {
String pattern = "/a/b/{0}";
Object[] parameters = new Object[] { "replace" };
String uriPath = RESTUtil.formatURIPath(pattern, parameters);
Assert.assertEquals(uriPath, "/a/b/replace");
}
@Test(dependsOnMethods = { "testFormatURIPathNoQS" })
public void testFormatURIPath() {
String pattern = "/a/b/{0}?name={1}";
Object[] parameters = new Object[] { "replace", "nameValue" };
String uriPath = RESTUtil.formatURIPath(pattern, parameters);
Assert.assertEquals(uriPath, "/a/b/replace?name=nameValue");
}
@Test(dependsOnMethods = { "testFormatURIPath" })
public void testFormatURIPathWithNull() {
String pattern = "/a/b/{0}?name={1}&age={2}";
Object[] parameters = new Object[] { "replace", "nameValue", null };
String uriPath = RESTUtil.formatURIPath(pattern, parameters);
Assert.assertEquals(uriPath, "/a/b/replace?name=nameValue");
}
@Test(dependsOnMethods = { "testFormatURIPathWithNull" })
public void testFormatURIPathWithEmpty() {
String pattern = "/a/b/{0}?name={1}&age=";
Object[] parameters = new Object[] { "replace", "nameValue", null };
String uriPath = RESTUtil.formatURIPath(pattern, parameters);
Assert.assertEquals(uriPath, "/a/b/replace?name=nameValue");
}
@Test(dependsOnMethods = { "testFormatURIPathWithEmpty" })
public void testFormatURIPathTwoQS() {
String pattern = "/a/b/{0}?name={1}&age={2}";
Object[] parameters = new Object[] { "replace", "nameValue", "1" };
String uriPath = RESTUtil.formatURIPath(pattern, parameters);
Assert.assertEquals(uriPath, "/a/b/replace?name=nameValue&age=1");
}
@Test(dependsOnMethods = { "testFormatURIPathTwoQS" })
public void testFormatURIPathMap() throws PayPalRESTException {
String pattern = "/a/b/{first}/{second}";
Map<String, String> pathParameters = new HashMap<String, String>();
pathParameters.put("first", "value1");
pathParameters.put("second", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters);
Assert.assertEquals(uriPath, "/a/b/value1/value2");
}
@Test(dependsOnMethods = { "testFormatURIPathMap" })
public void testFormatURIPathMapTraillingSlash() throws PayPalRESTException {
String pattern = "/a/b/{first}/{second}/";
Map<String, String> pathParameters = new HashMap<String, String>();
pathParameters.put("first", "value1");
pathParameters.put("second", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters);
Assert.assertEquals(uriPath, "/a/b/value1/value2/");
}
@Test(dependsOnMethods = { "testFormatURIPathMapTraillingSlash" })
public void testFormatURIPathMapNullMap() throws PayPalRESTException {
String pattern = "/a/b/first/second";
String uriPath = RESTUtil.formatURIPath(pattern,
(Map<String, String>) null);
Assert.assertEquals(uriPath, "/a/b/first/second");
}
@Test(dependsOnMethods = { "testFormatURIPathMapNullMap" })
public void testFormatURIPathMapIncorrectMap() throws PayPalRESTException {
String pattern = "/a/b/first/second";
Map<String, String> pathParameters = new HashMap<String, String>();
pathParameters.put("invalid1", "value1");
pathParameters.put("invalid2", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters);
Assert.assertEquals(uriPath, "/a/b/first/second");
}
@Test(dependsOnMethods = { "testFormatURIPathMapIncorrectMap" }, expectedExceptions = PayPalRESTException.class)
public void testFormatURIPathMapInsufficientMap()
throws PayPalRESTException {
String pattern = "/a/b/{first}/{second}";
Map<String, String> pathParameters = new HashMap<String, String>();
pathParameters.put("first", "value1");
RESTUtil.formatURIPath(pattern, pathParameters);
}
@Test(dependsOnMethods = { "testFormatURIPathMapInsufficientMap" })
public void testFormatURIPathMapNullQueryMap() throws PayPalRESTException {
String pattern = "/a/b/{first}/{second}";
Map<String, String> pathParameters = new HashMap<String, String>();
pathParameters.put("first", "value1");
pathParameters.put("second", "value2");
Map<String, String> queryParameters = null;
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters,
queryParameters);
Assert.assertEquals(uriPath, "/a/b/value1/value2");
}
@Test(dependsOnMethods = { "testFormatURIPathMapNullQueryMap" })
public void testFormatURIPathMapEmptyQueryMap() throws PayPalRESTException {
String pattern = "/a/b/{first}/{second}";
Map<String, String> pathParameters = new HashMap<String, String>();
pathParameters.put("first", "value1");
pathParameters.put("second", "value2");
Map<String, String> queryParameters = new HashMap<String, String>();
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters,
queryParameters);
Assert.assertEquals(uriPath, "/a/b/value1/value2");
}
@Test(dependsOnMethods = { "testFormatURIPathMapEmptyQueryMap" })
public void testFormatURIPathMapQueryMap() throws PayPalRESTException {
String pattern = "/a/b/first/second";
Map<String, String> pathParameters = new HashMap<String, String>();
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("query1", "value1");
queryParameters.put("query2", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters,
queryParameters);
Assert.assertEquals(uriPath,
"/a/b/first/second?query1=value1&query2=value2&");
}
@Test(dependsOnMethods = { "testFormatURIPathMapQueryMap" })
public void testFormatURIPathMapQueryMapQueryURIPath()
throws PayPalRESTException {
String pattern = "/a/b/first/second?";
Map<String, String> pathParameters = new HashMap<String, String>();
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("query1", "value1");
queryParameters.put("query2", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters,
queryParameters);
Assert.assertEquals(uriPath,
"/a/b/first/second?query1=value1&query2=value2&");
}
@Test(dependsOnMethods = { "testFormatURIPathMapQueryMapQueryURIPath" })
public void testFormatURIPathMapQueryMapQueryURIPathEncode()
throws PayPalRESTException {
String pattern = "/a/b/first/second";
Map<String, String> pathParameters = new HashMap<String, String>();
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("query1", "value&1");
queryParameters.put("query2", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters,
queryParameters);
Assert.assertEquals(uriPath,
"/a/b/first/second?query1=value%261&query2=value2&");
}
@Test(dependsOnMethods = { "testFormatURIPathMapQueryMapQueryURIPathEncode" })
public void testFormatURIPathMapQueryMapQueryValueURIPath()
throws PayPalRESTException {
String pattern = "/a/b/first/second?alreadypresent=value";
Map<String, String> pathParameters = new HashMap<String, String>();
Map<String, String> queryParameters = new HashMap<String, String>();
queryParameters.put("query1", "value1");
queryParameters.put("query2", "value2");
String uriPath = RESTUtil.formatURIPath(pattern, pathParameters,
queryParameters);
Assert.assertEquals(uriPath,
"/a/b/first/second?alreadypresent=value&query1=value1&query2=value2&");
}
}
| 3,735 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/RefundDetail.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class RefundDetail extends PayPalModel {
/**
* The PayPal refund type. Indicates whether refund was paid in invoicing flow through PayPal or externally. In the case of mark-as-refunded API, the supported refund type is `EXTERNAL`. For backward compatability, the `PAYPAL` refund type is still supported.
*/
private String type;
/**
* The PayPal refund transaction ID. Required with the `PAYPAL` refund type.
*/
private String transactionId;
/**
* Date on which the invoice was refunded. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*/
private String date;
/**
* Optional note associated with the refund.
*/
private String note;
/**
* Amount to be recorded as refund against invoice. If this field is not passed, the total invoice paid amount is recorded as refund.
*/
private Currency amount;
/**
* Default Constructor
*/
public RefundDetail() {
}
/**
* Parameterized Constructor
*/
public RefundDetail(String type) {
this.type = type;
}
}
| 3,736 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoicingPaymentDetail.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InvoicingPaymentDetail extends PayPalModel {
/**
* PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*/
private String type;
/**
* PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
*/
private String transactionId;
/**
* Type of the transaction.
*/
private String transactionType;
/**
* Date when the invoice was paid. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST.
*/
private String date;
/**
* Payment mode or method. This field is mandatory if the value of the type field is OTHER.
*/
private String method;
/**
* Optional note associated with the payment.
*/
private String note;
/**
* Default Constructor
*/
public InvoicingPaymentDetail() {
}
/**
* Parameterized Constructor
*/
public InvoicingPaymentDetail(String method) {
this.method = method;
}
}
| 3,737 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CreditCardHistory.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CreditCardHistory extends PayPalModel {
/**
* A list of credit card resources
*/
private List<CreditCard> items;
/**
* Total number of items.
*/
private int totalItems;
/**
* Total number of pages.
*/
private int totalPages;
/**
* HATEOAS links related to this call. Value assigned by PayPal.
*/
private List<Links> links;
/**
* Default Constructor
*/
public CreditCardHistory() {
items = new ArrayList<CreditCard>();
links = new ArrayList<Links>();
}
}
| 3,738 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/AlternatePayment.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AlternatePayment extends PayPalModel {
/**
* The unique identifier of the alternate payment account.
*/
private String alternatePaymentAccountId;
/**
* The unique identifier of the payer
*/
private String externalCustomerId;
/**
* Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal
*/
private String alternatePaymentProviderId;
/**
* Default Constructor
*/
public AlternatePayment() {
}
/**
* Parameterized Constructor
*/
public AlternatePayment(String alternatePaymentAccountId) {
this.alternatePaymentAccountId = alternatePaymentAccountId;
}
}
| 3,739 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InstallmentOption.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InstallmentOption extends PayPalModel {
/**
* Number of installments
*/
private int term;
/**
* Monthly payment
*/
private Currency monthlyPayment;
/**
* Discount amount applied to the payment, if any
*/
private Currency discountAmount;
/**
* Discount percentage applied to the payment, if any
*/
private Percentage discountPercentage;
/**
* Default Constructor
*/
public InstallmentOption() {
}
/**
* Parameterized Constructor
*/
public InstallmentOption(int term, Currency monthlyPayment) {
this.term = term;
this.monthlyPayment = monthlyPayment;
}
}
| 3,740 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/BankToken.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BankToken extends PayPalModel {
/**
* ID of a previously saved Bank resource using /vault/bank API.
*/
private String bankId;
/**
* The unique identifier of the payer used when saving this bank using /vault/bank API.
*/
private String externalCustomerId;
/**
* Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
*/
private String mandateReferenceNumber;
/**
* Default Constructor
*/
public BankToken() {
}
/**
* Parameterized Constructor
*/
public BankToken(String bankId, String externalCustomerId) {
this.bankId = bankId;
this.externalCustomerId = externalCustomerId;
}
}
| 3,741 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoicingRefundDetail.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InvoicingRefundDetail extends PayPalModel {
/**
* PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
*/
private String type;
/**
* Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date.
*/
private String date;
/**
* Optional note associated with the refund.
*/
private String note;
/**
* Default Constructor
*/
public InvoicingRefundDetail() {
}
/**
* Parameterized Constructor
*/
public InvoicingRefundDetail(String type) {
this.type = type;
}
}
| 3,742 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Participant.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Participant extends PayPalModel {
/**
* The participant email address.
*/
private String email;
/**
* The participant first name.
*/
private String firstName;
/**
* The participant last name.
*/
private String lastName;
/**
* The participant company business name.
*/
private String businessName;
/**
* The participant phone number.
*/
private Phone phone;
/**
* The participant fax number.
*/
private Phone fax;
/**
* The participant website.
*/
private String website;
/**
* Additional information, such as business hours.
*/
private String additionalInfo;
/**
* The participant address.
*/
private InvoiceAddress address;
/**
* Default Constructor
*/
public Participant() {
}
/**
* Parameterized Constructor
*/
public Participant(String email) {
this.email = email;
}
}
| 3,743 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Tax.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Tax extends PayPalModel {
/**
* The resource ID.
*/
private String id;
/**
* The tax name. Maximum length is 20 characters.
*/
private String name;
/**
* The rate of the specified tax. Valid range is from 0.001 to 99.999.
*/
private double percent;
/**
* The tax as a monetary amount. Cannot be specified in a request.
*/
private Currency amount;
/**
* Default Constructor
*/
public Tax() {
}
/**
* Parameterized Constructor
*/
public Tax(String name, float percent) {
this.name = name;
this.percent = percent;
}
}
| 3,744 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/DefinitionsLinkdescription.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class DefinitionsLinkdescription extends PayPalModel {
/**
* a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing
*/
private String href;
/**
* relation to the target resource of the link
*/
private String rel;
/**
* a title for the link
*/
private String title;
/**
* JSON Schema describing the link target
*/
private DefinitionsLinkdescription targetSchema;
/**
* media type (as defined by RFC 2046) describing the link target
*/
private String mediaType;
/**
* method for requesting the target of the link (e.g. for HTTP this might be "GET" or "DELETE")
*/
private String method;
/**
* The media type in which to submit data along with the request
*/
private String encType;
/**
* Schema describing the data to submit along with the request
*/
private DefinitionsLinkdescription schema;
/**
* Default Constructor
*/
public DefinitionsLinkdescription() {
}
/**
* Parameterized Constructor
*/
public DefinitionsLinkdescription(String href, String rel) {
this.href = href;
this.rel = rel;
}
}
| 3,745 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Order.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Order extends PayPalResource {
/**
* Identifier of the order transaction.
*/
private String id;
/**
* Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base.
*/
private String purchaseUnitReferenceId;
/**
* @deprecated Use {@link #purchaseUnitReferenceId} instead
* Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base.
*/
@Deprecated
private String referenceId;
/**
* Amount being collected.
*/
private Amount amount;
/**
* specifies payment mode of the transaction
*/
private String paymentMode;
/**
* State of the order transaction.
*/
private String state;
/**
* Reason code for the transaction state being Pending or Reversed. This field will replace pending_reason field eventually. Only supported when the `payment_method` is set to `paypal`.
*/
private String reasonCode;
/**
* @deprecated Reason code for the transaction state being Pending. Obsolete. Retained for backward compatability. Use reason_code field above instead.
*/
@Deprecated
private String pendingReason;
/**
* The level of seller protection in force for the transaction.
*/
private String protectionEligibility;
/**
* The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned.
*/
private String protectionEligibilityType;
/**
* ID of the Payment resource that this transaction is based on.
*/
private String parentPayment;
/**
* Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
*/
private FmfDetails fmfDetails;
/**
* Time the resource was created in UTC ISO8601 format.
*/
private String createTime;
/**
* Time the resource was last updated in UTC ISO8601 format.
*/
private String updateTime;
/**
*
*/
private List<Links> links;
/**
* Default Constructor
*/
public Order() {
}
/**
* Parameterized Constructor
*/
public Order(Amount amount) {
this.amount = amount;
}
/**
* Shows details for an order, by ID.
* @deprecated Please use {@link #get(APIContext, String)} instead.
* @param accessToken
* Access Token used for the API call.
* @param orderId
* String
* @return Order
* @throws PayPalRESTException
*/
public static Order get(String accessToken, String orderId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, orderId);
}
/**
* Shows details for an order, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @param orderId
* String
* @return Order
* @throws PayPalRESTException
*/
public static Order get(APIContext apiContext, String orderId) throws PayPalRESTException {
if (orderId == null) {
throw new IllegalArgumentException("orderId cannot be null");
}
Object[] parameters = new Object[] {orderId};
String pattern = "v1/payments/orders/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Order.class);
}
/**
* Captures a payment for an order, by ID. To use this call, the original payment call must specify an intent of `order`. In the JSON request body, include the payment amount and indicate whether this capture is the final capture for the authorization.
* @deprecated Please use {@link #capture(APIContext, Capture)} instead.
* @param accessToken
* Access Token used for the API call.
* @param capture
* Capture
* @return Capture
* @throws PayPalRESTException
*/
public Capture capture(String accessToken, Capture capture) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return capture(apiContext, capture);
}
/**
* Captures a payment for an order, by ID. To use this call, the original payment call must specify an intent of `order`. In the JSON request body, include the payment amount and indicate whether this capture is the final capture for the authorization.
* @param apiContext
* {@link APIContext} used for the API call.
* @param capture
* Capture
* @return Capture
* @throws PayPalRESTException
*/
public Capture capture(APIContext apiContext, Capture capture) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (capture == null) {
throw new IllegalArgumentException("capture cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payments/orders/{0}/capture";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = capture.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Capture.class);
}
/**
* Voids, or cancels, an order, by ID. You cannot void an order if a payment has already been partially or fully captured.
* @deprecated Please use {@link #doVoid(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return Order
* @throws PayPalRESTException
*/
public Order doVoid(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return doVoid(apiContext);
}
/**
* Voids, or cancels, an order, by ID. You cannot void an order if a payment has already been partially or fully captured.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Order
* @throws PayPalRESTException
*/
public Order doVoid(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payments/orders/{0}/do-void";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Order.class);
}
/**
* Authorizes an order, by ID. Include an `amount` object in the JSON request body.
* @deprecated Please use {@link #authorize(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return Authorization
* @throws PayPalRESTException
*/
public Authorization authorize(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return authorize(apiContext);
}
/**
* Authorizes an order, by ID. Include an `amount` object in the JSON request body.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Authorization
* @throws PayPalRESTException
*/
public Authorization authorize(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payments/orders/{0}/authorize";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = this.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Authorization.class);
}
}
| 3,746 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/WebProfileList.java
|
package com.paypal.api.payments;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class WebProfileList extends ArrayList<WebProfile> {
/**
*
*/
private static final long serialVersionUID = 1L;
private List<WebProfile> webProfiles = null;
/**
* Default Constructor
*/
public WebProfileList() {
webProfiles = new ArrayList<WebProfile>();
}
}
| 3,747 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CreditCardToken.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CreditCardToken extends PayPalModel {
/**
* ID of credit card previously stored using `/vault/credit-card`.
*/
private String creditCardId;
/**
* A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. **Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.**
*/
private String payerId;
/**
* Last four digits of the stored credit card number.
*/
private String last4;
/**
* Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display.
*/
private String type;
/**
* Expiration month with no leading zero. Acceptable values are 1 through 12.
*/
private int expireMonth;
/**
* 4-digit expiration year.
*/
private int expireYear;
/**
* Default Constructor
*/
public CreditCardToken() {
}
/**
* Parameterized Constructor
*/
public CreditCardToken(String creditCardId) {
this.creditCardId = creditCardId;
}
}
| 3,748 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Phone.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Phone extends PayPalModel {
/**
* Country code (from in E.164 format)
*/
private String countryCode;
/**
* In-country phone number (from in E.164 format)
*/
private String nationalNumber;
/**
* Phone extension
*/
private String extension;
/**
* Default Constructor
*/
public Phone() {
}
/**
* Parameterized Constructor
*/
public Phone(String countryCode, String nationalNumber) {
this.countryCode = countryCode;
this.nationalNumber = nationalNumber;
}
}
| 3,749 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Image.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Image extends PayPalModel {
/**
* Image as base64 encoded String
*/
private String image;
/**
* Default Constructor
*/
public Image() {
}
/**
* Saves the image to a file.
*
* @param fileName filename ending with .png
* @return boolean true if write successful. false, otherwise.
* @throws IOException
*/
public boolean saveToFile(String fileName) throws IOException {
byte[] imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary(this.image);
BufferedImage img = ImageIO.read(new ByteArrayInputStream(imageBytes));
return ImageIO.write(img, "png", new File(fileName));
}
}
| 3,750 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FuturePayment.java
|
package com.paypal.api.payments;
import com.paypal.api.openidconnect.CreateFromAuthorizationCodeParameters;
import com.paypal.api.openidconnect.CreateFromRefreshTokenParameters;
import com.paypal.api.openidconnect.Tokeninfo;
import com.paypal.base.Constants;
import com.paypal.base.rest.APIContext;
import com.paypal.base.rest.PayPalRESTException;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class FuturePayment extends Payment {
/**
* Creates a future payment using either authorization code or refresh token
* with correlation ID. <br>
* https://developer.paypal.com/webapps/developer/docs/integration/mobile/
* make-future-payment/
*
* @param accessToken
* an access token
* @param correlationId
* paypal application correlation ID
* @return a <code>Payment</code> object
* @throws PayPalRESTException
* @throws IOException
* thrown when config file cannot be read properly
* @throws FileNotFoundException
* thrown when config file does not exist
*/
public Payment create(String accessToken, String correlationId)
throws PayPalRESTException, FileNotFoundException, IOException {
if (correlationId == null || correlationId.equals("")) {
throw new IllegalArgumentException("correlation ID cannot be null or empty");
}
APIContext apiContext = new APIContext(accessToken);
apiContext.addHTTPHeader("PAYPAL-CLIENT-METADATA-ID", correlationId);
return this.create(apiContext);
}
/**
* Creates a future payment using either authorization code or refresh token
* with correlation ID. <br>
* https://developer.paypal.com/webapps/developer/docs/integration/mobile/
* make-future-payment/
*
* @param apiContext {@link APIContext}
* @param correlationId
* paypal application correlation ID
* @return a <code>Payment</code> object
* @throws PayPalRESTException
* @throws IOException
* thrown when config file cannot be read properly
* @throws FileNotFoundException
* thrown when config file does not exist
*/
public Payment create(APIContext apiContext, String correlationId)
throws PayPalRESTException, FileNotFoundException, IOException {
if (correlationId == null || correlationId.equals("")) {
throw new IllegalArgumentException("correlation ID cannot be null or empty");
}
apiContext.addHTTPHeader("PAYPAL-CLIENT-METADATA-ID", correlationId);
return this.create(apiContext);
}
/**
* @deprecated Please use {@link #fetchRefreshToken(APIContext, String)} instead.
* In this method, we need to pass clientID, secret information that is already known to apiContext. The newer method allows for better
* code readability, and make it less error prone.
*
* @param params Authorization code params
* @return {@link Tokeninfo}
* @throws PayPalRESTException
*/
public Tokeninfo getTokeninfo(CreateFromAuthorizationCodeParameters params) throws PayPalRESTException {
Map<String, String> configurationMap = new HashMap<String, String>();
configurationMap.put(Constants.CLIENT_ID, params.getClientID());
configurationMap.put(Constants.CLIENT_SECRET, params.getClientSecret());
configurationMap.put("response_type", "token");
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(configurationMap);
params.setRedirectURI("urn:ietf:wg:oauth:2.0:oob");
Tokeninfo info = Tokeninfo.createFromAuthorizationCodeForFpp(apiContext, params);
return info;
}
/**
* @deprecated Please use {@link #fetchRefreshToken(APIContext, String)} instead.
* In this method, we need to pass clientID, secret information that is already known to apiContext. The newer method allows for better
* code readability, and make it less error prone.
*
* @param params parameters
* @return {@link Tokeninfo}
* @throws PayPalRESTException
*/
public Tokeninfo getTokeninfo(CreateFromRefreshTokenParameters params, Tokeninfo info) throws PayPalRESTException {
Map<String, String> configurationMap = new HashMap<String, String>();
APIContext apiContext = new APIContext();
apiContext.setConfigurationMap(configurationMap);
info = info.createFromRefreshToken(apiContext, params);
return info;
}
/**
* Fetches long lived refresh token from authorization code, for future payment use.
*
* @param context {@link APIContext}
* @param authorizationCode code returned from mobile
* @return String of refresh token
* @throws PayPalRESTException
*/
public static String fetchRefreshToken(APIContext context, String authorizationCode) throws PayPalRESTException {
CreateFromAuthorizationCodeParameters params = new CreateFromAuthorizationCodeParameters();
params.setClientID(context.getClientID());
params.setClientSecret(context.getClientSecret());
params.setCode(authorizationCode);
Tokeninfo info = Tokeninfo.createFromAuthorizationCodeForFpp(context, params);
return info.getRefreshToken();
}
}
| 3,751 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FmfDetails.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class FmfDetails extends PayPalModel {
/**
* Type of filter.
*/
private String filterType;
/**
* Filter Identifier.
*/
private String filterId;
/**
* Name of the filter
*/
private String name;
/**
* Description of the filter.
*/
private String description;
}
| 3,752 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Incentive.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Incentive extends PayPalModel {
/**
* Identifier of the instrument in PayPal Wallet
*/
private String id;
/**
* Code that identifies the incentive.
*/
private String code;
/**
* Name of the incentive.
*/
private String name;
/**
* Description of the incentive.
*/
private String description;
/**
* Indicates incentive is applicable for this minimum purchase amount.
*/
private Currency minimumPurchaseAmount;
/**
* Logo image url for the incentive.
*/
private String logoImageUrl;
/**
* expiry date of the incentive.
*/
private String expiryDate;
/**
* Specifies type of incentive
*/
private String type;
/**
* URI to the associated terms
*/
private String terms;
/**
* Default Constructor
*/
public Incentive() {
}
}
| 3,753 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Credit.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Credit extends PayPalModel {
/**
* Unique identifier of credit resource.
*/
private String id;
/**
* specifies type of credit
*/
private String type;
/**
* Default Constructor
*/
public Credit() {
}
/**
* Parameterized Constructor
*/
public Credit(String type) {
this.type = type;
}
}
| 3,754 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PlanList.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PlanList extends PayPalModel {
/**
* Array of billing plans.
*/
private List<Plan> plans;
/**
* Total number of items.
*/
private String totalItems;
/**
* Total number of pages.
*/
private String totalPages;
/**
*
*/
private List<Links> links;
/**
* Default Constructor
*/
public PlanList() {
plans = new ArrayList<Plan>();
links = new ArrayList<Links>();
}
}
| 3,755 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Patch.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Patch extends PayPalModel {
/**
* The operation to perform.
*/
private String op;
/**
* A JSON pointer that references a location in the target document where the operation is performed. A `string` value.
*/
private String path;
/**
* New value to apply based on the operation.
*/
private Object value;
/**
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
*/
private String from;
/**
* Default Constructor
*/
public Patch() {
}
/**
* Parameterized Constructor
*/
public Patch(String op, String path) {
this.op = op;
this.path = path;
}
}
| 3,756 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoiceNumber.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InvoiceNumber extends PayPalModel {
/**
* The next invoice number
*/
private String number;
/**
* Default Constructor
*/
public InvoiceNumber() {
}
}
| 3,757 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/AgreementTransactions.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AgreementTransactions extends PayPalModel {
/**
* Array of agreement_transaction object.
*/
private List<AgreementTransaction> agreementTransactionList;
/**
* Default Constructor
*/
public AgreementTransactions() {
agreementTransactionList = new ArrayList<AgreementTransaction>();
}
}
| 3,758 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentCardToken.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PaymentCardToken extends PayPalModel {
/**
* ID of a previously saved Payment Card resource.
*/
private String paymentCardId;
/**
* The unique identifier of the payer used when saving this payment card.
*/
private String externalCustomerId;
/**
* Last 4 digits of the card number from the saved card.
*/
private String last4;
/**
* Type of the Card.
*/
private String type;
/**
* card expiry month from the saved card with value 1 - 12
*/
private int expireMonth;
/**
* 4 digit card expiry year from the saved card
*/
private int expireYear;
/**
* Default Constructor
*/
public PaymentCardToken() {
}
/**
* Parameterized Constructor
*/
public PaymentCardToken(String paymentCardId, String externalCustomerId, String type) {
this.paymentCardId = paymentCardId;
this.externalCustomerId = externalCustomerId;
this.type = type;
}
}
| 3,759 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PatchRequest.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PatchRequest extends PayPalModel {
/**
* The operation to perform.
*/
private String op;
/**
* string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed.
*/
private String path;
/**
* New value to apply based on the operation.
*/
private String value;
/**
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
*/
private String from;
/**
* Default Constructor
*/
public PatchRequest() {
}
/**
* Parameterized Constructor
*/
public PatchRequest(String op, String path) {
this.op = op;
this.path = path;
}
}
| 3,760 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/BillingInfo.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BillingInfo extends PayPalModel {
/**
* The invoice recipient email address. Maximum length is 260 characters.
*/
private String email;
/**
* The invoice recipient first name. Maximum length is 30 characters.
*/
private String firstName;
/**
* The invoice recipient last name. Maximum length is 30 characters.
*/
private String lastName;
/**
* The invoice recipient company business name. Maximum length is 100 characters.
*/
private String businessName;
/**
* The invoice recipient address.
*/
private InvoiceAddress address;
/**
* The language in which the email was sent to the payer. Used only when the payer does not have a PayPal account.
*/
private String language;
/**
* Additional information, such as business hours. Maximum length is 40 characters.
*/
private String additionalInfo;
/**
* Preferred notification channel of the payer. Email by default.
*/
private String notificationChannel;
/**
* Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS.
*/
private Phone phone;
/**
* Default Constructor
*/
public BillingInfo() {
}
/**
* Parameterized Constructor
*/
public BillingInfo(String email) {
this.email = email;
}
}
| 3,761 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ShippingCost.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ShippingCost extends PayPalModel {
/**
* The shipping cost, as an amount. Valid range is from 0 to 999999.99.
*/
private Currency amount;
/**
* The tax percentage on the shipping amount.
*/
private Tax tax;
/**
* Default Constructor
*/
public ShippingCost() {
}
}
| 3,762 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PotentialPayerInfo.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PotentialPayerInfo extends PayPalModel {
/**
* Email address representing the potential payer.
*/
private String email;
/**
* ExternalRememberMe id representing the potential payer
*/
private String externalRememberMeId;
/**
* Account Number representing the potential payer
*/
private String accountNumber;
/**
* Billing address of the potential payer.
*/
private Address billingAddress;
/**
* Default Constructor
*/
public PotentialPayerInfo() {
}
}
| 3,763 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CarrierAccount.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CarrierAccount extends PayPalModel {
/**
* The ID of the carrier account of the payer. Use in subsequent REST API calls. For example, to make payments.
*/
private String id;
/**
* The phone number of the payer, in E.164 format.
*/
private String phoneNumber;
/**
* The ID of the customer, as created by the merchant.
*/
private String externalCustomerId;
/**
* The method used to obtain the phone number. Value is `READ_FROM_DEVICE` or `USER_PROVIDED`.
*/
private String phoneSource;
/**
* The ISO 3166-1 alpha-2 country code where the phone number is registered.
*/
private CountryCode countryCode;
/**
* Default Constructor
*/
public CarrierAccount() {
}
/**
* Parameterized Constructor
*/
public CarrierAccount(String externalCustomerId, CountryCode countryCode) {
this.externalCustomerId = externalCustomerId;
this.countryCode = countryCode;
}
}
| 3,764 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PrivateLabelCard.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PrivateLabelCard extends PayPalModel {
/**
* encrypted identifier of the private label card instrument.
*/
private String id;
/**
* last 4 digits of the card number.
*/
private String cardNumber;
/**
* Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account.
*/
private String issuerId;
/**
* Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account.
*/
private String issuerName;
/**
* This value indicates URL to access PLCC program logo image
*/
private String imageKey;
/**
* Default Constructor
*/
public PrivateLabelCard() {
}
}
| 3,765 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Invoice.java
|
package com.paypal.api.payments;
import com.paypal.api.openidconnect.Tokeninfo;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Invoice extends PayPalResource {
/**
* The unique invoice resource identifier.
*/
private String id;
/**
* Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max.
*/
private String number;
/**
* The template ID used for the invoice. Useful for copy functionality.
*/
private String templateId;
/**
* URI of the invoice resource.
*/
private String uri;
/**
* Status of the invoice.
*/
private String status;
/**
* Information about the merchant who is sending the invoice.
*/
private MerchantInfo merchantInfo;
/**
* The required invoice recipient email address and any optional billing information. One recipient is supported.
*/
private List<BillingInfo> billingInfo;
/**
* For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant.
*/
private List<Participant> ccInfo;
/**
* The shipping information for entities to whom items are being shipped.
*/
private ShippingInfo shippingInfo;
/**
* The list of items to include in the invoice. Maximum value is 100 items per invoice.
*/
private List<InvoiceItem> items;
/**
* The date when the invoice was enabled. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6).
*/
private String invoiceDate;
/**
* Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both.
*/
private PaymentTerm paymentTerm;
/**
* Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters.
*/
private String reference;
/**
* The invoice level discount, as a percent or an amount value.
*/
private Cost discount;
/**
* The shipping cost, as a percent or an amount value.
*/
private ShippingCost shippingCost;
/**
* The custom amount to apply on an invoice. If you include a label, the amount cannot be empty.
*/
private CustomAmount custom;
/**
* Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`.
*/
private Boolean allowPartialPayment;
/**
* If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment.
*/
private Currency minimumAmountDue;
/**
* Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`.
*/
private Boolean taxCalculatedAfterDiscount;
/**
* Indicates whether the unit price includes tax. Default is `false`.
*/
private Boolean taxInclusive;
/**
* General terms of the invoice. 4000 characters max.
*/
private String terms;
/**
* Note to the payer. 4000 characters max.
*/
private String note;
/**
* A private bookkeeping memo for the merchant. Maximum length is 150 characters.
*/
private String merchantMemo;
/**
* Full URL of an external image to use as the logo. Maximum length is 4000 characters.
*/
private String logoUrl;
/**
* The total amount of the invoice.
*/
private Currency totalAmount;
/**
* List of payment details for the invoice.
*/
private List<PaymentDetail> payments;
/**
* List of refund details for the invoice.
*/
private List<RefundDetail> refunds;
/**
* Audit information for the invoice.
*/
private Metadata metadata;
/**
* Any miscellaneous invoice data. Maximum length is 4000 characters.
*/
private String additionalData;
/**
* Gratuity to include with the invoice.
*/
private Currency gratuity;
/**
* Payment summary of the invoice including amount paid through PayPal and other sources.
*/
private PaymentSummary paidAmount;
/**
* Payment summary of the invoice including amount refunded through PayPal and other sources.
*/
private PaymentSummary refundedAmount;
/**
* List of files attached to the invoice.
*/
private List<FileAttachment> attachments;
/**
* HATEOS links representing all the actions over the invoice resource based on the current invoice status.
*/
private List<Links> links;
/**
* Default Constructor
*/
public Invoice() {
}
/**
* Parameterized Constructor
*/
public Invoice(MerchantInfo merchantInfo) {
this.merchantInfo = merchantInfo;
}
/**
* @deprecated Please use {@link #getPayments()} instead.
* @return {@link List} of {@link PaymentDetail}
*/
public List<PaymentDetail> getPaymentDetails(){
return this.payments;
}
/**
* @deprecated Please use {@link #setPayments(List)} instead.
* @param details
* @return {@link Invoice}
*/
public Invoice setPaymentDetails(List<PaymentDetail> details) {
this.payments = details;
return this;
}
/**
* @deprecated Please use {@link #getRefunds()} instead.
* @return {@link List} of {@link RefundDetail}
*/
public List<RefundDetail> getRefundDetails() {
return this.refunds;
}
/**
* @deprecated Please use {@link #setRefunds(List)} instead.
* @param details
* @return {@link Invoice}
*/
public Invoice setRefundDetails(List<RefundDetail> details) {
this.refunds = details;
return this;
}
/**
* Creates an invoice. Include invoice details including merchant information in the request.
* @deprecated Please use {@link #create(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return Invoice
* @throws PayPalRESTException
*/
public Invoice create(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return create(apiContext);
}
/**
* Creates an invoice. Include invoice details including merchant information in the request.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Invoice
* @throws PayPalRESTException
*/
public Invoice create(APIContext apiContext) throws PayPalRESTException {
String resourcePath = "v1/invoicing/invoices";
String payLoad = this.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Invoice.class);
}
/**
* Searches for an invoice or invoices. Include a search object that specifies your search criteria in the request.
* @deprecated Please use {@link #search(APIContext, Search)} instead.
* @param accessToken
* Access Token used for the API call.
* @param search
* Search
* @return Invoices
* @throws PayPalRESTException
*/
public Invoices search(String accessToken, Search search) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return search(apiContext, search);
}
/**
* Searches for an invoice or invoices. Include a search object that specifies your search criteria in the request.
* @param apiContext
* {@link APIContext} used for the API call.
* @param search
* Search
* @return Invoices
* @throws PayPalRESTException
*/
public Invoices search(APIContext apiContext, Search search) throws PayPalRESTException {
if (search == null) {
throw new IllegalArgumentException("search cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/search";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = search.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Invoices.class);
}
/**
* Sends an invoice, by ID, to a recipient. Optionally, set the `notify_merchant` query parameter to send the merchant an invoice update notification. By default, `notify_merchant` is `true`.
* @deprecated Please use {@link #send(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @throws PayPalRESTException
*/
public void send(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
send(apiContext);
}
/**
* Sends an invoice, by ID, to a recipient. Optionally, set the `notify_merchant` query parameter to send the merchant an invoice update notification. By default, `notify_merchant` is `true`.
* @param apiContext
* {@link APIContext} used for the API call.
* @throws PayPalRESTException
*/
public void send(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/send";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null);
}
/**
* Sends a reminder about a specific invoice, by ID, to a recipient. Include a notification object that defines the reminder subject and other details in the JSON request body.
* @deprecated Please use {@link #remind(APIContext, Notification)} instead.
* @param accessToken
* Access Token used for the API call.
* @param notification
* Notification
* @throws PayPalRESTException
*/
public void remind(String accessToken, Notification notification) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
remind(apiContext, notification);
}
/**
* Sends a reminder about a specific invoice, by ID, to a recipient. Include a notification object that defines the reminder subject and other details in the JSON request body.
* @param apiContext
* {@link APIContext} used for the API call.
* @param notification
* Notification
* @throws PayPalRESTException
*/
public void remind(APIContext apiContext, Notification notification) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (notification == null) {
throw new IllegalArgumentException("notification cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/remind";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = notification.toJSON();
configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null);
}
/**
* Cancels an invoice, by ID.
* @deprecated Please use {@link #cancel(APIContext, CancelNotification)} instead.
* @param accessToken
* Access Token used for the API call.
* @param cancelNotification
* CancelNotification
* @throws PayPalRESTException
*/
public void cancel(String accessToken, CancelNotification cancelNotification) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
cancel(apiContext, cancelNotification);
}
/**
* Cancels an invoice, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @param cancelNotification
* CancelNotification
* @throws PayPalRESTException
*/
public void cancel(APIContext apiContext, CancelNotification cancelNotification) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (cancelNotification == null) {
throw new IllegalArgumentException("cancelNotification cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/cancel";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = cancelNotification.toJSON();
configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null);
}
/**
* Marks the status of a specified invoice, by ID, as paid. Include a payment detail object that defines the payment method and other details in the JSON request body.
* @deprecated Please use {@link #recordPayment(APIContext, PaymentDetail)} instead.
* @param accessToken
* Access Token used for the API call.
* @param paymentDetail
* PaymentDetail
* @throws PayPalRESTException
*/
public void recordPayment(String accessToken, PaymentDetail paymentDetail) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
recordPayment(apiContext, paymentDetail);
}
/**
* Marks the status of a specified invoice, by ID, as paid. Include a payment detail object that defines the payment method and other details in the JSON request body.
* @param apiContext
* {@link APIContext} used for the API call.
* @param paymentDetail
* PaymentDetail
* @throws PayPalRESTException
*/
public void recordPayment(APIContext apiContext, PaymentDetail paymentDetail) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (paymentDetail == null) {
throw new IllegalArgumentException("paymentDetail cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/record-payment";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = paymentDetail.toJSON();
configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null);
}
/**
* Marks the status of a specified invoice, by ID, as refunded. Include a refund detail object that defines the refund type and other details in the JSON request body.
* @deprecated Please use {@link #recordRefund(APIContext, RefundDetail)} instead.
* @param accessToken
* Access Token used for the API call.
* @param refundDetail
* RefundDetail
* @throws PayPalRESTException
*/
public void recordRefund(String accessToken, RefundDetail refundDetail) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
recordRefund(apiContext, refundDetail);
}
/**
* Marks the status of a specified invoice, by ID, as refunded. Include a refund detail object that defines the refund type and other details in the JSON request body.
* @param apiContext
* {@link APIContext} used for the API call.
* @param refundDetail
* RefundDetail
* @throws PayPalRESTException
*/
public void recordRefund(APIContext apiContext, RefundDetail refundDetail) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (refundDetail == null) {
throw new IllegalArgumentException("refundDetail cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/record-refund";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = refundDetail.toJSON();
configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, null);
}
/**
* Gets the details for a specified invoice, by ID.
* @deprecated Please use {@link #get(APIContext, String)} instead.
* @param accessToken
* Access Token used for the API call.
* @param invoiceId
* String
* @return Invoice
* @throws PayPalRESTException
*/
public static Invoice get(String accessToken, String invoiceId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, invoiceId);
}
/**
* Gets the details for a specified invoice, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @param invoiceId
* String
* @return Invoice
* @throws PayPalRESTException
*/
public static Invoice get(APIContext apiContext, String invoiceId) throws PayPalRESTException {
if (invoiceId == null) {
throw new IllegalArgumentException("invoiceId cannot be null");
}
Object[] parameters = new Object[] {invoiceId};
String pattern = "v1/invoicing/invoices/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Invoice.class);
}
/**
* Lists some or all merchant invoices. Filters the response by any specified optional query string parameters.
* @deprecated Please use {@link #getAll(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return Invoices
* @throws PayPalRESTException
*/
public static Invoices getAll(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return getAll(apiContext, null);
}
/**
* Lists some or all merchant invoices. Filters the response by any specified optional query string parameters.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Invoices
* @throws PayPalRESTException
*/
public static Invoices getAll(APIContext apiContext) throws PayPalRESTException {
return getAll(apiContext, null);
}
/**
* Lists some or all merchant invoices. Filters the response by any specified optional query string parameters.
* @param apiContext
* {@link APIContext} used for the API call.
* @param options
* {@link Map} of query parameters. Allowed options: page, page_size, total_count_required.
* @return Invoices
* @throws PayPalRESTException
*/
public static Invoices getAll(APIContext apiContext, Map<String, String> options) throws PayPalRESTException {
String pattern = "v1/invoicing/invoices";
String resourcePath = RESTUtil.formatURIPath(pattern, null, options);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Invoices.class);
}
/**
* Fully updates an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported.
* @deprecated Please use {@link #update(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return Invoice
* @throws PayPalRESTException
*/
public Invoice update(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return update(apiContext);
}
/**
* Fully updates an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Invoice
* @throws PayPalRESTException
*/
public Invoice update(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = this.toJSON();
return configureAndExecute(apiContext, HttpMethod.PUT, resourcePath, payLoad, Invoice.class);
}
/**
* Delete a particular invoice by passing the invoice ID to the request URI.
* @deprecated Please use {@link #delete(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @throws PayPalRESTException
*/
public void delete(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
delete(apiContext);
}
/**
* Delete a particular invoice by passing the invoice ID to the request URI.
* @param apiContext
* {@link APIContext} used for the API call.
* @throws PayPalRESTException
*/
public void delete(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
apiContext.setRequestId(null);
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null);
apiContext.setRequestId(null);
}
/**
* Delete external payment.
* @param apiContext
* {@link APIContext} used for the API call.
* @return
* @throws PayPalRESTException
*/
public void deleteExternalPayment(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
apiContext.setMaskRequestId(true);
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/payment-records/{1}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null);
}
/**
* Delete external refund.
* @param apiContext
* {@link APIContext} used for the API call.
* @return
* @throws PayPalRESTException
*/
public void deleteExternalRefund(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
apiContext.setMaskRequestId(true);
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/{0}/refund-records/{1}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null);
}
/**
* Generates a QR code for an invoice, by ID. The request generates a QR code that is 500 pixels in width and height. To change the dimensions of the returned code, specify optional query parameters.
* @deprecated Please use {@link #qrCode(APIContext, String, Map)} instead.
* @param apiContext
* {@link APIContext} used for the API call.
* @param invoiceId
* String
* @return object
* @throws PayPalRESTException
*/
public static Image qrCode(APIContext apiContext, String invoiceId) throws PayPalRESTException {
return qrCode(apiContext, invoiceId, null);
}
/**
* Generates a QR code for an invoice, by ID. The request generates a QR code that is 500 pixels in width and height. To change the dimensions of the returned code, specify optional query parameters.
* @param apiContext
* {@link APIContext} used for the API call.
* @param invoiceId
* String
* @param options
* {@link Map} of options. Valid values are: width, height, action.
* @return object
* @throws PayPalRESTException
*/
public static Image qrCode(APIContext apiContext, String invoiceId, Map<String, String> options) throws PayPalRESTException {
if (invoiceId == null) {
throw new IllegalArgumentException("invoiceId cannot be null");
}
String pattern = "v1/invoicing/invoices/{0}/qr-code";
String resourcePath = RESTUtil.formatURIPath(pattern, options, invoiceId);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Image.class);
}
/**
* Generates the next invoice number.
* @param apiContext
* {@link APIContext} used for the API call.
* @return object
* @throws PayPalRESTException
*/
public InvoiceNumber generateNumber(APIContext apiContext) throws PayPalRESTException {
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/invoicing/invoices/next-invoice-number";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, InvoiceNumber.class);
}
/**
* Fetches long lived refresh token from authorization code, for third party merchant invoicing use.
*
* @param context context
* @param authorizationCode authorization code
* @return {@link String} Refresh Token
* @throws PayPalRESTException
*/
public static String fetchRefreshToken(APIContext context, String authorizationCode) throws PayPalRESTException {
return Tokeninfo.createFromAuthorizationCode(context, authorizationCode).getRefreshToken();
}
}
| 3,766 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Card3dSecureInfo.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Card3dSecureInfo extends PayPalModel {
/**
* Authorization status from 3ds provider. Should be echoed back in the response
*/
private String authStatus;
/**
* Numeric flag to indicate how the payment should be processed in relationship to 3d-secure. If 0 then ignore all 3d values and process as non-3ds
*/
private String eci;
/**
* Cardholder Authentication Verification Value (used by VISA).
*/
private String cavv;
/**
* Transaction identifier from authenticator.
*/
private String xid;
/**
* Name of the actual 3ds vendor who processed the 3ds request, e.g. Cardinal
*/
private String mpiVendor;
/**
* Default Constructor
*/
public Card3dSecureInfo() {
}
}
| 3,767 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Transactions.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Transactions extends PayPalModel {
/**
* Amount being collected.
*/
private Amount amount;
/**
* Default Constructor
*/
public Transactions() {
}
}
| 3,768 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayoutBatch.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PayoutBatch extends PayPalModel {
/**
* A batch header. Includes the generated batch status.
*/
private PayoutBatchHeader batchHeader;
/**
* An array of items in a batch payout.
*/
private List<PayoutItemDetails> items;
/**
*
*/
private List<Links> links;
/**
* Default Constructor
*/
public PayoutBatch() {
}
/**
* Parameterized Constructor
*/
public PayoutBatch(PayoutBatchHeader batchHeader, List<PayoutItemDetails> items) {
this.batchHeader = batchHeader;
this.items = items;
}
}
| 3,769 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoicingNotification.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InvoicingNotification extends PayPalModel {
/**
* Subject of the notification.
*/
private String subject;
/**
* Note to the payer.
*/
private String note;
/**
* A flag indicating whether a copy of the email has to be sent to the merchant.
*/
private Boolean sendToMerchant;
/**
* Default Constructor
*/
public InvoicingNotification() {
}
}
| 3,770 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentCard.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PaymentCard extends PayPalModel {
/**
* The ID of a credit card to save for later use.
*/
private String id;
/**
* The card number.
*/
private String number;
/**
* The card type.
*/
private String type;
/**
* The two-digit expiry month for the card.
*/
private String expireMonth;
/**
* The four-digit expiry year for the card.
*/
private String expireYear;
/**
* The two-digit start month for the card. Required for UK Maestro cards.
*/
private String startMonth;
/**
* The four-digit start year for the card. Required for UK Maestro cards.
*/
private String startYear;
/**
* The validation code for the card. Supported for payments but not for saving payment cards for future use.
*/
private String cvv2;
/**
* The first name of the card holder.
*/
private String firstName;
/**
* The last name of the card holder.
*/
private String lastName;
/**
* The two-letter country code.
*/
private CountryCode billingCountry;
/**
* The billing address for the card.
*/
private Address billingAddress;
/**
* The ID of the customer who owns this card account. The facilitator generates and provides this ID. Required when you create or use a stored funding instrument in the PayPal vault.
*/
private String externalCustomerId;
/**
* The state of the funding instrument.
*/
private String status;
/**
* The product class of the financial instrument issuer.
*/
private String cardProductClass;
/**
* The date and time until when this instrument can be used fund a payment.
*/
private String validUntil;
/**
* The one- to two-digit card issue number. Required for UK Maestro cards.
*/
private String issueNumber;
/**
* Fields required to support 3d secure information when processing credit card payments. Only supported when the `payment_method` is set to `credit_card`.
*/
private Card3dSecureInfo card3dSecureInfo;
/**
*
*/
private List<DefinitionsLinkdescription> links;
/**
* Default Constructor
*/
public PaymentCard() {
}
/**
* @deprecated Please use {@link #setCard3dSecureInfo(Card3dSecureInfo)} instead.
*
* Setter for 3dSecureInfo
*/
@Deprecated
public PaymentCard set3dSecureInfo(Card3dSecureInfo card3dSecureInfo) {
this.card3dSecureInfo = card3dSecureInfo;
return this;
}
/**
* @deprecated Please use {@link #getCard3dSecureInfo()} instead.
*
* Getter for 3dSecureInfo
*/
public Card3dSecureInfo get3dSecureInfo() {
return this.card3dSecureInfo;
}
}
| 3,771 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/NameValuePair.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class NameValuePair extends PayPalModel {
/**
* Key for the name value pair. The value name types should be correlated
*/
private String name;
/**
* Value for the name value pair.
*/
private String value;
/**
* Default Constructor
*/
public NameValuePair() {
}
/**
* Parameterized Constructor
*/
public NameValuePair(String name, String value) {
this.name = name;
this.value = value;
}
}
| 3,772 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Billing.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Billing extends PayPalModel {
/**
* Identifier of the instrument in PayPal Wallet
*/
private String billingAgreementId;
/**
* Selected installment option for issuer based installments (BR and MX).
*/
private InstallmentOption selectedInstallmentOption;
/**
* Default Constructor
*/
public Billing() {
}
}
| 3,773 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoicingMetaData.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InvoicingMetaData extends PayPalModel {
/**
* Date when the resource was created.
*/
private String createdDate;
/**
* Email address of the account that created the resource.
*/
private String createdBy;
/**
* Date when the resource was cancelled.
*/
private String cancelledDate;
/**
* Actor who cancelled the resource.
*/
private String cancelledBy;
/**
* Date when the resource was last edited.
*/
private String lastUpdatedDate;
/**
* Email address of the account that last edited the resource.
*/
private String lastUpdatedBy;
/**
* Date when the resource was first sent.
*/
private String firstSentDate;
/**
* Date when the resource was last sent.
*/
private String lastSentDate;
/**
* Email address of the account that last sent the resource.
*/
private String lastSentBy;
/**
* Default Constructor
*/
public InvoicingMetaData() {
}
}
| 3,774 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Payment.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Payment extends PayPalResource {
/**
* Identifier of the payment resource created.
*/
private String id;
/**
* Payment intent.
*/
private String intent;
/**
* Source of the funds for this payment represented by a PayPal account or a direct credit card.
*/
private Payer payer;
/**
* Information that the merchant knows about the payer. This information is not definitive and only serves as a hint to the UI or any pre-processing logic.
*/
private PotentialPayerInfo potentialPayerInfo;
/**
* Receiver of funds for this payment. **Readonly for PayPal external REST payments.**
*/
private Payee payee;
/**
* ID of the cart to execute the payment.
*/
private String cart;
/**
* Transactional details including the amount and item details.
*/
private List<Transaction> transactions;
/**
* Applicable for advanced payments like multi seller payment (MSP) to support partial failures
*/
private List<Error> failedTransactions;
/**
* Collection of PayPal generated billing agreement tokens.
*/
private List<BillingAgreementToken> billingAgreementTokens;
/**
* Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in
*/
private CreditFinancingOffered creditFinancingOffered;
/**
* Instructions for the payer to complete this payment. Applies to the German market and partners only.
*/
private PaymentInstruction paymentInstruction;
/**
* The state of the payment, authorization, or order transaction. The value is:<ul><li><code>created</code>. The transaction was successfully created.</li><li><code>approved</code>. The buyer approved the transaction.</li><li><code>failed</code>. The transaction request failed.</li></ul>
*/
private String state;
/**
* PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/docs/api/#payment-experience) link to create experience profile ID.
*/
private String experienceProfileId;
/**
* free-form field for the use of clients to pass in a message to the payer
*/
private String noteToPayer;
/**
* Set of redirect URLs you provide only for PayPal-based payments.
*/
private RedirectUrls redirectUrls;
/**
* Failure reason code returned when the payment failed for some valid reasons.
*/
private String failureReason;
/**
* Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
*/
private String createTime;
/**
* Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
*/
private String updateTime;
/**
*
*/
private List<Links> links;
/**
* Default Constructor
*/
public Payment() {
}
/**
* Parameterized Constructor
*/
public Payment(String intent, Payer payer) {
this.intent = intent;
this.payer = payer;
}
/**
* Creates and processes a payment. In the JSON request body, include a `payment` object with the intent, payer, and transactions. For PayPal payments, include redirect URLs in the `payment` object.
* @deprecated Please use {@link #create(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return Payment
* @throws PayPalRESTException
*/
public Payment create(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return create(apiContext);
}
/**
* Creates and processes a payment. In the JSON request body, include a `payment` object with the intent, payer, and transactions. For PayPal payments, include redirect URLs in the `payment` object.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Payment
* @throws PayPalRESTException
*/
public Payment create(APIContext apiContext) throws PayPalRESTException {
String resourcePath = "v1/payments/payment";
String payLoad = this.toJSON();
Payment payment = configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Payment.class);
apiContext.setRequestId(null);
return payment;
}
/**
* Shows details for a payment, by ID.
* @deprecated Please use {@link #get(APIContext, String)} instead.
* @param accessToken
* Access Token used for the API call.
* @param paymentId
* String
* @return Payment
* @throws PayPalRESTException
*/
public static Payment get(String accessToken, String paymentId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, paymentId);
}
/**
* Shows details for a payment, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @param paymentId
* String
* @return Payment
* @throws PayPalRESTException
*/
public static Payment get(APIContext apiContext, String paymentId) throws PayPalRESTException {
if (paymentId == null) {
throw new IllegalArgumentException("paymentId cannot be null");
}
Object[] parameters = new Object[] {paymentId};
String pattern = "v1/payments/payment/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Payment.class);
}
/**
* Executes the payment (after approved by the Payer) associated with this resource when the payment method is PayPal.
* @deprecated Please use {@link #execute(APIContext, PaymentExecution)} instead.
* @param accessToken
* Access Token used for the API call.
* @param paymentExecution
* PaymentExecution
* @return Payment
* @throws PayPalRESTException
*/
public Payment execute(String accessToken, PaymentExecution paymentExecution) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return execute(apiContext, paymentExecution);
}
/**
* Executes, or completes, a PayPal payment that the payer has approved. You can optionally update selective payment information when you execute a payment.
* @param apiContext
* {@link APIContext} used for the API call.
* @param paymentExecution
* PaymentExecution
* @return Payment
* @throws PayPalRESTException
*/
public Payment execute(APIContext apiContext, PaymentExecution paymentExecution) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (paymentExecution == null) {
throw new IllegalArgumentException("paymentExecution cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payments/payment/{0}/execute";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = paymentExecution.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, Payment.class);
}
/**
* Partially update a payment resource by by passing the payment_id in the request URI. In addition, pass a patch_request_object in the body of the request JSON that specifies the operation to perform, path of the target location, and new value to apply. Please note that it is not possible to use patch after execute has been called.
* @deprecated Please use {@link #update(APIContext, List)} instad.
*
* @param accessToken
* Access Token used for the API call.
* @param patchRequest
* List<Patch>
* @throws PayPalRESTException
*/
public void update(String accessToken, List<Patch> patchRequest) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
update(apiContext, patchRequest);
}
/**
* Partially update a payment resource by by passing the payment_id in the request URI. In addition, pass a patch_request_object in the body of the request JSON that specifies the operation to perform, path of the target location, and new value to apply. Please note that it is not possible to use patch after execute has been called.
* @param apiContext
* {@link APIContext} used for the API call.
* @param patchRequest
* List<Patch>
* @throws PayPalRESTException
*/
public void update(APIContext apiContext, List<Patch> patchRequest) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (patchRequest == null) {
throw new IllegalArgumentException("patchRequest cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payments/payment/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = JSONFormatter.toJSON(patchRequest);
PayPalResource.configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, null);
}
/**
* List payments that were made to the merchant who issues the request. Payments can be in any state.
* @deprecated Please use {@link #list(APIContext, Map)} instead.
*
* @param accessToken
* Access Token used for the API call.
* @param containerMap
* Map<String, String>
* @return PaymentHistory
* @throws PayPalRESTException
*/
public static PaymentHistory list(String accessToken, Map<String, String> containerMap) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return list(apiContext, containerMap);
}
/**
* List payments that were made to the merchant who issues the request. Payments can be in any state.
* @param apiContext
* {@link APIContext} used for the API call.
* @param containerMap
* Map<String, String>
* @return PaymentHistory
* @throws PayPalRESTException
*/
public static PaymentHistory list(APIContext apiContext, Map<String, String> containerMap) throws PayPalRESTException {
if (containerMap == null) {
throw new IllegalArgumentException("containerMap cannot be null");
}
Object[] parameters = new Object[] {containerMap};
String pattern = "v1/payments/payment?count={0}&start_id={1}&start_index={2}&start_time={3}&end_time={4}&payee_id={5}&sort_by={6}&sort_order={7}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
PaymentHistory paymentHistory = configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, PaymentHistory.class);
apiContext.setRequestId(null);
return paymentHistory;
}
}
| 3,775 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/FundingOption.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class FundingOption extends PayPalModel {
/**
* id of the funding option.
*/
private String id;
/**
* List of funding sources that contributes to a payment.
*/
private List<FundingSource> fundingSources;
/**
* Backup funding instrument which will be used for payment if primary fails.
*/
private FundingInstrument backupFundingInstrument;
/**
* Currency conversion applicable to this funding option.
*/
private CurrencyConversion currencyConversion;
/**
* Installment options available for a funding option.
*/
private InstallmentInfo installmentInfo;
/**
*
*/
private List<DefinitionsLinkdescription> links;
/**
* Default Constructor
*/
public FundingOption() {
}
/**
* Parameterized Constructor
*/
public FundingOption(String id, List<FundingSource> fundingSources) {
this.id = id;
this.fundingSources = fundingSources;
}
}
| 3,776 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/WebProfile.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class WebProfile extends PayPalResource {
/**
* The unique ID of the web experience profile.
*/
private String id;
/**
* The web experience profile name. Unique for a specified merchant's profiles.
*/
private String name;
/**
* Indicates whether the profile persists for three hours or permanently. Set to `false` to persist the profile permanently. Set to `true` to persist the profile for three hours.
*/
private Boolean temporary;
/**
* Parameters for flow configuration.
*/
private FlowConfig flowConfig;
/**
* Parameters for input fields customization.
*/
private InputFields inputFields;
/**
* Parameters for style and presentation.
*/
private Presentation presentation;
/**
* Default Constructor
*/
public WebProfile() {
}
/**
* Parameterized Constructor
*/
public WebProfile(String name) {
this.name = name;
}
/**
* Creates a web experience profile. Pass the profile name and details in the JSON request body.
* @deprecated Please use {@link #create(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return CreateProfileResponse
* @throws PayPalRESTException
*/
public CreateProfileResponse create(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return create(apiContext);
}
/**
* Creates a web experience profile. Pass the profile name and details in the JSON request body.
* @param apiContext
* {@link APIContext} used for the API call.
* @return CreateProfileResponse
* @throws PayPalRESTException
*/
public CreateProfileResponse create(APIContext apiContext) throws PayPalRESTException {
String resourcePath = "v1/payment-experience/web-profiles";
String payLoad = this.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, CreateProfileResponse.class);
}
/**
* Updates a web experience profile. Pass the ID of the profile to the request URI and pass the profile details in the JSON request body. If your request omits any profile detail fields, the operation removes the previously set values for those fields.
* @deprecated Please use {@link #update(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return
* @throws PayPalRESTException
*/
public void update(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
update(apiContext);
}
/**
* Updates a web experience profile. Pass the ID of the profile to the request URI and pass the profile details in the JSON request body. If your request omits any profile detail fields, the operation removes the previously set values for those fields.
* @param apiContext
* {@link APIContext} used for the API call.
* @return
* @throws PayPalRESTException
*/
public void update(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payment-experience/web-profiles/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = this.toJSON();
configureAndExecute(apiContext, HttpMethod.PUT, resourcePath, payLoad, null);
return;
}
/**
* Partially-updates a web experience profile. Pass the profile ID to the request URI. Pass a patch object with the operation, path of the profile location to update, and, if needed, a new value to complete the operation in the JSON request body.
* @deprecated Please use {@link #partialUpdate(APIContext, PatchRequest)} instead.
*
* @param accessToken
* Access Token used for the API call.
* @param patchRequest
* PatchRequest
* @return
* @throws PayPalRESTException
*/
public void partialUpdate(String accessToken, PatchRequest patchRequest) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
partialUpdate(apiContext, patchRequest);
}
/**
* Partially-updates a web experience profile. Pass the profile ID to the request URI. Pass a patch object with the operation, path of the profile location to update, and, if needed, a new value to complete the operation in the JSON request body.
* @param apiContext
* {@link APIContext} used for the API call.
* @param patchRequest
* PatchRequest
* @return
* @throws PayPalRESTException
*/
public void partialUpdate(APIContext apiContext, PatchRequest patchRequest) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
if (patchRequest == null) {
throw new IllegalArgumentException("patchRequest cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payment-experience/web-profiles/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = patchRequest.toJSON();
configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, null);
return;
}
/**
* Shows details for a web experience profile, by ID.
* @deprecated Please use {@link #get(APIContext, String)} instead.
* @param accessToken
* Access Token used for the API call.
* @param profileId
* String
* @return WebProfile
* @throws PayPalRESTException
*/
public static WebProfile get(String accessToken, String profileId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, profileId);
}
/**
* Shows details for a web experience profile, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @param profileId
* String
* @return WebProfile
* @throws PayPalRESTException
*/
public static WebProfile get(APIContext apiContext, String profileId) throws PayPalRESTException {
if (profileId == null) {
throw new IllegalArgumentException("profileId cannot be null");
}
Object[] parameters = new Object[] {profileId};
String pattern = "v1/payment-experience/web-profiles/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, WebProfile.class);
}
/**
* Lists all web experience profiles for a merchant or subject.
* @deprecated Please use {@link #getList(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return WebProfileList
* @throws PayPalRESTException
*/
public static List<WebProfile> getList(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return getList(apiContext);
}
/**
* Lists all web experience profiles for a merchant or subject.
* @param apiContext
* {@link APIContext} used for the API call.
* @return WebProfileList
* @throws PayPalRESTException
*/
public static List<WebProfile> getList(APIContext apiContext) throws PayPalRESTException {
String resourcePath = "v1/payment-experience/web-profiles";
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, WebProfileList.class);
}
/**
* Deletes a web experience profile, by ID.
* @deprecated Please use {@link #delete(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return
* @throws PayPalRESTException
*/
public void delete(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
delete(apiContext);
}
/**
* Deletes a web experience profile, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @return
* @throws PayPalRESTException
*/
public void delete(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/payment-experience/web-profiles/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null);
}
}
| 3,777 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayoutItem.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PayoutItem extends PayPalResource {
/**
* The type of ID that identifies the payment receiver. Value is:<ul><code>EMAIL</code>. Unencrypted email. Value is a string of up to 127 single-byte characters.</li><li><code>PHONE</code>. Unencrypted phone number.<blockquote><strong>Note:</strong> The PayPal sandbox does not support the <code>PHONE</code> recipient type.</blockquote></li><li><code>PAYPAL_ID</code>. Encrypted PayPal account number.</li></ul>If the <code>sender_batch_header</code> includes the <code>recipient_type</code> attribute, any payout item without its own <code>recipient_type</code> attribute uses the <code>recipient_type</code> value from <code>sender_batch_header</code>. If the <code>sender_batch_header</code> omits the <code>recipient_type</code> attribute, each payout item must include its own <code>recipient_type</code> value.
*/
private String recipientType;
/**
* The amount of money to pay the receiver.
*/
private Currency amount;
/**
* Optional. A sender-specified note for notifications. Value is any string value.
*/
private String note;
/**
* The receiver of the payment. Corresponds to the `recipient_type` value in the request.
*/
private String receiver;
/**
* A sender-specified ID number. Tracks the batch payout in an accounting system.
*/
private String senderItemId;
/**
* Default Constructor
*/
public PayoutItem() {
}
/**
* Parameterized Constructor
*/
public PayoutItem(Currency amount, String receiver) {
this.amount = amount;
this.receiver = receiver;
}
/**
* Obtain the status of a payout item by passing the item ID to the request
* URI.
* @deprecated Please use {@link #get(APIContext, String)} instead.
*
* @param accessToken
* Access Token used for the API call.
* @param payoutItemId
* String
* @return PayoutItemDetails
* @throws PayPalRESTException
*/
public static PayoutItemDetails get(String accessToken, String payoutItemId)
throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, payoutItemId);
}
/**
* Obtain the status of a payout item by passing the item ID to the request
* URI.
*
* @param apiContext
* {@link APIContext} used for the API call.
* @param payoutItemId
* String
* @return PayoutItemDetails
* @throws PayPalRESTException
*/
public static PayoutItemDetails get(APIContext apiContext,
String payoutItemId) throws PayPalRESTException {
if (payoutItemId == null) {
throw new IllegalArgumentException("payoutItemId cannot be null");
}
Object[] parameters = new Object[] { payoutItemId };
String pattern = "v1/payments/payouts-item/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET,
resourcePath, payLoad, PayoutItemDetails.class);
}
/**
* Cancels the unclaimed payment using the items id passed in the request
* URI. If an unclaimed item is not claimed within 30 days, the funds will
* be automatically returned to the sender. This call can be used to cancel
* the unclaimed item prior to the automatic 30-day return.
* @deprecated Please use {@link #cancel(APIContext, String)} instead.
*
* @param accessToken
* Access Token used for the API call.
* @param payoutItemId
* String
* @return PayoutItemDetails
* @throws PayPalRESTException
*/
public static PayoutItemDetails cancel(String accessToken,
String payoutItemId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return cancel(apiContext, payoutItemId);
}
/**
* Cancels the unclaimed payment using the items id passed in the request
* URI. If an unclaimed item is not claimed within 30 days, the funds will
* be automatically returned to the sender. This call can be used to cancel
* the unclaimed item prior to the automatic 30-day return.
*
* @param apiContext
* {@link APIContext} used for the API call.
* @param payoutItemId
* String
* @return PayoutItemDetails
* @throws PayPalRESTException
*/
public static PayoutItemDetails cancel(APIContext apiContext,
String payoutItemId) throws PayPalRESTException {
if (payoutItemId == null) {
throw new IllegalArgumentException("payoutItemId cannot be null");
}
Object[] parameters = new Object[] { payoutItemId };
String pattern = "v1/payments/payouts-item/{0}/cancel";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.POST,
resourcePath, payLoad, PayoutItemDetails.class);
}
}
| 3,778 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Notification.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Notification extends PayPalModel {
/**
* Subject of the notification.
*/
private String subject;
/**
* Note to the payer.
*/
private String note;
/**
* Indicates whether to send a copy of the email to the merchant.
*/
private Boolean sendToMerchant;
/**
* Applicable for invoices created with Cc emails. If this field is not in the body, all the cc email addresses added as part of the invoice shall be notified else this field can be used to limit the list of email addresses. Note: additional email addresses are not supported.
*/
private List<String> ccEmails;
/**
* Default Constructor
*/
public Notification() {
}
}
| 3,779 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentInstruction.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalResource;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PaymentInstruction extends PayPalResource {
/**
* ID of payment instruction
*/
private String referenceNumber;
/**
* Type of payment instruction
*/
private String instructionType;
/**
* Recipient bank Details.
*/
private RecipientBankingInstruction recipientBankingInstruction;
/**
* Amount to be transferred
*/
private Currency amount;
/**
* Date by which payment should be received
*/
private String paymentDueDate;
/**
* Additional text regarding payment handling
*/
private String note;
/**
*
*/
private List<Links> links;
/**
* Parameterized Constructor
*/
public PaymentInstruction(String referenceNumber, String instructionType, RecipientBankingInstruction recipientBankingInstruction, Currency amount) {
this.referenceNumber = referenceNumber;
this.instructionType = instructionType;
this.recipientBankingInstruction = recipientBankingInstruction;
this.amount = amount;
}
}
| 3,780 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CreditCard.java
|
package com.paypal.api.payments;
import com.google.gson.GsonBuilder;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CreditCard extends PayPalResource {
/**
* ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.**
*/
private String id;
/**
* Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.*
*/
private String number;
/**
* Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`
*/
private String type;
/**
* Expiration month with no leading zero. Acceptable values are 1 through 12.
*/
private int expireMonth;
/**
* 4-digit expiration year.
*/
private int expireYear;
/**
* 3-4 digit card validation code.
*/
private String cvv2;
/**
* Cardholder's first name.
*/
private String firstName;
/**
* Cardholder's last name.
*/
private String lastName;
/**
* Billing Address associated with this card.
*/
private Address billingAddress;
/**
* A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.**
*/
private String externalCustomerId;
/**
* State of the credit card funding instrument.
*/
private String state;
/**
* Funding instrument expiration date.
*/
private String validUntil;
/**
*
*/
private List<Links> links;
/**
* Payer ID
*/
private String payerId;
/**
* Default Constructor
*/
public CreditCard() {
}
/**
* @deprecated Please use {@link #getCvv2String()} instead.
* Getter for cvv2
* Returns -1 if <code>cvv2</code> is null.
* Not autogenerating using lombok as it includes logic to return -1 on null.
*/
public int getCvv2() {
if (this.cvv2 == null) {
return -1;
} else {
return Integer.valueOf(this.cvv2);
}
}
/**
* @deprecated The cvv2 needs to be a string, as any cvv2 starting with 0 is sent invalid to servers. Please use {@link #setCvv2(String)} instead.
* @param cvv2 Integer cvv2
* @return CreditCard
*/
public CreditCard setCvv2(Integer cvv2) {
this.cvv2 = cvv2.toString();
return this;
}
/**
* @param cvv2 String cvv2
* @return CreditCard
*/
public CreditCard setCvv2(String cvv2) {
this.cvv2 = cvv2;
return this;
}
/**
* Returns the cvv2
* @return String representation of cvv2
*/
public String getCvv2String() {
return this.cvv2;
}
/**
* Parameterized Constructor
*/
public CreditCard(String number, String type, int expireMonth, int expireYear) {
this.number = number;
this.type = type;
this.expireMonth = expireMonth;
this.expireYear = expireYear;
}
/**
* Creates a new Credit Card Resource (aka Tokenize).
* @deprecated Please use {@link #create(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @return CreditCard
* @throws PayPalRESTException
*/
public CreditCard create(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return create(apiContext);
}
/**
* Creates a new Credit Card Resource (aka Tokenize).
* @param apiContext
* {@link APIContext} used for the API call.
* @return CreditCard
* @throws PayPalRESTException
*/
public CreditCard create(APIContext apiContext) throws PayPalRESTException {
String resourcePath = "v1/vault/credit-cards";
String payLoad = this.toJSON();
return configureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad, CreditCard.class);
}
/**
* Obtain the Credit Card resource for the given identifier.
* @deprecated Please use {@link #get(APIContext, String)} instead.
* @param accessToken
* Access Token used for the API call.
* @param creditCardId
* String
* @return CreditCard
* @throws PayPalRESTException
*/
public static CreditCard get(String accessToken, String creditCardId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, creditCardId);
}
/**
* Obtain the Credit Card resource for the given identifier.
* @param apiContext
* {@link APIContext} used for the API call.
* @param creditCardId
* String
* @return CreditCard
* @throws PayPalRESTException
*/
public static CreditCard get(APIContext apiContext, String creditCardId) throws PayPalRESTException {
if (creditCardId == null) {
throw new IllegalArgumentException("creditCardId cannot be null");
}
Object[] parameters = new Object[] {creditCardId};
String pattern = "v1/vault/credit-cards/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, CreditCard.class);
}
/**
* Delete the Credit Card resource for the given identifier.
* @deprecated Please use {@link #delete(APIContext)} instead.
* @param accessToken
* Access Token used for the API call.
* @throws PayPalRESTException
*/
public void delete(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
delete(apiContext);
return;
}
/**
* Delete the Credit Card resource for the given identifier.
* @param apiContext
* {@link APIContext} used for the API call.
* @throws PayPalRESTException
*/
public void delete(APIContext apiContext) throws PayPalRESTException {
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
apiContext.setRequestId(null);
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/vault/credit-cards/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
configureAndExecute(apiContext, HttpMethod.DELETE, resourcePath, payLoad, null);
apiContext.setRequestId(null);
return;
}
/**
* Update information in a previously saved card. Only the modified fields need to be passed in the request.
* @deprecated Please use {@link #update(APIContext, List)} instead.
* @param accessToken
* Access Token used for the API call.
* @param patchRequest
* List<Patch>
* @return CreditCard
* @throws PayPalRESTException
*/
public CreditCard update(String accessToken, List<Patch> patchRequest) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return update(apiContext, patchRequest);
}
/**
* Update information in a previously saved card. Only the modified fields need to be passed in the request.
* @param apiContext
* {@link APIContext} used for the API call.
* @param patchRequest
* List<Patch>
* @return CreditCard
* @throws PayPalRESTException
*/
public CreditCard update(APIContext apiContext, List<Patch> patchRequest) throws PayPalRESTException {
if (patchRequest == null) {
throw new IllegalArgumentException("patchRequest cannot be null");
}
if (this.getId() == null) {
throw new IllegalArgumentException("Id cannot be null");
}
Object[] parameters = new Object[] {this.getId()};
String pattern = "v1/vault/credit-cards/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = new GsonBuilder().create().toJson(patchRequest);
return configureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, payLoad, CreditCard.class);
}
/**
* Retrieves a list of Credit Card resources.
* @deprecated Please use {@link #list(APIContext, Map)} instead.
* @param accessToken
* Access Token used for the API call.
* @param containerMap
* Map<String, String>. See https://developer.paypal.com/webapps/developer/docs/api/#list-credit-card-resources
* @return CreditCardHistory
* @throws PayPalRESTException
*/
public static CreditCardHistory list(String accessToken, Map<String, String> containerMap) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return list(apiContext, containerMap);
}
/**
* Retrieves a list of Credit Card resources.
* @param apiContext
* {@link APIContext} used for the API call.
* @param containerMap
* Map<String, String>. See https://developer.paypal.com/webapps/developer/docs/api/#list-credit-card-resources
* @return CreditCardHistory
* @throws PayPalRESTException
*/
public static CreditCardHistory list(APIContext apiContext, Map<String, String> containerMap) throws PayPalRESTException {
if (containerMap == null) {
throw new IllegalArgumentException("containerMap cannot be null");
}
apiContext.setRequestId(null);
Object[] parameters = new Object[] {containerMap};
String pattern = "v1/vault/credit-cards?merchant_id={0}&external_card_id={1}&external_customer_id={2}&start_time={3}&end_time={4}&page={5}&page_size={6}&sort_order={7}&sort_by={8}&total_required={9}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
CreditCardHistory creditCardHistory = configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, CreditCardHistory.class);
apiContext.setRequestId(null);
return creditCardHistory;
}
/**
* Retrieves a list of Credit Card resources.
* @param apiContext
* {@link APIContext} used for the API call.
* @return CreditCardHistory
* @throws PayPalRESTException
*/
public static CreditCardHistory list(APIContext apiContext) throws PayPalRESTException {
Map<String, String> containerMap = new HashMap<String, String>();
CreditCardHistory creditCardHistory = CreditCard.list(apiContext, containerMap);
return creditCardHistory;
}
/**
* Retrieves a list of Credit Card resources. containerMap (filters) are set to defaults.
* @deprecated Please use {@link #list(APIContext, Map)} instead.
* @param accessToken
* Access Token used for the API call.
* @return CreditCardHistory
* @throws PayPalRESTException
*/
public static CreditCardHistory list(String accessToken) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("merchant_id", "");
parameters.put("external_card_id", "");
parameters.put("external_customer_id", "");
parameters.put("start_time", "");
parameters.put("end_time", "");
parameters.put("page", "1");
parameters.put("page_size", "10");
parameters.put("sort_order", "asc");
parameters.put("sort_by", "create_time");
parameters.put("total_required", "true");
return list(apiContext, parameters);
}
}
| 3,781 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InvoiceAddress.java
|
package com.paypal.api.payments;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InvoiceAddress extends BaseAddress {
/**
* Phone number in E.123 format.
*/
private Phone phone;
/**
* Default Constructor
*/
public InvoiceAddress() {
}
}
| 3,782 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Amount.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Amount extends PayPalModel {
/**
* 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). PayPal does not support all currencies.
*/
private String currency;
/**
* Total amount charged from the payer to the payee. In case of a refund, this is the refunded amount to the original payer from the payee. 10 characters max with support for 2 decimal places.
*/
private String total;
/**
* Additional details of the payment amount.
*/
private Details details;
/**
* Default Constructor
*/
public Amount() {
}
/**
* Parameterized Constructor
*/
public Amount(String currency, String total) {
this.currency = currency;
this.total = total;
}
}
| 3,783 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Terms.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Terms extends PayPalModel {
/**
* Identifier of the terms. 128 characters max.
*/
private String id;
/**
* Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`.
*/
private String type;
/**
* Max Amount associated with this term.
*/
private Currency maxBillingAmount;
/**
* How many times money can be pulled during this term.
*/
private String occurrences;
/**
* Amount_range associated with this term.
*/
private Currency amountRange;
/**
* Buyer's ability to edit the amount in this term.
*/
private String buyerEditable;
/**
* Default Constructor
*/
public Terms() {
}
/**
* Parameterized Constructor
*/
public Terms(String type, Currency maxBillingAmount, String occurrences, Currency amountRange, String buyerEditable) {
this.type = type;
this.maxBillingAmount = maxBillingAmount;
this.occurrences = occurrences;
this.amountRange = amountRange;
this.buyerEditable = buyerEditable;
}
}
| 3,784 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Details.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Details extends PayPalModel {
/**
* Amount of the subtotal of the items. **Required** if line items are specified. 10 characters max, with support for 2 decimal places.
*/
private String subtotal;
/**
* Amount charged for shipping. 10 characters max with support for 2 decimal places.
*/
private String shipping;
/**
* Amount charged for tax. 10 characters max with support for 2 decimal places.
*/
private String tax;
/**
* Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`.
*/
private String handlingFee;
/**
* Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`.
*/
private String shippingDiscount;
/**
* Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`.
*/
private String insurance;
/**
* Amount being charged as gift wrap fee.
*/
private String giftWrap;
/**
* Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
*/
private String fee;
/**
* Default Constructor
*/
public Details() {
}
}
| 3,785 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Refund.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Refund extends PayPalResource {
/**
* ID of the refund transaction. 17 characters max.
*/
private String id;
/**
* Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max.
*/
private Amount amount;
/**
* State of the refund.
*/
private String state;
/**
* Reason description for the Sale transaction being refunded.
*/
private String reason;
/**
* Your own invoice or tracking ID number. Character length and limitations: 127 single-byte alphanumeric characters.
*/
private String invoiceNumber;
/**
* ID of the Sale transaction being refunded.
*/
private String saleId;
/**
* ID of the sale transaction being refunded.
*/
private String captureId;
/**
* ID of the payment resource on which this transaction is based.
*/
private String parentPayment;
/**
* Description of what is being refunded for.
*/
private String description;
/**
* Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
*/
private String createTime;
/**
* Time that the resource was last updated.
*/
private String updateTime;
/**
* The reason code for the refund state being pending
*/
private String reasonCode;
/**
*
*/
private List<Links> links;
/**
* Default Constructor
*/
public Refund() {
}
/**
* Shows details for a refund, by ID.
* @deprecated Please use {@link #get(APIContext, String)} instead.
* @param accessToken
* Access Token used for the API call.
* @param refundId
* String
* @return Refund
* @throws PayPalRESTException
*/
public static Refund get(String accessToken, String refundId) throws PayPalRESTException {
APIContext apiContext = new APIContext(accessToken);
return get(apiContext, refundId);
}
/**
* Shows details for a refund, by ID.
* @param apiContext
* {@link APIContext} used for the API call.
* @param refundId
* String
* @return Refund
* @throws PayPalRESTException
*/
public static Refund get(APIContext apiContext, String refundId) throws PayPalRESTException {
if (refundId == null) {
throw new IllegalArgumentException("refundId cannot be null");
}
Object[] parameters = new Object[] {refundId};
String pattern = "v1/payments/refund/{0}";
String resourcePath = RESTUtil.formatURIPath(pattern, parameters);
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Refund.class);
}
}
| 3,786 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/BaseAddress.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BaseAddress extends PayPalModel {
/**
* Line 1 of the Address (eg. number, street, etc).
*/
private String line1;
/**
* Optional line 2 of the Address (eg. suite, apt #, etc.).
*/
private String line2;
/**
* City name.
*/
private String city;
/**
* 2 letter country code.
*/
private String countryCode;
/**
* Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
*/
private String postalCode;
/**
* 2 letter code for US states, and the equivalent for other countries.
*/
private String state;
/**
* BaseAddress normalization status, returned only for payers from Brazil.
*/
private String normalizationStatus;
/**
* BaseAddress status
*/
private String status;
/**
* Default Constructor
*/
public BaseAddress() {
}
/**
* Parameterized Constructor
*/
public BaseAddress(String line1, String countryCode) {
this.line1 = line1;
this.countryCode = countryCode;
}
}
| 3,787 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/ChargeModels.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ChargeModels extends PayPalModel {
/**
* Identifier of the charge model. 128 characters max.
*/
private String id;
/**
* Type of charge model. Allowed values: `SHIPPING`, `TAX`.
*/
private String type;
/**
* Specific amount for this charge model.
*/
private Currency amount;
/**
* Default Constructor
*/
public ChargeModels() {
}
/**
* Parameterized Constructor
*/
public ChargeModels(String type, Currency amount) {
this.type = type;
this.amount = amount;
}
}
| 3,788 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Presentation.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Presentation extends PayPalModel {
/**
* A label that overrides the business name in the PayPal account on the PayPal pages. Character length and limitations: 127 single-byte alphanumeric characters.
*/
private String brandName;
/**
* A URL to the logo image. A valid media type is `.gif`, `.jpg`, or `.png`. The maximum width of the image is 190 pixels. The maximum height of the image is 60 pixels. PayPal crops images that are larger. PayPal places your logo image at the top of the cart review area. PayPal recommends that you store the image on a secure (HTTPS) server. Otherwise, web browsers display a message that checkout pages contain non-secure items. Character length and limit: 127 single-byte alphanumeric characters.
*/
private String logoImage;
/**
* The locale of pages displayed by PayPal payment experience. A valid value is `AU`, `AT`, `BE`, `BR`, `CA`, `CH`, `CN`, `DE`, `ES`, `GB`, `FR`, `IT`, `NL`, `PL`, `PT`, `RU`, or `US`. A 5-character code is also valid for languages in specific countries: `da_DK`, `he_IL`, `id_ID`, `ja_JP`, `no_NO`, `pt_BR`, `ru_RU`, `sv_SE`, `th_TH`, `zh_CN`, `zh_HK`, or `zh_TW`.
*/
private String localeCode;
/**
* A label to use as hypertext for the return to merchant link.
*/
private String returnUrlLabel;
/**
* A label to use as the title for the note to seller field. Used only when `allow_note` is `1`.
*/
private String noteToSellerLabel;
/**
* Default Constructor
*/
public Presentation() {
}
}
| 3,789 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PaymentDefinition.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PaymentDefinition extends PayPalModel {
/**
* Identifier of the payment_definition. 128 characters max.
*/
private String id;
/**
* Name of the payment definition. 128 characters max.
*/
private String name;
/**
* Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`.
*/
private String type;
/**
* How frequently the customer should be charged.
*/
private String frequencyInterval;
/**
* Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`.
*/
private String frequency;
/**
* Number of cycles in this payment definition.
*/
private String cycles;
/**
* Amount that will be charged at the end of each cycle for this payment definition.
*/
private Currency amount;
/**
* Array of charge_models for this payment definition.
*/
private List<ChargeModels> chargeModels;
/**
* Default Constructor
*/
public PaymentDefinition() {
}
/**
* Parameterized Constructor
*/
public PaymentDefinition(String name, String type, String frequencyInterval, String frequency, String cycles, Currency amount) {
this.name = name;
this.type = type;
this.frequencyInterval = frequencyInterval;
this.frequency = frequency;
this.cycles = cycles;
this.amount = amount;
}
}
| 3,790 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CancelNotification.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CancelNotification extends PayPalModel {
/**
* Subject of the notification.
*/
private String subject;
/**
* Note to the payer.
*/
private String note;
/**
* Indicates whether to send a copy of the notification to the merchant.
*/
private Boolean sendToMerchant;
/**
* Indicates whether to send a copy of the notification to the payer.
*/
private Boolean sendToPayer;
/**
* Applicable for invoices created with Cc emails. If this field is not in the body, all the cc email addresses added as part of the invoice shall be notified else this field can be used to limit the list of email addresses. Note: additional email addresses are not supported.
*/
private List<String> ccEmails;
/**
* Default Constructor
*/
public CancelNotification() {
}
}
| 3,791 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Address.java
|
package com.paypal.api.payments;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Address extends BaseAddress {
/**
* Phone number in E.123 format. 50 characters max.
*/
private String phone;
/**
* Type of address (e.g., HOME_OR_WORK, GIFT etc).
*/
private String type;
}
| 3,792 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Payer.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Payer extends PayPalModel {
/**
* Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
*/
private String paymentMethod;
/**
* Status of payer's PayPal Account.
*/
private String status;
/**
* Type of account relationship payer has with PayPal.
*/
private String accountType;
/**
* Duration since the payer established account relationship with PayPal in days.
*/
private String accountAge;
/**
* List of funding instruments to fund the payment. 'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed.
*/
private List<FundingInstrument> fundingInstruments;
/**
* Id of user selected funding option for the payment.'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed.
*/
private String fundingOptionId;
/**
* Default funding option available for the payment
*/
@Deprecated
private FundingOption fundingOption;
/**
* Instrument type pre-selected by the user outside of PayPal and passed along the payment creation. This param is used in cases such as PayPal Credit Second Button
*/
private String externalSelectedFundingInstrumentType;
/**
* Funding option related to default funding option.
*/
private FundingOption relatedFundingOption;
/**
* Information related to the Payer.
*/
private PayerInfo payerInfo;
/**
* Default Constructor
*/
public Payer() {
}
}
| 3,793 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/BankAccount.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BankAccount extends PayPalModel {
/**
* ID of the bank account being saved for later use.
*/
private String id;
/**
* Account number in either IBAN (max length 34) or BBAN (max length 17) format.
*/
private String accountNumber;
/**
* Type of the bank account number (International or Basic Bank Account Number). For more information refer to http://en.wikipedia.org/wiki/International_Bank_Account_Number.
*/
private String accountNumberType;
/**
* Routing transit number (aka Bank Code) of the bank (typically for domestic use only - for international use, IBAN includes bank code). For more information refer to http://en.wikipedia.org/wiki/Bank_code.
*/
private String routingNumber;
/**
* Type of the bank account.
*/
private String accountType;
/**
* A customer designated name.
*/
private String accountName;
/**
* Type of the check when this information was obtained through a check by the facilitator or merchant.
*/
private String checkType;
/**
* How the check was obtained from the customer, if check was the source of the information provided.
*/
private String authType;
/**
* Time at which the authorization (or check) was captured. Use this field if the user authorization needs to be captured due to any privacy requirements.
*/
private String authCaptureTimestamp;
/**
* Name of the bank.
*/
private String bankName;
/**
* 2 letter country code of the Bank.
*/
private String countryCode;
/**
* Account holder's first name.
*/
private String firstName;
/**
* Account holder's last name.
*/
private String lastName;
/**
* Birth date of the bank account holder.
*/
private String birthDate;
/**
* Billing address.
*/
private Address billingAddress;
/**
* State of this funding instrument.
*/
private String state;
/**
* Confirmation status of a bank account.
*/
private String confirmationStatus;
/**
* [DEPRECATED] Use external_customer_id instead.
*/
private String payerId;
/**
* A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
*/
private String externalCustomerId;
/**
* A unique identifier of the merchant for which this bank account has been stored for. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
*/
private String merchantId;
/**
* Time the resource was created.
*/
private String createTime;
/**
* Time the resource was last updated.
*/
private String updateTime;
/**
* Date/Time until this resource can be used to fund a payment.
*/
private String validUntil;
/**
*
*/
private List<DefinitionsLinkdescription> links;
/**
* Default Constructor
*/
public BankAccount() {
}
/**
* Parameterized Constructor
*/
public BankAccount(String accountNumber, String accountNumberType) {
this.accountNumber = accountNumber;
this.accountNumberType = accountNumberType;
}
}
| 3,794 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/PayerInfo.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PayerInfo extends PayPalModel {
/**
* Email address representing the payer. 127 characters max.
*/
private String email;
/**
* External Remember Me id representing the payer
*/
private String externalRememberMeId;
/**
* @deprecated use {@link #buyerAccountNumber} instead
*/
@Deprecated
private String accountNumber;
/**
* Account Number representing the Payer
*/
private String buyerAccountNumber;
/**
* Salutation of the payer.
*/
private String salutation;
/**
* First name of the payer.
*/
private String firstName;
/**
* Middle name of the payer.
*/
private String middleName;
/**
* Last name of the payer.
*/
private String lastName;
/**
* Suffix of the payer.
*/
private String suffix;
/**
* PayPal assigned encrypted Payer ID.
*/
private String payerId;
/**
* Phone number representing the payer. 20 characters max.
*/
private String phone;
/**
* Phone type
*/
private String phoneType;
/**
* Birth date of the Payer in ISO8601 format (yyyy-mm-dd).
*/
private String birthDate;
/**
* Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`.
*/
private String taxId;
/**
* Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`.
*/
private String taxIdType;
/**
* Two-letter registered country code of the payer to identify the buyer country.
*/
private String countryCode;
/**
* Billing address of the Payer.
*/
private Address billingAddress;
/**
* @deprecated Use shipping address present in purchase unit or at root level of checkout Session.
*/
@Deprecated
private ShippingAddress shippingAddress;
/**
* Default Constructor
*/
public PayerInfo() {
}
}
| 3,795 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/InputFields.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.Getter; import lombok.Setter;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class InputFields extends PayPalModel {
/**
* Indicates whether the buyer can enter a note to the merchant on the PayPal page during checkout.
*/
private Boolean allowNote;
/**
* Indicates whether PayPal displays shipping address fields on the experience pages. Valid value is `0`, `1`, or `2`. Set to `0` to display the shipping address on the PayPal pages. Set to `1` to redact shipping address fields from the PayPal pages. Set to `2` to not pass the shipping address but instead get it from the buyer's account profile. For digital goods, this field is required and value must be `1`.
*/
private int noShipping;
/**
* Indicates whether to display the shipping address that is passed to this call rather than the one on file with PayPal for this buyer on the PayPal experience pages. Valid value is `0` or `1`. Set to `0` to display the shipping address on file. Set to `1` to display the shipping address supplied to this call; the buyer cannot edit this shipping address.
*/
private int addressOverride;
/**
* Default Constructor
*/
public InputFields() {
}
}
| 3,796 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/BillingAgreementToken.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BillingAgreementToken extends PayPalModel {
/**
* Default Constructor
*/
public BillingAgreementToken() {
}
}
| 3,797 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/CreditFinancingOffered.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.PayPalModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CreditFinancingOffered extends PayPalModel {
/**
* This is the estimated total payment amount including interest and fees the user will pay during the lifetime of the loan.
*/
private Currency totalCost;
/**
* Length of financing terms in month
*/
private float term;
/**
* This is the estimated amount per month that the customer will need to pay including fees and interest.
*/
private Currency monthlyPayment;
/**
* Estimated interest or fees amount the payer will have to pay during the lifetime of the loan.
*/
private Currency totalInterest;
/**
* Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit.
*/
private Boolean payerAcceptance;
/**
* Indicates whether the cart amount is editable after payer's acceptance on PayPal side
*/
private Boolean cartAmountImmutable;
/**
* Default Constructor
*/
public CreditFinancingOffered() {
}
/**
* Parameterized Constructor
*/
public CreditFinancingOffered(Currency totalCost, float term, Currency monthlyPayment, Currency totalInterest, Boolean payerAcceptance) {
this.totalCost = totalCost;
this.term = term;
this.monthlyPayment = monthlyPayment;
this.totalInterest = totalInterest;
this.payerAcceptance = payerAcceptance;
}
}
| 3,798 |
0 |
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api
|
Create_ds/PayPal-Java-SDK/rest-api-sdk/src/main/java/com/paypal/api/payments/Templates.java
|
package com.paypal.api.payments;
import com.paypal.base.rest.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.List;
@Getter @Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class Templates extends PayPalResource {
/**
* List of addresses in merchant's profile.
*/
private List<Address> addresses;
/**
* List of emails in merchant's profile.
*/
private List<String> emails;
/**
* List of phone numbers in merchant's profile.
*/
private List<Phone> phones;
/**
* Array of templates.
*/
private List<Template> templates;
/**
* HATEOS links representing all the actions over the template list returned.
*/
private List<Links> links;
/**
* Default Constructor
*/
public Templates() {
}
/**
* Retrieve the details for a particular template by passing the template ID to the request URI.
* @deprecated Please use {@link Template#get(APIContext, String)} instead.
* @param apiContext
* {@link APIContext} used for the API call.
* @param templateId
* String
* @return Template
* @throws PayPalRESTException
*/
public static Template get(APIContext apiContext, String templateId) throws PayPalRESTException {
return Template.get(apiContext, templateId);
}
/**
* Retrieves the template information of the merchant.
* @param apiContext
* {@link APIContext} used for the API call.
* @return Templates
* @throws PayPalRESTException
*/
public static Templates getAll(APIContext apiContext) throws PayPalRESTException {
String resourcePath = "v1/invoicing/templates";
String payLoad = "";
return configureAndExecute(apiContext, HttpMethod.GET, resourcePath, payLoad, Templates.class);
}
}
| 3,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.