コード例 #1
0
  @Override
  public BookingInfo payWithStripe(@Named("token") String token, BookingInfo bookingInfo) {
    ObjectifyService.begin();
    logger.info("payWithStripe" + bookingInfo.getPaidPrice());
    Profil profil = bookingServiceManager.getProfil();
    logger.info("payWithStripe" + bookingInfo.getPaidPrice());
    Route route = ofy().load().type(Route.class).id(bookingInfo.getRouteId()).now();
    ContractorInfo contractorInfo = bookingServiceManager.getContractor(bookingInfo);
    Agent agent = ofy().load().type(Agent.class).id(contractorInfo.getAgentId()).now();
    Long orderCount = agent.getOrderCount();
    String orderRef = orderCount + "_" + bookingInfo.getName();

    String refusal = stripePayment.charge(token, bookingInfo, profil.getStripeSecret(), orderRef);
    if (refusal == null) {
      bookingInfo = bookingServiceManager.setPayed(profil, bookingInfo, OrderStatus.PAID, orderRef);
      if (bookingInfo != null) {
        AgentInfo agentInfo = bookingServiceManager.getAgent(contractorInfo);
        Mailer.sendConfirmation(bookingInfo, profil, agentInfo, contractorInfo);
        financeManager.addPayment(bookingInfo, new Date());
        ofy().save().entity(agent).now();
      }
    } else {
      bookingInfo.setStripeRefusalReason(refusal);
    }
    return bookingInfo;
  }
コード例 #2
0
  @Override
  public List<BookingInfo> cancelBooking(BookingInfo bookingInfo, AgentInfo agentInfo)
      throws IllegalArgumentException {
    bookingServiceManager.cancel(bookingInfo);
    financeManager.cancel(bookingInfo.getId());

    return getBookingsForAgent(agentInfo);
  }
コード例 #3
0
 @Override
 // @ApiMethod(name = "payment.save", httpMethod = "post")
 public List<FinanceInfo> savePayment(FinanceInfo financeInfo) {
   return financeManager.addTransfer(financeInfo);
 }
コード例 #4
0
 @Override
 public List<FinanceInfo> getFinances(AgentInfo agentInfo) {
   return financeManager.getFinance(agentInfo);
 }