invoicePaymentApi.createPurchaseForInvoicePayment(account, invoiceId, payment.getPaymentMethodId(), payment.getId(), amount, currency, null, payment.getExternalKey(), pendingOrSuccessTransaction.getExternalKey(), pluginProperties, paymentOptions, callContext);
@Override public Payment apply(@Nullable final Void input) { try { final InvoicePayment invoicePayment = invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(), null, amount, currency, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); return paymentApi.getPayment(invoicePayment.getPaymentId(), false, false, ImmutableList.<PluginProperty>of(), callContext); } catch (final PaymentApiException e) { fail(e.toString()); return null; } } }, events);
@Override public Payment apply(@Nullable final Void input) { try { final InvoicePayment invoicePayment = invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(), null, invoice.getBalance(), invoice.getCurrency(), null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), EXTERNAL_PAYMENT_OPTIONS, callContext); return paymentApi.getPayment(invoicePayment.getPaymentId(), false, false, ImmutableList.<PluginProperty>of(), callContext); } catch (final PaymentApiException e) { fail(e.toString()); return null; } } }, events);
protected InvoicePayment createPurchaseForInvoice(final Account account, final UUID invoiceId, final BigDecimal amountToPay, final UUID paymentMethodId, final Boolean externalPayment, final String paymentExternalKey, final String transactionExternalKey, final Iterable<PluginProperty> pluginProperties, final CallContext callContext) throws PaymentApiException { try { return invoicePaymentApi.createPurchaseForInvoicePayment(account, invoiceId, paymentMethodId, null, amountToPay, account.getCurrency(), null, paymentExternalKey, transactionExternalKey, pluginProperties, createInvoicePaymentControlPluginApiPaymentOptions(externalPayment), callContext); } catch (final PaymentApiException e) { if (e.getCode() == ErrorCode.PAYMENT_PLUGIN_EXCEPTION.getCode() /* && e.getMessage().contains("Invalid amount") */) { /* Plugin received bad input */ throw e; } else if (e.getCode() == ErrorCode.PAYMENT_PLUGIN_API_ABORTED.getCode()) { /* Plugin aborted the call (e.g invoice already paid) */ return null; } throw e; } }
@Test(groups = "slow") public void testCreatePurchaseWithExternalKeyOverLimit() throws InvoiceApiException, EventBusException { final BigDecimal requestedAmount = BigDecimal.TEN; final LocalDate now = clock.getUTCToday(); final Invoice invoice = testHelper.createTestInvoice(account, now, Currency.USD); final String paymentExternalKey = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,."; final String transactionExternalKey = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,."; try { invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(), null, requestedAmount, Currency.USD, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), INVOICE_PAYMENT, callContext); Assert.fail(); } catch (final PaymentApiException e) { assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode()); } }
invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
invoice.addInvoiceItem(invoiceItem); invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
Currency.USD)); try { invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
new BigDecimal("1.0"), Currency.USD)); invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
invoice.addInvoiceItem(invoiceItem); invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
invoicePaymentApi.createPurchaseForInvoicePayment(account, updateInvoice2.getId(), account.getPaymentMethodId(),
invoice.addInvoiceItem(invoiceItem); invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
Currency.USD)); try { invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(), invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice1.getId(), payments.get(0).getPaymentMethodId(),
invoicePaymentApi.createPurchaseForInvoicePayment(childAccount, childInvoices.get(1).getId(), childAccount.getPaymentMethodId(),
invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),
invoicePaymentApi.createPurchaseForInvoicePayment(account, invoice.getId(), account.getPaymentMethodId(),