1
我正在为Coldfusion中的Stripe API实现外部包装。Coldfusion时间戳数据类型错误
一个我正在呼叫的功能采用类型“时间戳”的参数,如图所示:
我传递一个有效的日期(测试则IsDate()导致了“YES”),以trial_end参数,但它给了我一个“不是类型的时间戳”错误。
为了使函数调用正常工作,我需要做些什么?
感谢
UPDATE:全功能增加:
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);
}
基于谷歌搜索我做了我会同意。那么oyu认为这是这个人执行Stripe.cfc的错误吗?这是Stripe中人们推荐的CFC,这让我想自己质疑任何更改。 – Cheeky
我会说这绝对是一个错误。脚本可能在未检查参数类型的系统上进行测试(CF管理员中的一个选项)。类型工作的唯一方式是如果它传递了另一个类型为timestamp(timestamp.cfc)的对象。我不得不看看函数的其余部分,以了解它们是否期望一个简单的值或一个复杂的对象。 –
@Dan Short:我添加了完整的功能。正如你所看到的,它期望一个简单的字符串/日期对象。 – Cheeky