【发布时间】:2020-11-06 12:32:00
【问题描述】:
我已经建立了一个包含买家和卖家的平台,现在我想整合支付。 我遇到了 Stripe,它使用起来非常简单直接。
但是,我发现缺少文档,因为我想实现 卖方不必创建条带帐户即可获得买方的付款。 Stripe 提供的是他们所称的解决方案;条带连接。
条带连接有三个选项;标准、快速和定制。
对我的特定用例有意义的解决方案是自定义选项。 从documentation,他们有这个代码sn-p;
Stripe.api_key = 'STRIPE_SECRET_KEY'
account = Stripe::Account.create({
country: 'US',
type: 'custom',
requested_capabilities: ['card_payments', 'transfers'],
})
他们写道,以上内容用于创建自定义帐户。坦率地说,没有太多工作要做。 有没有人开发了我正在尝试实现的东西。这方面的帮助真的很有帮助。
我已经实现了 Express Stripe 连接。这是我写的一个助手;
module ApplicationHelper
# Express Stripe url
def stripe_url
"https://dashboard.stripe.com/express/oauth/authorize?response_type=code&client_id=#{ENV["STRIPE_CONNECT_CLIENT_ID"]}&scope=read_write"
end
# Express Stripe Implementation
def stripe_connect_button
link_to stripe_url, class: "stripe-connect" do
content_tag :span, "Connect With Stripe"
end
end
end
我在.erb 文件中写入<%= stripe_connect_button %> 并且它正确呈现。我能够完成整个过程。
我希望有一个类似的方法,但对于 Custom Stripe Connect,因为通过上述实现,我必须创建一个作为卖家的 Stripe 帐户。
我能够基于this 使用curl 测试自定义条带帐户创建
curl 就是这样;
curl https://api.stripe.com/v1/accounts \
-u STRIPE_SECRET_KEY: \
-d country=US \
-d type=custom \
-d "requested_capabilities[]"=card_payments \
-d "requested_capabilities[]"=transfers
上面返回 json,我复制了 id 和 account_id。我在另一个 curl 请求中使用了这个 id;
curl https://api.stripe.com/v1/account_links \
-u STRIPE_SECRET_KEY: \
-d account= #{id} \
-d refresh_url="https://example.com/reauth" \
-d return_url="https://example.com/return" \
-d type=account_onboarding
这会返回看起来像这样的 json;
{
"object": "account_link",
"created": 1594988541,
"expires_at": 1594988841,
"url": "https://connect.stripe.com/setup/c/AUyum7LCw4cV"
}
然后我访问url: https://connect.stripe.com/setup/c/AUyum7LCw4cV 进行入职培训。我已经成功创建了stripe connect custom account。
但是,我想将此流程转换为RubyOnRails。
所以,我的问题是,当Seller 单击按钮 (Connect To Stripe) 时,如何使以下代码 sn-p 启动帐户创建?
Stripe.api_key = STRIPE_SECRET_KEY
account = Stripe::Account.create({
country: 'US',
type: 'custom',
requested_capabilities: ['card_payments', 'transfers'],
})
在Express Stripe Connect 实现中,我有一个url 传递给按钮。有了以上内容,我没有可使用的网址。
【问题讨论】:
-
您在寻找什么却找不到?有用于测试帐户验证的文档:stripe.com/docs/connect/testing-verification。以及使用 Connect 创建付款的示例:stripe.com/docs/connect/destination-charges。你想做什么?
标签: stripe-payments ruby-on-rails-6