Ai
2 Star 0 Fork 0

mirrors_sourcegraph/stripe-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
example_test.go 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
Remi Jannel 提交于 2018-05-24 10:02 +08:00 . Remove the currency package
package stripe_test
import (
"log"
stripe "github.com/stripe/stripe-go"
"github.com/stripe/stripe-go/charge"
"github.com/stripe/stripe-go/customer"
"github.com/stripe/stripe-go/invoice"
"github.com/stripe/stripe-go/plan"
)
func ExampleCharge_new() {
stripe.Key = "sk_key"
params := &stripe.ChargeParams{
Amount: stripe.Int64(1000),
Currency: stripe.String(string(stripe.CurrencyUSD)),
}
params.SetSource("tok_visa")
params.AddMetadata("key", "value")
ch, err := charge.New(params)
if err != nil {
log.Fatal(err)
}
log.Printf("%v\n", ch.ID)
}
func ExampleCharge_get() {
stripe.Key = "sk_key"
params := &stripe.ChargeParams{}
params.AddExpand("customer")
params.AddExpand("application")
params.AddExpand("balance_transaction")
ch, err := charge.Get("ch_example_id", params)
if err != nil {
log.Fatal(err)
}
if ch.Application != nil {
log.Fatal(err)
}
log.Printf("%v\n", ch.ID)
}
func ExampleInvoice_update() {
stripe.Key = "sk_key"
params := &stripe.InvoiceParams{
Description: stripe.String("updated description"),
}
inv, err := invoice.Update("sub_example_id", params)
if err != nil {
log.Fatal(err)
}
log.Printf("%v\n", inv.Description)
}
func ExampleCustomer_delete() {
stripe.Key = "sk_key"
customerDel, err := customer.Del("cus_example_id", nil)
if err != nil {
log.Fatal(err)
}
if !customerDel.Deleted {
log.Fatal("Customer doesn't appear deleted while it should be")
}
}
func ExamplePlan_list() {
stripe.Key = "sk_key"
params := &stripe.PlanListParams{}
params.Filters.AddFilter("limit", "", "3")
params.Single = true
it := plan.List(params)
for it.Next() {
log.Printf("%v ", it.Plan().Nickname)
}
if err := it.Err(); err != nil {
log.Fatal(err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_sourcegraph/stripe-go.git
git@gitee.com:mirrors_sourcegraph/stripe-go.git
mirrors_sourcegraph
stripe-go
stripe-go
master

搜索帮助