Skip to content

Subscription_Insert#


Description#

This function creates a new subscription in Miva.

Request Parameters#

Parameter
Type Description
customer_id
edit_customer
customer_login
Number
String
String
The customer id
The customer login
The customer login
paymentcard_id Number The id of the saved payment card linked to the subscription
product_id Number The id number of the product
productsubscriptionterm_id Number Subscription term id for the product
address_id Number Address id for the subscription
ship_id Number Shipping id for the subscription
ship_data String The name of the shipping option for the subscription
quantity Number Product quantity for the subscription
nextdate Number Datetime string for the next subscription fulfillment date
template_codes String Template codes for product
attribute_codes String Attribute codes for product
values String Product values

Response Parameters#

Parameter
Type Description
success Boolean Boolean value indicating if the api request was successful
id Number The subscription id
order_id Number Order id associated with the customer subscription
line_id Number Line id of the subscription
cust_id Number Customer id for the subscription
custpc_id Number The id of the payment card linked to the subscription
product_id Number Product id for the subscription item
subterm_id Number Id number for the subscription term
addr_id Number Address id of the subscription
ship_id Number Line id of the subscription
ship_data String The name of the shipping option for the subscription
quantity Number Product quantity for the subscription
termrem Number Number of terms remaining for the subscription
termproc Number Number of terms processed on the subscription
firstdate Object Subscription first fulfillment date
status String Subscription status
message String Subscription status message
tax Number Tax for the subscription
formatted_tax String Currency formatted subscription tax
shipping Number Shipping total for the subscription
formatted_shipping String Currency formatted shipping total
subtotal Number Subscription subtotal
formatted_subtotal String Currency formatted subtotal
total Number Subscription total price
formatted_total String Currency formatted subscription total price
authfails Number Number of times payment authorization has failed
lastafail Object Time of the last failed authorization attempt
nextdate Object Time of the next authorization attempt
cncldate Object Time of the subscription authorization conclude
options Object Array of objects containing options.

date Object#

The data structure of the firstdate object below is repeated in lastdate, nextdate, cncldate, lastafail.

Parameter
Type Description
time_t Number Unix timestamp
year Number Year component
month Number Month component
day Number Day component
hour Number Hour component
minute Number Minute component
second Number Second component
timezone Number Timezone offset in seconds

options Object#

Parameter
Type Description
subscrp_id String Subscription ID
templ_code String Attribute Template code
attr_code String Attribute Code
value String Option value

Example Request#

{
    "Store_Code": "{{Store_Code}}",
    "Miva_Request_Timestamp": "{{$timestamp}}",
    "Function": "Subscription_Insert",
    "Customer_ID": 2,
    "PaymentCard_ID": 0,
    "Product_ID": 9,
    "ProductSubscriptionTerm_ID": 1,
    "Address_ID": 2,
    "Ship_ID": 140,
    "Ship_Data": "overnight",
    "Quantity": 2,
    "NextDate": "2022-03-11T00:00:00-00:00",
    "Template_Codes": "",
    "Attribute_Codes": "",
    "Values": ""
}

Example Response#

{
    "success": 1,
    "data": {
        "id": 5,
        "order_id": 0,
        "line_id": 0,
        "cust_id": 2,
        "custpc_id": 0,
        "product_id": 9,
        "subterm_id": 1,
        "addr_id": 2,
        "ship_id": 140,
        "ship_data": "overnight",
        "quantity": 2,
        "termrem": 0,
        "termproc": 0,
        "firstdate": {
            "time_t": 1646974800,
            "year": 2022,
            "month": 3,
            "day": 11,
            "hour": 0,
            "minute": 0,
            "second": 0,
            "timezone": -5
        },
        "status": "A",
        "message": "",

        "tax": 3.51,
        "formatted_tax": "$3.51",
        "shipping": 15.0,
        "formatted_shipping": "$15.00",
        "subtotal": 36.0,
        "formatted_subtotal": "$36.00",
        "total": 54.51,
        "formatted_total": "$54.51",
        "authfails": 0,
        "lastafail": {
            "time_t": 0,
            "year": 1969,
            "month": 12,
            "day": 31,
            "hour": 19,
            "minute": 0,
            "second": 0,
            "timezone": -5
        },
        "options": [
            {
                "subscrp_id": 37,
                "templ_code": "",
                "attr_code": "size",
                "value": "small"
            },
            {
                "subscrp_id": 37,
                "templ_code": "",
                "attr_code": "color",
                "value": "red"
            }
        ]
    }
}

Error Responses#

Error Code Error Message Error Description
MER-SUB-JSN-00060 Subscription not found Subscription not found