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

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

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

origin: com.ning.billing/killbill-jaxrs

@POST
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{invoiceId:" + UUID_PATTERN + "}/" + PAYMENTS)
public Response createInstantPayment(final PaymentJson payment,
                   @QueryParam(QUERY_PAYMENT_EXTERNAL) @DefaultValue("false") final Boolean externalPayment,
                   @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 HttpServletRequest request,
                   @javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException, PaymentApiException {
  final CallContext callContext = context.createContext(createdBy, reason, comment, request);
  final Account account = accountUserApi.getAccountById(UUID.fromString(payment.getAccountId()), callContext);
  final UUID invoiceId = UUID.fromString(payment.getInvoiceId());
  if (externalPayment) {
    paymentApi.createExternalPayment(account, invoiceId, payment.getAmount(), callContext);
  } else {
    paymentApi.createPayment(account, invoiceId, payment.getAmount(), callContext);
  }
  return uriBuilder.buildResponse(uriInfo, InvoiceResource.class, "getPayments", payment.getInvoiceId());
}
origin: com.ning.billing/killbill-jaxrs

@DELETE
@Produces(APPLICATION_JSON)
@Path("/{paymentMethodId:" + UUID_PATTERN + "}")
public Response deletePaymentMethod(@PathParam("paymentMethodId") final String paymentMethodId,
                  @QueryParam(QUERY_DELETE_DEFAULT_PM_WITH_AUTO_PAY_OFF) @DefaultValue("false") final Boolean deleteDefaultPaymentMethodWithAutoPayOff,
                  @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 HttpServletRequest request) throws PaymentApiException, AccountApiException {
  final CallContext callContext = context.createContext(createdBy, reason, comment, request);
  final PaymentMethod paymentMethod = paymentApi.getPaymentMethodById(UUID.fromString(paymentMethodId), false, false, callContext);
  final Account account = accountUserApi.getAccountById(paymentMethod.getAccountId(), callContext);
  paymentApi.deletedPaymentMethod(account, UUID.fromString(paymentMethodId), deleteDefaultPaymentMethodWithAutoPayOff, callContext);
  return Response.status(Status.OK).build();
}
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENTS)
@Produces(APPLICATION_JSON)
public Response getPayments(@PathParam("accountId") final String accountId,
              @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException {
  final List<Payment> payments = paymentApi.getAccountPayments(UUID.fromString(accountId), context.createContext(request));
  final List<PaymentJson> result = new ArrayList<PaymentJson>(payments.size());
  for (final Payment payment : payments) {
    result.add(new PaymentJson(payment, null));
  }
  return Response.status(Status.OK).entity(result).build();
}
origin: com.ning.billing/killbill-jaxrs

@PUT
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS + "/{paymentMethodId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS_DEFAULT_PATH_POSTFIX)
public Response setDefaultPaymentMethod(@PathParam("accountId") final String accountId,
                    @PathParam("paymentMethodId") final String paymentMethodId,
                    @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 HttpServletRequest request) throws AccountApiException, PaymentApiException {
  final CallContext callContext = context.createContext(createdBy, reason, comment, request);
  final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), callContext);
  paymentApi.setDefaultPaymentMethod(account, UUID.fromString(paymentMethodId), callContext);
  if (payAllUnpaidInvoices) {
    final Collection<Invoice> unpaidInvoices = invoiceApi.getUnpaidInvoicesByAccountId(account.getId(), clock.getUTCToday(), callContext);
    for (final Invoice invoice : unpaidInvoices) {
      paymentApi.createPayment(account, invoice.getId(), invoice.getBalance(), callContext);
    }
  }
  return Response.status(Status.OK).build();
}
origin: com.ning.billing/killbill-payment

