Tabnine Logo
PaymentApi.addPaymentMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
addPaymentMethod
method
in
com.ning.billing.payment.api.PaymentApi

Best Java code snippets using com.ning.billing.payment.api.PaymentApi.addPaymentMethod (Showing top 4 results out of 315)

origin: com.ning.billing/killbill-payment

  public void addTestPaymentMethod(final Account account, final PaymentMethodPlugin paymentMethodInfo) throws Exception {
    final UUID paymentMethodId = paymentApi.addPaymentMethod(MockPaymentProviderPlugin.PLUGIN_NAME, account, true, paymentMethodInfo, context);
    Mockito.when(account.getPaymentMethodId()).thenReturn(paymentMethodId);
  }
}
origin: com.ning.billing/killbill-jaxrs

@POST
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response createPaymentMethod(final PaymentMethodJson json,
                  @PathParam("accountId") final String accountId,
                  @QueryParam(QUERY_PAYMENT_METHOD_IS_DEFAULT) @DefaultValue("false") final Boolean isDefault,
                  @QueryParam(QUERY_PAY_ALL_UNPAID_INVOICES) @DefaultValue("false") final Boolean payAllUnpaidInvoices,
                  @HeaderParam(HDR_CREATED_BY) final String createdBy,
                  @HeaderParam(HDR_REASON) final String reason,
                  @HeaderParam(HDR_COMMENT) final String comment,
                  @javax.ws.rs.core.Context final UriInfo uriInfo,
                  @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException {
  final CallContext callContext = context.createContext(createdBy, reason, comment, request);
  final PaymentMethod data = json.toPaymentMethod(accountId);
  final Account account = accountUserApi.getAccountById(data.getAccountId(), callContext);
  final boolean hasDefaultPaymentMethod = account.getPaymentMethodId() != null || isDefault;
  final Collection<Invoice> unpaidInvoices = payAllUnpaidInvoices ? invoiceApi.getUnpaidInvoicesByAccountId(account.getId(), clock.getUTCToday(), callContext) :
                        Collections.<Invoice>emptyList();
  if (payAllUnpaidInvoices && unpaidInvoices.size() > 0 && !hasDefaultPaymentMethod) {
    return Response.status(Status.BAD_REQUEST).build();
  }
  final UUID paymentMethodId = paymentApi.addPaymentMethod(data.getPluginName(), account, isDefault, data.getPluginDetail(), callContext);
  if (payAllUnpaidInvoices && unpaidInvoices.size() > 0) {
    for (final Invoice invoice : unpaidInvoices) {
      paymentApi.createPayment(account, invoice.getId(), invoice.getBalance(), callContext);
    }
  }
  return uriBuilder.buildResponse(PaymentMethodResource.class, "getPaymentMethod", paymentMethodId, uriInfo.getBaseUri().toString());
}
origin: com.ning.billing/killbill-payment

final UUID newPaymentMethodId = paymentApi.addPaymentMethod(MockPaymentProviderPlugin.PLUGIN_NAME, account, true, newPaymenrMethod, callContext);
Mockito.when(account.getPaymentMethodId()).thenReturn(newPaymentMethodId);
origin: com.ning.billing/killbill-payment

@Test(groups = "slow")
public void testRefreshWithDeletedPaymentMethod() throws Exception {
  final Account account = testHelper.createTestAccount("super@bar.com", true);
  Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 1);
  final UUID firstPmId = account.getPaymentMethodId();
  final UUID secondPmId = paymentApi.addPaymentMethod(MockPaymentProviderPlugin.PLUGIN_NAME, account, true, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, null), callContext);
  Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 2);
  Assert.assertEquals(paymentApi.getPaymentMethods(account, false, callContext).size(), 2);
  // Remove second PM from plugin
  getPluginApi().deletePaymentMethod(account.getId(), secondPmId, callContext);
  Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, callContext).size(), 1);
  Assert.assertEquals(paymentApi.getPaymentMethods(account, false, callContext).size(), 2);
  // Verify that the refresh sees that PM as being deleted now
  final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, internalCallContext);
  Assert.assertEquals(methods.size(), 1);
  checkPaymentMethodExistsWithStatus(methods, firstPmId, true);
  PaymentMethodModelDao deletedPMModel =  paymentDao.getPaymentMethodIncludedDeleted(secondPmId, internalCallContext);
  Assert.assertNotNull(deletedPMModel);
  Assert.assertFalse(deletedPMModel.isActive());
}
com.ning.billing.payment.apiPaymentApiaddPaymentMethod

Popular methods of PaymentApi

  • createPayment
  • deletedPaymentMethod
  • getAccountPayments
  • getPaymentMethods
    Find all payment methods in a given plugin
  • createExternalPayment
  • createRefund
    Create a refund for a given payment. The associated invoice is not adjusted.
  • createRefundWithAdjustment
    Create a refund for a given payment. The associated invoice is adjusted.
  • createRefundWithItemsAdjustments
    Create a refund for a given payment. The specified invoice items are fully adjusted. The refund amou
  • getAccountRefunds
  • getInvoicePayments
  • getPayment
  • getPaymentMethodById
  • getPayment,
  • getPaymentMethodById,
  • getPaymentRefunds,
  • getPayments,
  • getRefund,
  • getRefunds,
  • retryPayment,
  • searchPaymentMethods,
  • searchPayments

Popular in Java

  • Reactive rest calls using spring rest template
  • getSharedPreferences (Context)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (Timer)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now