瀏覽代碼

allow updating plan prices. throw error in credit processing if price is zero

tags/v0.5.2
Jonathan Cobb 5 年之前
父節點
當前提交
232729e7f0
共有 5 個檔案被更改,包括 41 行新增7 行删除
  1. +4
    -1
      bubble-server/src/main/java/bubble/cloud/payment/stripe/StripePaymentDriver.java
  2. +11
    -5
      bubble-server/src/main/java/bubble/model/bill/BubblePlan.java
  3. +24
    -0
      bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java
  4. +1
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  5. +1
    -1
      bubble-web

+ 4
- 1
bubble-server/src/main/java/bubble/cloud/payment/stripe/StripePaymentDriver.java 查看文件

@@ -147,7 +147,10 @@ public class StripePaymentDriver extends PaymentDriverBase<StripePaymentDriverCo
final Map<String, Object> 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());


+ 11
- 5
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)


+ 24
- 0
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<AccountPlan, Acco
}
}

// If the accountPlan is not found, look for an orphaned network
@DELETE @Path("/{id}")
@Override public Response delete(@Context ContainerRequest ctx,
@PathParam("id") String id) {
final Account caller = checkEditable(ctx);
AccountPlan found = find(ctx, id);
if (found == null) {
found = findAlternateForDelete(ctx, id);
if (found == null) {
final BubbleNetwork orphan = networkDAO.findByAccountAndId(getAccountUuid(ctx), id);
if (orphan == null) return notFound(id);
log.warn("delete: deleting orphaned network: "+orphan.getUuid()+"/"+orphan.getNetworkDomain());
networkDAO.delete(orphan.getUuid());
return ok_empty();
}
}

if (!canDelete(ctx, caller, found)) return forbidden();

getDao().delete(found.getUuid());
return ok(found);
}

@Path("/{id}"+EP_BILLS)
public BillsResource getBills(@Context ContainerRequest ctx,
@PathParam("id") String id) {


+ 1
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties 查看文件

@@ -599,6 +599,7 @@ err.purchase.paymentMethodMismatch=Payment method cannot be used for this purcha
err.purchase.paymentMethodNotFound=Payment method not found
err.purchase.paymentMethodNotSet=Payment method not set on plan
err.purchase.planNotFound=Account Plan not found
err.purchase.priceInvalid=Price is not valid
err.purchase.tokenNotFound=Invite code not found
err.purchase.tokenExpired=Invite code has expired
err.purchase.tokenUsed=Invite code has already been used


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit 5c987a87cbb00e7b750300feeac19e293dbafa3c
Subproject commit cbf7f47ad1115f634af625edd7b6c96808e49f90

Loading…
取消
儲存