-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
helpers/order/order.go:
// CheckBillingOrderStatus returns true if the status of the billing order for
// the provided product order receipt is in the list of provided statuses.
// Returns false otherwise, along with the billing order item used to check the statuses,
// and any error encountered.
func CheckBillingOrderStatus(sess *session.Session, receipt *datatypes.Container_Product_Order_Receipt, statuses []string) (bool, *datatypes.Billing_Order_Item, error) {
service := services.GetBillingOrderItemService(sess)
item, err := service.
Id(*receipt.PlacedOrder.Items[0].Id).
Mask("mask[id,billingItem[id,provisionTransaction[id,transactionStatus[name]]]]").
GetObject()
if err != nil {
return false, nil, err
}
currentStatus := *item.BillingItem.ProvisionTransaction.TransactionStatus.Name
for _, status := range statuses {
if currentStatus == status {
return true, &item, nil
}
}
return false, &item, nil
}The helper name suggests that the status of a Billing_Order is checked, when in-fact:
- only the first order item found is actually inspected
- it checks the provision transaction, not the order status.
Provision transactions are not applicable to all types of orders (e.g., guest upgrade orders do not have provision transactions, resulting in a panic when passing an upgrade order receipt to this helper.
These helpers should either be renamed to indicate that they are to be used to check for provisioning transactions, or updated to check the actual order status.
If the former approach is adopted, some thought should also be given as to whether it is appropriate to stop and return after checking only one order item out of potentially multiple to an order
Metadata
Metadata
Assignees
Labels
No labels