Coldfusion时间戳数据类型错误

时间:2012-09-05 09:37:33

标签: coldfusion stripe-payments

我正在为Coldfusion中的Stripe API实现一个外部包装器。

我调用的函数之一采用“timestamp”类型的参数,如下所示:

public struct function updateSubscription(required string customerid, required string planid, string coupon='', boolean prorate=true, timestamp trial_end, any card) 
{
...
}

我将一个有效的日期(已测试且IsDate()导致“YES”)传递给trial_end参数,但它给出了“not of type timestamp”错误。

为了让函数调用正常工作,我需要对此日期做些什么?

由于

更新:已添加完整功能:

public struct function updateSubscription(required string customerid, required string planid, string coupon='', boolean prorate=true, timestamp trial_end, any card) {

    local.HTTPService = createHTTPService('POST');
    local.HTTPService.addParam(type='formfield',name='plan',value=arguments.planid);

    local.HTTPService.setUrl(getBaseUrl() & 'customers/' & arguments.customerid & '/subscription');
    if (Len(Trim(arguments.coupon))) {
        local.HTTPService.addParam(type='formfield',name='coupon',value=Trim(arguments.coupon));
    }
    local.HTTPService.addParam(type='formfield',name='prorate',value=arguments.prorate);
    if (StructKeyExists(arguments,'trial_end') AND IsDate(arguments.trial_end)) {
        loca.intUTCDate = timeToUTCInt(arguments.trial_end);
        local.HTTPService.addParam(type='formfield',name='trial_end',value=local.intUTCDate);
    }
    if (StructKeyExists(arguments,'card') AND isStruct(arguments.card)) {
        local.HTTPService.addParam(type='formfield',name='card[number]',value=arguments.card.number);
        local.HTTPService.addParam(type='formfield',name='card[exp_month]',value=arguments.card.exp_month);
        local.HTTPService.addParam(type='formfield',name='card[exp_year]',value=arguments.card.exp_year);
        if (StructKeyExists(arguments,'card.cvc')) {
            local.HTTPService.addParam(type='formfield',name='card[cvc]',value=arguments.card.cvc);
        }
        if (StructKeyExists(arguments,'card.name') AND Len(Trim(arguments.card.name))) {
            local.HTTPService.addParam(type='formfield',name='card[name]',value=arguments.card.name);
        }
        if (StructKeyExists(arguments,'card.address_line1') AND Len(Trim(arguments.card.address_line1))) {
            local.HTTPService.addParam(type='formfield',name='card[address_line1]',value=Trim(arguments.card.address_line1));
        }
        if (StructKeyExists(arguments,'card.address_line2') AND Len(Trim(arguments.card.address_line2))) {
            local.HTTPService.addParam(type='formfield',name='card[address_line2]',value=Trim(arguments.card.address_line2));
        }
        if (StructKeyExists(arguments,'card.address_zip') AND Len(Trim(arguments.card.address_zip))) {
            local.HTTPService.addParam(type='formfield',name='card[address_zip]',value=Trim(arguments.card.address_zip));
        }
        if (StructKeyExists(arguments,'card.address_state') AND Len(Trim(arguments.card.address_state))) {
            local.HTTPService.addParam(type='formfield',name='card[address_state]',value=Trim(arguments.card.address_state));
        }
        if (StructKeyExists(arguments,'card.address_country') AND Len(Trim(arguments.card.address_country))) {
            local.HTTPService.addParam(type='formfield',name='card[address_country]',value=Trim(arguments.card.address_country));
        }
    } else if (StructKeyExists(arguments,'card')) {
        local.HTTPService.addParam(type='formfield',name='card',value=Trim(arguments.card));
    }
    local.HTTPResult = local.HTTPService.send().getPrefix();

    if (NOT isDefined("local.HTTPResult.statusCode")) {
        throw(type='Stripe',errorcode="stripe_unresponsive", message="The Stripe server did not respond.", detail="The Stripe server did not respond.");
    } else if (left(local.HTTPResult.statusCode,3) NEQ "200") {
        throw(type='Stripe',errorcode=local.HTTPResult.statusCode, message=local.HTTPResult.statuscode, detail=local.HTTPResult.filecontent);
    }
    return deserializeJSON(local.HTTPResult.filecontent);
}

1 个答案:

答案 0 :(得分:8)

timestamp不是本机CF data type,因此CF正在尝试查找名为timestamp.cfc的CFC。

在这种情况下,我认为你的意思是date