AutoShip Daily Run and Retry Rules

The AutoShip Daily Run is an automated job that triggers AutoShip orders to process at a particular time of day—ideally a time of low impact.



AutoShip DailyRun

As a part of the Platform launch and setting up AutoShips, clients submit a request to Customer Care (via [email protected]) to turn on the AutoShip DailyRun. This starts a daily process that runs AutoShips at whatever time you specify. Most will choose a low-impact time like 3 AM each day.

For custom DailyRun logic, use the DailyRun Hook.

Hook name: DirectScale.Disco.Extension.Hooks.Autoships.DailyRun

public class DailyRun : IHook<DailyRunHookRequest, DailyRunHookResponse>
{
  public DailyRun() { }
    
  public DailyRunHookResponse Invoke(DailyRunHookRequest request, Func<DailyRunHookRequest, DailyRunHookResponse> func)
  {
    return func(request);
  }
}
services.AddTransient<IHook<DailyRunHookRequest, DailyRunHookResponse>, DailyRun>();

Is there a way to set a commission expiration date for people who do not create a payment merchant account within a certain time period (three months)?

DirectScale doesn't have a way built-in, but this is something you could check during the Daily Run.

  1. Implement the Daily Run Hook
  2. Set anyone without an account, who is older than three months, to expired.


AutoShip Retry Rules

You develop specific AutoShip retry rules. If for any reason, an AutoShip should fail, you’ll need to have rules in place so the system knows how to handle it.

Using the ShouldRetryAutoshipOrder Hook, you can set the AutoShip retry rules based on your requirements.

Hook name: DirectScale.Disco.Extension.Hooks.Autoships.ShouldRetryAutoshipOrder

public class ShouldRetryAutoshipOrder : IHook<ShouldRetryAutoshipOrderHookRequest, ShouldRetryAutoshipOrderHookResponse>
{
  public ShouldRetryAutoshipOrder() { }
  
