diff --git a/bubble-server/src/main/java/bubble/cloud/payment/stripe/StripePaymentDriver.java b/bubble-server/src/main/java/bubble/cloud/payment/stripe/StripePaymentDriver.java index 8a3cdb2f..6052d047 100644 --- a/bubble-server/src/main/java/bubble/cloud/payment/stripe/StripePaymentDriver.java +++ b/bubble-server/src/main/java/bubble/cloud/payment/stripe/StripePaymentDriver.java @@ -147,7 +147,10 @@ public class StripePaymentDriver extends PaymentDriverBase chargeParams = new LinkedHashMap<>();; final RedisService authCache = getAuthCache(); try { - chargeParams.put("amount", plan.getPrice()); // Amount in cents + final Long price = plan.getPrice(); + if (price <= 0) throw invalidEx("err.purchase.priceInvalid"); + + chargeParams.put("amount", price); // Amount in cents chargeParams.put("currency", plan.getCurrency().toLowerCase()); chargeParams.put("customer", paymentMethod.getPaymentInfo()); chargeParams.put("description", plan.chargeDescription()); diff --git a/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java b/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java index 9f2edfeb..ee5d0668 100644 --- a/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java +++ b/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java @@ -9,7 +9,9 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.experimental.Accessors; +import org.cobbzilla.util.collection.ArrayUtil; import org.cobbzilla.util.collection.HasPriority; +import org.cobbzilla.wizard.model.Identifiable; import org.cobbzilla.wizard.model.entityconfig.EntityFieldType; import org.cobbzilla.wizard.model.entityconfig.IdentifiableBaseParentEntity; import org.cobbzilla.wizard.model.entityconfig.annotations.*; @@ -38,15 +40,19 @@ public class BubblePlan extends IdentifiableBaseParentEntity implements HasAccou public static final int MAX_CHARGENAME_LEN = 12; - public static final String[] CREATE_FIELDS = { - "name", "chargeName", "enabled", "priority", "price", "period", - "computeSizeType", "nodesIncluded", "additionalPerNodePrice", - "storageGbIncluded", "additionalStoragePerGbPrice", - "bandwidthGbIncluded", "additionalBandwidthPerGbPrice" + public static final String[] UPDATE_FIELDS = { + "enabled", "price", "additionalPerNodePrice", "additionalStoragePerGbPrice", "additionalBandwidthPerGbPrice" }; + public static final String[] CREATE_FIELDS = ArrayUtil.append(UPDATE_FIELDS, + "name", "chargeName", "priority", "period", "computeSizeType", + "nodesIncluded", "storageGbIncluded", "bandwidthGbIncluded" + ); + public BubblePlan (BubblePlan other) { copy(this, other, CREATE_FIELDS); } + @Override public Identifiable update(Identifiable other) { copy(this, other, UPDATE_FIELDS); return this; } + @ECSearchable(filter=true) @ECField(index=10) @HasValue(message="err.name.required") @ECIndex @Column(nullable=false, updatable=false, length=200) diff --git a/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java b/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java index 58b1ebba..865268de 100644 --- a/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java +++ b/bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java @@ -29,6 +29,7 @@ import org.glassfish.grizzly.http.server.Request; import org.glassfish.jersey.server.ContainerRequest; import org.springframework.beans.factory.annotation.Autowired; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -230,6 +231,29 @@ public class AccountPlansResource extends AccountOwnedResource