1

Coldfusion で Stripe API の外部ラッパーを実装しています。

以下に示すように、私が呼び出している関数の 1 つは、「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 引数に渡していますが、「タイムスタンプの型ではない」というエラーが表示されます。

関数呼び出しを適切に機能させるには、この日付までに何をする必要がありますか?

ありがとう

更新: 完全な機能が追加されました:

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);
}
4

1 に答える 1

8

timestampはネイティブのCF データ型ではないため、CF は timestamp.cfc という名前の CFC を見つけようとしています。

dateこの場合、あなたはただ意味があると思います。

于 2012-09-05T09:47:18.100 に答える