@Test(groups = "fast")
public void testPaymentMethods() throws Exception {
  List<PaymentMethod> methods = paymentApi.getPaymentMethods(account, false, callContext);
  assertEquals(methods.size(), 1);
  final UUID newPaymentMethodId = paymentApi.addPaymentMethod(MockPaymentProviderPlugin.PLUGIN_NAME, account, true, newPaymenrMethod, callContext);
  Mockito.when(account.getPaymentMethodId()).thenReturn(newPaymentMethodId);
  methods = paymentApi.getPaymentMethods(account, false, callContext);
  assertEquals(methods.size(), 2);
    paymentApi.deletedPaymentMethod(account, newPaymentMethodId, false, callContext);
  } catch (PaymentApiException e) {
    failed = true;
  paymentApi.deletedPaymentMethod(account, initDefaultMethod.getId(), true,  callContext);
  methods = paymentApi.getPaymentMethods(account, false, callContext);
  assertEquals(methods.size(), 1);
  paymentApi.deletedPaymentMethod(account, newPaymentMethodId, true, callContext);
  methods = paymentApi.getPaymentMethods(account, false, callContext);
  assertEquals(methods.size(), 0);
origin: com.ning.billing/killbill-jaxrs

final Payment payment = paymentApi.getPayment(paymentUuid, false, callContext);
final Account account = accountUserApi.getAccountById(payment.getAccountId(), callContext);
      adjustments.put(UUID.fromString(item.getInvoiceItemId()), item.getAmount());
    result = paymentApi.createRefundWithItemsAdjustments(account, paymentUuid, adjustments, callContext);
  } else {
    result = paymentApi.createRefundWithAdjustment(account, paymentUuid, json.getAmount(), callContext);
  result = paymentApi.createRefund(account, paymentUuid, json.getAmount(), callContext);
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

@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());
}
origin: com.ning.billing/killbill-payment

  paymentApi.createPayment(account, invoice.getId(), requestedAmount, callContext);
} catch (PaymentApiException e) {
  Assert.assertEquals(e.getCode(), ErrorCode.PAYMENT_NO_DEFAULT_PAYMENT_METHOD.getCode());
final List<Payment> payments = paymentApi.getAccountPayments(account.getId(), callContext);
Assert.assertEquals(payments.size(), 1);
origin: com.ning.billing/killbill-jaxrs

final List<Payment> payments = paymentApi.getAccountPayments(accountId, tenantContext);
final List<Refund> refunds = paymentApi.getAccountRefunds(account, tenantContext);
final Multimap<UUID, Refund> refundsByPayment = ArrayListMultimap.<UUID, Refund>create();
for (final Refund refund : refunds) {
origin: com.ning.billing/killbill-jaxrs

paymentApi.createPayment(account, invoice.getId(), invoice.getBalance(), callContext);
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS)
@Produces(APPLICATION_JSON)
public Response getPaymentMethods(@PathParam("accountId") final String accountId,
                 @QueryParam(QUERY_PAYMENT_METHOD_PLUGIN_INFO) @DefaultValue("false") final Boolean withPluginInfo,
                 @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
                 @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), tenantContext);
  final List<PaymentMethod> methods = paymentApi.getPaymentMethods(account, withPluginInfo, tenantContext);
  final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext);
  final List<PaymentMethodJson> json = new ArrayList<PaymentMethodJson>(Collections2.transform(methods, new Function<PaymentMethod, PaymentMethodJson>() {
    @Override
    public PaymentMethodJson apply(final PaymentMethod input) {
      return PaymentMethodJson.toPaymentMethodJson(account, input, accountAuditLogs);
    }
  }));
  return Response.status(Status.OK).entity(json).build();
}
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

@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + REFUNDS)
@Produces(APPLICATION_JSON)
public Response getRefunds(@PathParam("accountId") final String accountId,
              @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, PaymentApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), tenantContext);
  final List<Refund> refunds = paymentApi.getAccountRefunds(account, tenantContext);
  final List<RefundJson> result = new ArrayList<RefundJson>(Collections2.transform(refunds, new Function<Refund, RefundJson>() {
    @Override
    public RefundJson apply(Refund input) {
      // TODO Return adjusted items and audits
      return new RefundJson(input, null, null);
    }
  }));
  return Response.status(Status.OK).entity(result).build();
}
origin: com.ning.billing/killbill-jaxrs

paymentApi.createPayment(account, invoice.getId(), invoice.getBalance(), callContext);
origin: com.ning.billing/killbill-jaxrs

  paymentMethods = paymentApi.getPaymentMethods(offset, limit, tenantContext);
} else {
  paymentMethods = paymentApi.getPaymentMethods(offset, limit, pluginName, tenantContext);
origin: com.ning.billing/killbill-jaxrs

@POST
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENTS)
public Response payAllInvoices(@PathParam("accountId") final String accountId,
                @QueryParam(QUERY_PAYMENT_EXTERNAL) @DefaultValue("false") final Boolean externalPayment,
                @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 HttpServletRequest request) throws AccountApiException, PaymentApiException {
  final CallContext callContext = context.createContext(createdBy, reason, comment, request);
  final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), callContext);
  final Collection<Invoice> unpaidInvoices = invoiceApi.getUnpaidInvoicesByAccountId(account.getId(), clock.getUTCToday(), callContext);
  for (final Invoice invoice : unpaidInvoices) {
    if (externalPayment) {
      paymentApi.createExternalPayment(account, invoice.getId(), invoice.getBalance(), callContext);
    } else {
      paymentApi.createPayment(account, invoice.getId(), invoice.getBalance(), callContext);
    }
  }
  return Response.status(Status.OK).build();
}
origin: com.ning.billing/killbill-payment

final Payment paymentInfo = paymentApi.createPayment(account, invoice.getId(), requestedAmount, callContext);
if (expectedAmount == null) {
  fail("Expected to fail because requested amount > invoice amount");
com.ning.billing.payment.apiPaymentApi

Most used methods

  • addPaymentMethod
  • 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
  • getInvoicePayments,
  • getPayment,
  • getPaymentMethodById,
  • getPaymentRefunds,
  • getPayments,
  • getRefund,
  • getRefunds,
  • retryPayment,
  • searchPaymentMethods,
  • searchPayments

Popular in Java

  • Creating JSON documents from java classes using gson
  • setContentView (Activity)
  • setScale (BigDecimal)
  • getSharedPreferences (Context)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • CodeWhisperer alternatives
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