/** * Enter an offline payment for a manual invoice (beta) - Recurly Enterprise Feature * * @deprecated Prefer using Invoice#getId() as the id param (which is a String) * * @param invoiceId Recurly Invoice ID * @param payment The external payment */ @Deprecated public Transaction enterOfflinePayment(final Integer invoiceId, final Transaction payment) { return enterOfflinePayment(invoiceId.toString(), payment); }
/** * Get Account Adjustments * <p> * * @param accountCode recurly account id * @return the adjustments on the account */ public Adjustments getAccountAdjustments(final String accountCode) { return getAccountAdjustments(accountCode, null, null, new QueryParams()); }
/** * Lookup an invoice * <p> * Returns the invoice given an integer id * * @deprecated Please switch to using a string for invoice ids * * @param invoiceId Recurly Invoice ID * @return the invoice */ @Deprecated public Invoice getInvoice(final Integer invoiceId) { return getInvoice(invoiceId.toString()); }
@BeforeMethod(groups = {"integration", "enterprise"}) public void setUp() throws Exception { final String apiKey = System.getProperty(KILLBILL_PAYMENT_RECURLY_API_KEY); String subDomainTemp = System.getProperty(KILLBILL_PAYMENT_RECURLY_SUBDOMAIN); if (apiKey == null) { Assert.fail("You need to set your Recurly api key to run integration tests:" + " -Dkillbill.payment.recurly.apiKey=..."); } if (subDomainTemp == null) { subDomainTemp = "api"; } final String subDomain = subDomainTemp; recurlyClient = new RecurlyClient(apiKey, subDomain); recurlyClient.open(); }
@Test(groups = "integration") public void testUnauthorizedException() throws Exception { final String subdomain = System.getProperty(KILLBILL_PAYMENT_RECURLY_SUBDOMAIN); RecurlyClient unauthorizedRecurlyClient = new RecurlyClient("invalid-api-key", subdomain); unauthorizedRecurlyClient.open(); try { unauthorizedRecurlyClient.getAccounts(); Assert.fail("getAccounts call should not succeed with invalid credentials."); } catch (RecurlyAPIException expected) { Assert.assertEquals(expected.getRecurlyError().getSymbol(), "unauthorized"); } }
final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); adjustmentData1.setDescription("A description of an account adjustment1"); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustmentData1); adjustmentData2.setDescription("A description of an account adjustment2"); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustmentData2); final Invoice invoice = recurlyClient.postAccountInvoice(account.getAccountCode(), invoiceData).getChargeInvoice(); updatedInvoice.setCustomerNotes("Some notes"); recurlyClient.updateInvoice(invoice.getId(), updatedInvoice); refundOptions.setExternalRefund(true); refundOptions.setPaymentMethod("credit_card"); final Invoice refundInvoice = recurlyClient.refundInvoice(invoice.getId(), refundOptions); final Invoices originalInvoices = recurlyClient.getOriginalInvoices(refundInvoice.getId()); Assert.assertEquals(originalInvoices.get(0).getId(), invoice.getId()); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode());
final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); adjustmentData1.setDescription("A description of an account adjustment1"); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustmentData1); adjustmentData2.setDescription("A description of an account adjustment2"); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustmentData2); Invoice invoice = recurlyClient.postAccountInvoice(account.getAccountCode(), invoiceData).getChargeInvoice(); invoice = recurlyClient.getInvoice(invoice.getId()); refundOptions.setRefundMethod(RefundMethod.transaction_first); refundOptions.setLineItems(lineItems); final Invoice refundInvoice = recurlyClient.refundInvoice(invoice.getId(), refundOptions); Assert.assertEquals(lineItem.getQuantity(), new Integer(1)); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode());
final Account account = recurlyClient.createAccount(accountData); final Adjustment createdA = recurlyClient.createAccountAdjustment(accountData.getAccountCode(), a); invoiceData.setCollectionMethod("manual"); invoiceData.setLineItems(null); final Invoice invoice = recurlyClient.postAccountInvoice(accountData.getAccountCode(), invoiceData).getChargeInvoice(); Assert.assertNotNull(invoice); final Invoice closedInvoice = recurlyClient.markInvoiceSuccessful(invoice.getId()); Assert.assertEquals(closedInvoice.getState(), "paid", "Invoice not closed successfully"); final Adjustment createdB = recurlyClient.createAccountAdjustment(accountData.getAccountCode(), b); failInvoiceData.setCollectionMethod("manual"); failInvoiceData.setLineItems(null); final Invoice invoiceFail = recurlyClient.postAccountInvoice(accountData.getAccountCode(), failInvoiceData).getChargeInvoice(); Assert.assertNotNull(invoiceFail); final Invoice failedInvoice = recurlyClient.markInvoiceFailed(invoiceFail.getId()).getChargeInvoice(); Assert.assertEquals(failedInvoice.getState(), "failed", "Invoice not failed successfully"); final Adjustment created = recurlyClient.createAccountAdjustment(accountData.getAccountCode(), c); externalInvoiceData.setCollectionMethod("manual"); externalInvoiceData.setLineItems(null); final Invoice invoiceExternal = recurlyClient.postAccountInvoice(accountData.getAccountCode(), externalInvoiceData).getChargeInvoice(); Assert.assertNotNull(invoiceExternal);
final Account account = recurlyClient.createAccount(accountData); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final Plan plan = recurlyClient.createPlan(planData); Thread.sleep(1000); // TODO - can remove after Jan 18th 2017 final List<AddOn> addons = new ArrayList<AddOn>(); for (int i = 0; i < nbAddOns; i++) { final AddOn addOn = TestUtils.createRandomAddOn(CURRENCY); final AddOn addOnRecurly = recurlyClient.createPlanAddOn(plan.getPlanCode(), addOn); addons.add(addOnRecurly); final Subscription subscriptionWithAddons = recurlyClient.createSubscription(subscriptionDataWithAddons); Assert.assertEquals(subscriptionWithAddons.getAddOns().size(), nbAddOns); for (int i = 0; i < nbAddOns; i++) { final Invoice gotInvoice = recurlyClient.getInvoice(invoiceID); final Subscription subscriptionWithAddons1 = recurlyClient.updateSubscription(subscriptionWithAddons.getUuid(), subscriptionUpdate); Assert.assertTrue(subscriptionWithAddons1.getAddOns().isEmpty()); newAddons.addAll(subscriptionDataWithAddons.getAddOns()); subscriptionUpdate1.setAddOns(newAddons); final Subscription subscriptionWithAddons2 = recurlyClient.updateSubscription(subscriptionWithAddons.getUuid(), subscriptionUpdate1); Assert.assertEquals(subscriptionWithAddons2.getAddOns().size(), nbAddOns); for (int i = 0; i < nbAddOns; i++) {
final Account account = recurlyClient.createAccount(accountData); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Plan plan = recurlyClient.createPlan(planData); recurlyClient.createAccountAdjustment(accountData.getAccountCode(), adjustment); recurlyClient.createAccountAdjustment(accountData.getAccountCode(), adjustmentWithCode); Adjustments retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), null, null); Assert.assertEquals(retrievedAdjustments.size(), 2, "Did not retrieve correct count of Adjustments of any type and state"); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), Adjustments.AdjustmentType.CHARGE, null); Assert.assertEquals(retrievedAdjustments.size(), 2, "Did not retrieve correct count of Adjustments of type Charge"); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), Adjustments.AdjustmentType.CHARGE, Adjustments.AdjustmentState.INVOICED); Assert.assertEquals(retrievedAdjustments.size(), 0, "Retrieved Adjustments of type Charge marked as invoiced although none should be."); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), null, Adjustments.AdjustmentState.INVOICED); Assert.assertEquals(retrievedAdjustments.size(), 0, "Retrieved Adjustments marked as invoiced although none should be."); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), Adjustments.AdjustmentType.CHARGE, Adjustments.AdjustmentState.PENDING); Assert.assertEquals(2, retrievedAdjustments.size(), "Did not retrieve correct count of Adjustments of type Charge in Pending state"); int adjAccountCodeCounter = 0; recurlyClient.closeAccount(accountData.getAccountCode());
final Account account = recurlyClient.createAccount(accountData); a.setCurrency(CURRENCY); final Adjustment createdA = recurlyClient.createAccountAdjustment(accountData.getAccountCode(), a); invoiceData.setCollectionMethod("manual"); invoiceData.setLineItems(null); final Invoice invoice = recurlyClient.postAccountInvoice(accountData.getAccountCode(), invoiceData).getChargeInvoice(); Assert.assertNotNull(invoice); InputStream pdfInputStream = recurlyClient.getInvoicePdf(invoice.getId()); Assert.assertNotNull(pdfInputStream); Assert.assertTrue(pdfString.contains("Subtotal $" + 1.5)); final Invoice closedInvoice = recurlyClient.markInvoiceSuccessful(invoice.getId()); Assert.assertEquals(closedInvoice.getState(), "paid", "Invoice not closed successfully"); recurlyClient.closeAccount(accountData.getAccountCode());
final Account account = recurlyClient.createAccount(accountData); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); recurlyClient.createAccountAdjustment(accountData.getAccountCode(), a); final InvoiceCollection collection = recurlyClient.postAccountInvoice(accountData.getAccountCode(), invoiceData); Assert.assertNotNull(collection.getChargeInvoice()); Adjustments retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), null, Adjustments.AdjustmentState.PENDING); Assert.assertEquals(retrievedAdjustments.size(), 0, "Retrieved Adjustments marked as pending although none should be."); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), null, Adjustments.AdjustmentState.INVOICED); Assert.assertEquals(retrievedAdjustments.size(), 1, "Not all Adjustments marked as invoiced although all should be."); final Adjustment createdB = recurlyClient.createAccountAdjustment(accountData.getAccountCode(), b); final Invoice invoiceFail = recurlyClient.postAccountInvoice(accountData.getAccountCode(), failInvoiceData).getChargeInvoice(); Assert.assertNotNull(invoiceFail); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), null, Adjustments.AdjustmentState.PENDING); Assert.assertEquals(retrievedAdjustments.size(), 0, "Retrieved Adjustments marked as pending although none should be."); retrievedAdjustments = recurlyClient.getAccountAdjustments(accountData.getAccountCode(), null, Adjustments.AdjustmentState.INVOICED); Assert.assertEquals(retrievedAdjustments.size(), 2, "Not all Adjustments marked as invoiced although all should be.");
final Plan plan = recurlyClient.createPlan(planData); final GiftCard purchasedGiftCard = recurlyClient.purchaseGiftCard(giftCardData); final GiftCard redemptionData = new GiftCard(); redemptionData.setRedemptionCode(purchasedGiftCard.getRedemptionCode()); purchaseData.setVatReverseChargeNotes("VAT Reverse Charge Notes"); final Invoice invoice = recurlyClient.authorizePurchase(purchaseData).getChargeInvoice(); Assert.assertNotNull(invoice.getUuid()); } finally { recurlyClient.deletePlan(planData.getPlanCode());
@Test(groups = "fast") public void testEmptyGitRepositoryState() throws Exception { final Properties gitRepositoryState = new Properties(); Assert.assertNull(recurlyClient.getVersionFromGitRepositoryState(gitRepositoryState)); } }
/** * Refund an invoice given some line items * <p/> * Returns the refunded invoice * * @deprecated Please use refundInvoice(String, InvoiceRefund) * * @param invoiceId The id of the invoice to refund * @param lineItems The list of adjustment refund objects * @param method If credit line items exist on the invoice, this parameter specifies which refund method to use first * @return the refunded invoice */ @Deprecated public Invoice refundInvoice(final String invoiceId, List<AdjustmentRefund> lineItems, final RefundMethod method) { final InvoiceRefund invoiceRefund = new InvoiceRefund(); invoiceRefund.setRefundMethod(method); invoiceRefund.setLineItems(lineItems); return refundInvoice(invoiceId, invoiceRefund); }
/** * Mark an invoice as failed collection * * @deprecated Prefer using Invoice#getId() as the id param (which is a String) * * @param invoiceId Recurly Invoice ID */ @Deprecated public InvoiceCollection markInvoiceFailed(final Integer invoiceId) { return markInvoiceFailed(invoiceId.toString()); }
/** * Mark an invoice as paid successfully - Recurly Enterprise Feature * * @deprecated Prefer using Invoice#getId() as the id param (which is a String) * * @param invoiceId Recurly Invoice ID */ @Deprecated public Invoice markInvoiceSuccessful(final Integer invoiceId) { return markInvoiceSuccessful(invoiceId.toString()); }
/** * Fetch invoice pdf * <p> * Returns the invoice pdf as an inputStream * * @deprecated Prefer using Invoice#getId() as the id param (which is a String) * * @param invoiceId Recurly Invoice ID * @return the invoice pdf as an inputStream */ @Deprecated public InputStream getInvoicePdf(final Integer invoiceId) { return getInvoicePdf(invoiceId.toString()); }
@BeforeMethod(groups = "fast") public void setUp() throws Exception { recurlyClient = new RecurlyClient(UUID.randomUUID().toString(), "api"); }
final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); adjustmentData1.setDescription("A description of an account adjustment1"); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustmentData1); adjustmentData2.setDescription("A description of an account adjustment2"); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustmentData2); final Invoice invoice = recurlyClient.postAccountInvoice(account.getAccountCode(), invoiceData).getChargeInvoice(); updatedInvoice.setCustomerNotes("Some notes"); recurlyClient.updateInvoice(invoice.getId(), updatedInvoice); refundOptions.setExternalRefund(true); refundOptions.setPaymentMethod("credit_card"); final Invoice refundInvoice = recurlyClient.refundInvoice(invoice.getId(), refundOptions); final Invoices originalInvoices = recurlyClient.getOriginalInvoices(refundInvoice.getId()); Assert.assertEquals(originalInvoices.get(0).getId(), invoice.getId()); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode());