Преглед изворни кода

allow setting preferred plan when adding payment method

tags/v0.15.5
Jonathan Cobb пре 4 година
родитељ
комит
d7ce21f11d
6 измењених фајлова са 23 додато и 7 уклоњено
  1. +2
    -4
      bubble-server/src/main/java/bubble/model/account/Account.java
  2. +10
    -2
      bubble-server/src/main/java/bubble/model/bill/AccountPaymentMethod.java
  3. +7
    -0
      bubble-server/src/main/java/bubble/resources/bill/AccountPaymentMethodsResource.java
  4. +2
    -0
      bubble-server/src/main/resources/db/migration/V2020080302__add_account_preferred_plan_fk.sql
  5. +1
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  6. +1
    -1
      utils/cobbzilla-wizard

+ 2
- 4
bubble-server/src/main/java/bubble/model/account/Account.java Прегледај датотеку

@@ -8,10 +8,7 @@ import bubble.dao.account.AccountInitializer;
import bubble.model.app.AppData;
import bubble.model.app.BubbleApp;
import bubble.model.app.RuleDriver;
import bubble.model.bill.AccountPayment;
import bubble.model.bill.AccountPaymentMethod;
import bubble.model.bill.AccountPlan;
import bubble.model.bill.Bill;
import bubble.model.bill.*;
import bubble.model.boot.ActivationRequest;
import bubble.model.cloud.*;
import bubble.model.cloud.notify.ReceivedNotification;
@@ -198,6 +195,7 @@ public class Account extends IdentifiableBaseParentEntity implements TokenPrinci
}

@Column(length=UUID_MAXLEN)
@ECForeignKey(entity=BubblePlan.class, index=false, cascade=false)
@Getter @Setter private String preferredPlan;
public boolean hasPreferredPlan () { return !empty(preferredPlan); }



+ 10
- 2
bubble-server/src/main/java/bubble/model/bill/AccountPaymentMethod.java Прегледај датотеку

@@ -6,6 +6,7 @@ package bubble.model.bill;

import bubble.cloud.CloudServiceType;
import bubble.cloud.payment.PaymentServiceDriver;
import bubble.dao.bill.BubblePlanDAO;
import bubble.dao.cloud.CloudServiceDAO;
import bubble.model.account.Account;
import bubble.model.account.HasAccountNoName;
@@ -102,6 +103,9 @@ public class AccountPaymentMethod extends IdentifiableBase implements HasAccount
@Transient @Getter @Setter private transient Boolean requireValidatedEmail = null;
public boolean requireValidatedEmail() { return requireValidatedEmail == null || requireValidatedEmail; }

@Transient @Getter @Setter private transient String preferredPlan;
public boolean hasPreferredPlan() { return !empty(preferredPlan); }

public ValidationResult validate(ValidationResult result, BubbleConfiguration configuration) {

if (!hasPaymentMethodType()) {
@@ -143,7 +147,7 @@ public class AccountPaymentMethod extends IdentifiableBase implements HasAccount
if (empty(getPaymentInfo())) {
result.addViolation("err.paymentInfo.required");
} else {
log.info("validate: starting validation of payment method with this.requireValidatedEmail="+requireValidatedEmail);
log.debug("validate: starting validation of payment method with this.requireValidatedEmail="+requireValidatedEmail);
final PaymentValidationResult validationResult = paymentDriver.validate(this);
if (validationResult.hasErrors()) {
result.addAll(validationResult.getViolations());
@@ -153,7 +157,11 @@ public class AccountPaymentMethod extends IdentifiableBase implements HasAccount
}
}
}

if (hasPreferredPlan()) {
final BubblePlanDAO planDAO = configuration.getBean(BubblePlanDAO.class);
final BubblePlan plan = planDAO.findById(preferredPlan);
if (plan == null) result.addViolation("err.plan.notFound");
}
return result;
}



+ 7
- 0
bubble-server/src/main/java/bubble/resources/bill/AccountPaymentMethodsResource.java Прегледај датотеку

@@ -75,4 +75,11 @@ public class AccountPaymentMethodsResource extends AccountOwnedResource<AccountP
return false;
}

@Override protected Object daoCreate(AccountPaymentMethod apm) {
if (apm.hasPreferredPlan()) {
final Account account = accountDAO.findByUuid(apm.getAccount());
accountDAO.update(account.setPreferredPlan(apm.getPreferredPlan()));
}
return super.daoCreate(apm);
}
}

+ 2
- 0
bubble-server/src/main/resources/db/migration/V2020080302__add_account_preferred_plan_fk.sql Прегледај датотеку

@@ -0,0 +1,2 @@

ALTER TABLE ONLY account ADD CONSTRAINT account_fk_preferred_plan FOREIGN KEY (preferred_plan) REFERENCES bubble_plan(uuid);

+ 1
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties Прегледај датотеку

@@ -762,6 +762,7 @@ err.paymentService.notFound=Payment service is invalid
err.parent.notFound=Parent account does not exist
err.path.length=Path is too long
err.plan.required=Plan is required
err.plan.notFound=Plan not found
err.plan.planMaxAccountLimit=No more accounts can be created. Please upgrade your plan to create more accounts.
err.price.invalid=Price is invalid
err.price.length=Price is too long


+ 1
- 1
utils/cobbzilla-wizard

@@ -1 +1 @@
Subproject commit 121fc1cc39ff487d74f9000658ba9138e18e9267
Subproject commit 7937eb3f39cfbc026275ed381b89ce4dd7b16d23

Loading…
Откажи
Сачувај