Lua无效的HTTP请求 - Stripe API

我正在尝试编写一个模块与Stripe的付款API通信。然而,我遇到了麻烦。我一直收到此响应:“"Your client sent an invalid HTTP request."”我已经尝试了我能想到的所有可能性,甚至包括 b64,但似乎什么都不起作用。有什么想法吗?

这是我的代码:

description = "test"
email = "test@email.com"
api_key = "pk_test_4PRPYs3eM4HQx0ZMBOubGjoy" -- 不用担心,这是公共测试密钥;)
cardNumber = "4242 4242 4242 4242"
fullName = "Test Name"
expMonth = "07"
expYear = "2016"
cvc = "432"

-------------------------------------------------- --------

firstCard = {["number"] = cardNumber,["exp_month"] = expMonth,["exp_year"] = expYear,["cvc"] = cvc,["name"] = fullName}

StripeNewRegister = function()
    local json = require“json”
    print("test")
    newCustomer = {["email"] = email,["description"] = description} - ["card"] = firstCard}

    print(newCustomer)

    local function networkListenereventif(event.isError)then
            print(“网络错误!)
        秒
        其他
            打印(“响应:”..event.response)
            local data1 = event.response
            local resp1 = json.decode(data1)
            print(resp1)
            local error = resp1.error
            如果错误~ = nil则
                从1到#resp1.error do的
                    print(resp1.error[i].type)
                    print(resp1.error[i].message)
                秒
            结尾
            如果错误== nil then
                --打印功能
            结尾
        结束
    end

    local key = {["Bearer"] = api_key}

    local headers = {
        ["Authorization Bearer"] = api_key
    }

    local params = {}
    参数标题=标题
    参数身体= json .encode(newCustomer)

    print(“params.body:”..params.body)

    network.request(“https://api.stripe.com/v1/customers”,“POST”,networkListener,params)

结束

StripeNewRegister()
点赞