duanpuqi9965 2017-11-15 09:08
浏览 31

无法使用App Engine Golang进行条纹充电

So here is my problem, i have been following the github readme for app engine users in order to implement stripe into my app but the thing is that i can’t make it work as it seems that the http.DefaultTransport and http.DefaultClient are not available in App Engine.

I have seen that in the readme you show us how to initialize the Stripe client with app engine but i cannot find any charge card example so this is why i have come to this implementation.

I am used to this problem, since i have been working with app engine for a long time but for some reason i still get this akward error :

cannot use stripe.BackendConfiguration literal (type stripe.BackendConfiguration) as type stripe.Backend in assignment: stripe.BackendConfiguration does not implement stripe.Backend (Call method has pointer receiver)

Here is the code :

func setStripeChargeClient(context context.Context, key string) *charge.Client {
    c := &charge.Client{}

    var b stripe.Backend
    b = stripe.BackendConfiguration{
        stripe.APIBackend, 
        "https://api.stripe.com/v1",
        urlfetch.Client(context),
    }

    c.Key = key
    c.B = b

    return c
}

Getting the error on that b assignation …

What i can’t figure it out is why this example seems to work all around the web and does not work in my app, if you could please enlighten me on this one, i would be in your debt hahaha

and then calling it this way

stripeClient := setStripeChargeClient(context, "sk_live_key »)

  • 写回答

3条回答 默认 最新

  • doucan8521 2017-11-15 11:15
    关注

    The error message tells you the problem. The stripe.BackendConfiguration type does not implement stripe.Backend interface. The error message also gives the helpful hint that the missing Call method is on the pointer receiver.

    The fix is to use a pointer value:

    b = &stripe.BackendConfiguration{  // note the &
        stripe.APIBackend, 
        "https://api.stripe.com/v1",
        urlfetch.Client(context),
    }
    

    See the specification regarding method sets. The method set of a value receiver does not include the pointer receiver methods.

    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM