Przeglądaj źródła

add support for viewing/updating payment methods

tags/v0.8.0
Jonathan Cobb 5 lat temu
rodzic
commit
0f49b61638
6 zmienionych plików z 42 dodań i 5 usunięć
  1. +8
    -0
      bubble-server/src/main/java/bubble/model/bill/AccountPaymentMethod.java
  2. +1
    -1
      bubble-server/src/main/java/bubble/model/bill/AccountPlan.java
  3. +1
    -1
      bubble-server/src/main/java/bubble/model/bill/Bill.java
  4. +13
    -2
      bubble-server/src/main/java/bubble/resources/bill/AccountPaymentMethodsResource.java
  5. +18
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  6. +1
    -1
      bubble-web

+ 8
- 0
bubble-server/src/main/java/bubble/model/bill/AccountPaymentMethod.java Wyświetl plik

@@ -9,6 +9,7 @@ import bubble.model.cloud.CloudService;
import bubble.notify.payment.PaymentValidationResult;
import bubble.server.BubbleConfiguration;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -23,6 +24,7 @@ import org.cobbzilla.wizard.validation.ValidationResult;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.util.List;

import static org.cobbzilla.util.daemon.ZillaRuntime.*;
import static org.cobbzilla.util.reflect.ReflectionUtil.copy;
@@ -86,6 +88,12 @@ public class AccountPaymentMethod extends IdentifiableBase implements HasAccount
public boolean deleted() { return deleted != null; }
public boolean notDeleted() { return !deleted(); }

@Transient @Getter @Setter private transient List<String> planNames = null;
@Transient public Boolean getDeletable () { return planNames == null ? null : notDeleted() && planNames.isEmpty(); }
public void setDeletable(boolean deletable) {} // noop

@JsonProperty @Override public long getCtime () { return super.getCtime(); }

public ValidationResult validate(ValidationResult result, BubbleConfiguration configuration) {

if (!hasPaymentMethodType()) {


+ 1
- 1
bubble-server/src/main/java/bubble/model/bill/AccountPlan.java Wyświetl plik

@@ -68,7 +68,7 @@ public class AccountPlan extends IdentifiableBase implements HasAccount {

@ECSearchable @ECField(index=40)
@ECForeignKey(entity=AccountPaymentMethod.class)
@Column(updatable=false, length=UUID_MAXLEN)
@Column(length=UUID_MAXLEN)
@Getter @Setter private String paymentMethod;

@ECSearchable @ECField(index=50)


+ 1
- 1
bubble-server/src/main/java/bubble/model/bill/Bill.java Wyświetl plik

@@ -22,7 +22,7 @@ import static org.cobbzilla.wizard.model.entityconfig.annotations.ECForeignKeySe
@ECTypeURIs(listFields={"account", "plan", "periodLabel", "total", "status"})
@Entity @NoArgsConstructor @Accessors(chain=true)
@ECIndexes({
@ECIndex(unique=true, of={"account", "accountPlan", "type", "periodStart"})
@ECIndex(unique=true, of={"accountPlan", "periodStart"})
})
public class Bill extends IdentifiableBase implements HasAccountNoName {



+ 13
- 2
bubble-server/src/main/java/bubble/resources/bill/AccountPaymentMethodsResource.java Wyświetl plik

@@ -1,8 +1,10 @@
package bubble.resources.bill;

import bubble.dao.bill.AccountPaymentMethodDAO;
import bubble.dao.bill.AccountPlanDAO;
import bubble.model.account.Account;
import bubble.model.bill.AccountPaymentMethod;
import bubble.model.bill.AccountPlan;
import bubble.resources.account.AccountOwnedResource;
import bubble.server.BubbleConfiguration;
import lombok.extern.slf4j.Slf4j;
@@ -27,6 +29,7 @@ public class AccountPaymentMethodsResource extends AccountOwnedResource<AccountP

public static final String PARAM_ALL = "all";

@Autowired private AccountPlanDAO accountPlanDAO;
@Autowired private BubbleConfiguration configuration;

public AccountPaymentMethodsResource(Account account) { super(account); }
@@ -43,12 +46,20 @@ public class AccountPaymentMethodsResource extends AccountOwnedResource<AccountP
@Override protected List<AccountPaymentMethod> list(ContainerRequest ctx) {
final Map<String, String> params = queryParams(ctx.getRequestUri().getQuery());
if (params.containsKey(PARAM_ALL) && Boolean.parseBoolean(params.get("all").toLowerCase())) {
return super.list(ctx);
return setPlanNames(super.list(ctx));
} else {
return super.list(ctx).stream().filter(AccountPaymentMethod::notDeleted).collect(Collectors.toList());
return setPlanNames(super.list(ctx).stream().filter(AccountPaymentMethod::notDeleted).collect(Collectors.toList()));
}
}

private List<AccountPaymentMethod> setPlanNames(List<AccountPaymentMethod> paymentMethods) {
for (AccountPaymentMethod apm : paymentMethods) {
final List<AccountPlan> plans = accountPlanDAO.findByAccountAndPaymentMethodAndNotDeleted(apm.getAccount(), apm.getUuid());
apm.setPlanNames(plans.stream().map(AccountPlan::getName).collect(Collectors.toList()));
}
return paymentMethods;
}

@Override protected AccountPaymentMethod setReferences(ContainerRequest ctx, Account caller, AccountPaymentMethod request) {
final ValidationResult result = new ValidationResult();
request.validate(result, configuration);


+ 18
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties Wyświetl plik

@@ -33,6 +33,8 @@ button_label_update_profile=Update
link_label_change_password=Change Password
link_label_account_ssh_keys=Manage SSH Keys
link_label_account_policy=Account Policy and Contact Info
link_label_account_payments=Payment Methods and Credits
link_label_account_bills=Bills
message_profile_update_success=Profile update was successful

# Account SSH key fields
@@ -285,6 +287,22 @@ label_promotion_AccountCredit1=$1 Bonus
label_promotion_AccountCredit5=$5 Bonus
label_promotion_AccountCreditBill=Full Bill Bonus ($100 max value)

title_account_payment_methods=Payment Methods
label_account_payment_method_type=Type
label_account_payment_method_info=Info
label_account_payment_method_added=Added
label_account_payment_method_added_format={{MMM}} {{d}}, {{YYYY}}
label_account_payment_method_current=Currently paying for
label_account_payment_method_remove=Delete
label_account_payment_method_set=Set as payment for plan
label_account_payment_add=Add New Payment Method
button_label_account_payment_delete=Remove

title_account_promotions=Promotional Credits
title_account_promotions_used=Used Promotional Credits
label_account_promotion_used=Used On
label_account_payment_method_used_format={{MMM}} {{d}}, {{YYYY}}

# Bubble Plans
plan_name_bubble=Bubble Standard
plan_description_bubble=Try this one first. Most users probably don't need anything more


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit ddbe7e69b39138c458766c82ee616c31fa7980d1
Subproject commit ecaebb464c6ecb27d2422a42f42892181ae09c4e

Ładowanie…
Anuluj
Zapisz