  public ShouldRetryAutoshipOrderHookResponse Invoke(ShouldRetryAutoshipOrderHookRequest request, Func<ShouldRetryAutoshipOrderHookRequest, ShouldRetryAutoshipOrderHookResponse> func)
  {
    return func(request);
  }
}
services.AddTransient<IHook<ShouldRetryAutoshipOrderHookRequest, ShouldRetryAutoshipOrderHookResponse>, ShouldRetryAutoshipOrder>();
{
  "RetryDate": "0001-01-01T00:00:00",
  "Order": {
    "BackofficeId": "string",
    "LastModifiedDate": "0001-01-01T00:00:00",
    "BillPhone": "string",
    "CommissionDate": "0001-01-01T00:00:00",
    "AssociateId": 0,
    "Email": "string",
    "InvoiceDate": "0001-01-01T00:00:00",
    "LocalInvoiceNumber": 0,
    "Name": "string",
    "OrderDate": "0001-01-01T00:00:00",
    "OrderType": 0,
    "OrderNumber": 0,
    "SpecialInstructions": "string",
    "Status": "string",
    "TotalBonus": 0.0,
    "TotalCost": 0.0,
    "TotalCV": 0.0,
    "TotalQV": 0.0,
    "Void": false,
    "BillAddress": {
      "Id": 0,
      "AddressLine1": "string",
      "AddressLine2": "string",
      "AddressLine3": "string",
      "City": "string",
      "State": "string",
      "PostalCode": "string",
      "CountryCode": "string"
    },
    "PartyId": 0,
    "IsPaid": false,
    "IsShipped": false,
    "Custom": {
      "Field1": "string",
      "Field2": "string",
      "Field3": "string",
      "Field4": "string",
      "Field5": "string"
    },
    "CanRerun": false,
    "LineItems": [],
    "Packages": [],
    "Totals": [],
    "Payments": [],
    "OrderCoupons": [],
    "USDSubTotal": 0.0,
    "USDTotal": 0.0,
    "IsMoveable": {
      "IsOrderMovable": false,
      "MessageType": 0,
      "Message": "string"
    }
  },
  "Autoship": {
    "AutoshipId": 0,
    "AssociateId": 0,
    "ShipAddress": {
      "Id": 0,
      "AddressLine1": "string",
      "AddressLine2": "string",
      "AddressLine3": "string",
      "City": "string",
      "State": "string",
      "PostalCode": "string",
      "CountryCode": "string"
    },
    "StartDate": "0001-01-01T00:00:00",
    "Frequency": 0,
    "LastProcessDate": "0001-01-01T00:00:00",
    "NextProcessDate": "0001-01-01T00:00:00",
    "LastChargeAmount": 0.0,
    "Status": "string",
    "ShipMethodId": 0,
    "PaymentMethodId": "string",
    "PaymentMerchantId": 0,
    "Custom": {
      "Field1": "string",
      "Field2": "string",
      "Field3": "string",
      "Field4": "string",
      "Field5": "string"
    },
    "AutoshipType": 0,
    "LineItems": [
      {
        "ItemId": 0,
        "Quantity": 0.0,
        "Cost": 0.0,
        "Disabled": false,
        "ExtendedPrice": 0.0,
        "ExtendedOriginalPrice": 0.0,
        "ExtendedBonus": 0.0,
        "ExtendedCV": 0.0,
        "ExtendedQV": 0.0,
        "ExtendedRewardPoints": 0.0,
        "ExtendedCost": 0.0,
        "ProductName": "string",
        "Description": "string",
        "Specifications": "string",
        "LanguageCode": "string",
        "SKU": "string",
        "Category": {
          "Id": 0,
          "Name": "string",
          "CategoryTranslations": [],
          "Description": "string",
          "DisplayIndex": 0.0,
          "ImageUrl": "string",
          "ParentId": 0,
          "ProductLineId": 0,
          "ShortDescription": "string",
          "StoreIds": [],
          "HasChildren": false
        },
        "ChargeShipping": false,
        "Height": 0.0,
        "Image": "string",
        "Length": 0.0,
        "LengthUOM": "string",
        "MPN": "string",
        "PackCount": 0.0,
        "PackageGroupId": 0,
        "TaxClassId": 0,
        "UnitOfMeasure": "string",
        "UPC": "string",
        "Weight": 0.0,
        "WeightUOM": "string",
        "Width": 0.0,
        "FlagBirthDefects": false,
        "HasKitGroups": false,
        "FlagCancer": false,
        "PriceGroup": 0,
        "Custom": {
          "Field1": "string",
          "Field2": "string",
          "Field3": "string",
          "Field4": "string",
          "Field5": "string"
        },
        "Images": [
          {
            "Description": "string",
            "Path": "string"
          }
        ],
        "Prices": [
          {
            "GroupId": 0,
            "Price": 0.0,
            "PriceCurrency": "string",
            "OriginalPrice": 0.0,
            "Bonus": 0.0,
            "CV": 0.0,
            "QV": 0.0,
            "RewardPoints": 0.0
          }
        ],
        "Options": [
          {
            "OptionId": 0,
            "Option": "string"
          }
        ],
        "ItemOptions": [
          {
            "OptionId": 0,
            "Option": "string",
            "OptionType": 0,
            "Values": [
              {
                "Option": "string",
                "SkuExt": "string"
              }
            ]
          }
        ],
        "Languages": [
          {
            "Description": "string",
            "LanguageCode": "string",
            "ProductName": "string",
            "SEOKeywords": "string",
            "Specifications": "string"
          }
        ],
        "OptionsMap": [
          {
            "Key": "string",
            "Checked": false,
            "ItemId": 0,
            "Image": "string",
            "ExtSku": "string"
          }
        ],
        "HasOptions": false,
        "Price": 0.0,
        "PriceCurrency": "string",
        "OriginalPrice": 0.0,
        "Bonus": 0.0,
        "CV": 0.0,
        "QV": 0.0,
        "RewardPoints": 0.0,
        "CouponsBeingUsed": 0,
        "PriceGroups": [
          0
        ]
      }
    ],
    "FrequencyString": "string",
    "TotalCV": 0.0,
    "TotalQV": 0.0,
    "CurrencyCode": "string",
    "SubTotal": 0.0
  }
}
{
  "RetryRule": {
    "Charge": false,
    "AssociateStatusId": 0,
    "SendEmail": null,
    "Cancel": null,
    "NotificationCount": null
  }
}

This Hook looks at all orders attached to an AutoShip that haven’t been paid for:

  • Because they’re using some delayed payment
  • Or, The payment method had insufficient funds
  • Etc.

Many companies will have different rules regarding this. For example, try it every other day for three tries, then try one more time on the month's last day. Or, you can set it to try every five days for the next two months. The default range is the day after and the next two days from that.

You can revise these rules at any time.



DailyRun API Endpoint

The API endpoint /command/Corporate.Company.DailyRun calls the same Client Extension DailyRun that the DailyRun Hook overrides.

The request object has two properties:

{
     "filler": 0,
     "CommandKey": "string"
}

The filler request property does not need to be populated. It is not used. When testing in Swagger, the CommandKey does not need to be populated.


Related Docs
Did this page help you?