在以下代码中使用了 SourceToken 选项,但我在 Visual Studio 中的 CreateCustomerOptions 引用中或按 f12 键找不到 SourceToken 选项。相反,我看到有一个 Source 选项,这两个选项是否相同?需要帮助解决这个问题..
我在这里给出代码链接: https://stripe.com/docs/api/customers/create
是否可以在条纹付款中添加大于 999,999.99 美元的金额?Stripe 不允许我添加超过 999,999.99 美元的金额。
我正在尝试util.promisify以下条纹调用,该调用确实成功了:
stripe.customers.create(
{
description: 'My First Test Customer (created for API docs)',
},
function(err, customer) {
console.log(customer)
}
)
Run Code Online (Sandbox Code Playgroud)
IIUC 这应该有效:
const util = require('util')
const createCustomerPromise = util.promisify(stripe.customers.create)
createCustomerPromise(
{
description: 'My First Test Customer (created for API docs)'
}
).then(customer=>console.log(customer))
Run Code Online (Sandbox Code Playgroud)
但是,当我运行上面的命令时,我得到:
(node:28136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'createResourcePathWithSymbols' of undefined
at /home/ole/Temp/stripetest/node_modules/stripe/lib/StripeMethod.js:27:12
at internal/util.js:286:30
Run Code Online (Sandbox Code Playgroud) 我使用billing_cycle_anchor为第一个订阅月创建按比例收费,以确保在下个月的 1 号收取第一张完整发票。
这部分效果很好,但随后 Stripe 会计算当前发票在(现在)和未来账单日期之间的按比例分配的费率。
在实际向客户的卡扣款之前,如何计算并向客户显示按比例分配的费用?
目前我们使用以下公式来计算当前的按比例分配金额,但并不准确。我们的公式显示3.54 美元,但 Stripe 最终收费3.87 美元
async function getThisMonth(pmtdata) {
let now = Date.now();
var lastday = function(y,m){
return new Date(y, m +1, 0).getDate();
}
let seconds = now / 1000;
let year = new Date().getFullYear();
let month = new Date().getMonth();
if(month <= 10) {
let date = lastday(year,month);
let l1 = 86400 * Number(date);
let l2 = Number(pmtdata.numberPrice) / l1;
let todayD = new Date().getUTCDate();
let l3 = …Run Code Online (Sandbox Code Playgroud) 我在TypeScript应用程序中使用 stripe,并且我读到可以使用如下语言环境设置 stripe 变量:var stripe = Stripe('pk_test', {locale: 'en'});但是如果我想在初始化后更改语言,我无法做到这一点......我想创建一个新的 stripe 变量实例,但库说:IntegrationError: Please use the same instance of 'Stripe' you used to create this Element to create your Source or Token.
那么我需要在运行时更改区域设置吗?
谢谢!
因此,我尝试使用 .NET Core 3.1 将 Stripe 与我的 Asp.NET Core 应用程序集成和测试,每次调用 Webhook 时都会引发异常。
这是控制器代码:
namespace Revoow.Controllers
{
[Route("webhooks")]
[ApiController]
[AllowAnonymous]
public class StripeWebhook : ControllerBase
{
private readonly PaymentService _service;
private readonly string _webhookSecret;
public StripeWebhook(IOptions<StripeOptions> options,
PaymentService service)
{
_service = service;
_webhookSecret = options.Value.WebhookSigningKey;
}
[HttpPost]
public async Task<IActionResult> Post()
{
Debug.WriteLine("Api Post called");
//string json = HttpContext.Request.Body;
var reader = new StreamReader(Request.Body);
reader.BaseStream.Seek(0, SeekOrigin.Begin);
var json = reader.ReadToEnd();
try
{
var stripeEvent = EventUtility.ConstructEvent(json,
Request.Headers["Stripe-Signature"], _webhookSecret);
switch (stripeEvent.Type) …Run Code Online (Sandbox Code Playgroud) 您好,我是在 React 中使用 Stripe 和 Stripe Elements 的新手。我正在使用包 React-stripe-js 和 stripe-js,如https://stripe.com/docs/stripe-js/react中所述。\n我有两个组件,其中一个称为 StripeWrapper :
\nimport React from \'react\';\n\n// stripe\nimport { loadStripe } from \'@stripe/stripe-js\';\nimport { Elements } from \'@stripe/react-stripe-js\';\n\n// components\nimport CheckoutForm from \'./CheckoutForm\';\n\n// stripe load\nconst stripePromise = loadStripe(...);\n\nconst StripeWrapper = () => {\n return ( \n <Elements stripe={ stripePromise } >\n <CheckoutForm /> \n </Elements>\n );\n};\n \nexport default StripeWrapper;\nRun Code Online (Sandbox Code Playgroud)\n这只是一个 HOC,用于用 Elements 组件包装实际的 CheckoutForm,再次如 Stripe 文档中所述。以及实际的表单组件:
\nconst CheckoutForm = () => {\n\n const stripe = useStripe();\n …Run Code Online (Sandbox Code Playgroud) 我希望能够在本地测试用户试用期结束时是否采取了正确的操作。
我设置了 Stripe CLI,并开始监听:
stripe listen --forward-to http://localhost:8000/api/stripe-webhook
Run Code Online (Sandbox Code Playgroud)
当审判结束时,该customer.subscription.updated事件就会发生。
我使用 Stripe CLI 触发此事件:
stripe trigger customer.subscription.updated
Run Code Online (Sandbox Code Playgroud)
在我的服务器端,我可以看到它payload['data']['previous_attributes']包含一个带有foo = null. 当试验结束时,我们应该包含previous_attributes以下内容:{ "status": "trialing"...
我想知道是否可以使用 Stripe CLI 来触发一个模拟用户试用结束的事件(或者甚至只是将 设定为previous_attributes试用结束时在实时环境中发生的类似值的一种方法)?如果可以做到这一点,那么在本地测试当试验结束时会发生适当的操作而不需要推送到类似产品的环境会更容易一些。
有人知道或知道如何向我解释 ngx-stripe 是如何进行订阅的吗?
我尝试用 cURL 做到这一点,但我做不到。
我可以制作令牌卡,但下一步是什么?
我的前端是 Angular,后端是 Laravel。
我知道我需要制作令牌,然后是客户,最后是订阅。但我不知道怎么办,我已经阅读了文档,但我仍然陷入困境
我按照他们的要求开发了年底的最后一个 Stripe 模块,但自从我提出之后,我就没有再在 Stripe 中提供任何描述和客户姓名。
你知道我怎样才能把它再放一次吗?
这是我的 PHP 代码:
try {
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'customer_email' => $email,
'line_items' => [[
'price_data' => [
'product_data' => [
'name' => $custom['item_name'],
'metadata' => [
'pro_id' => $custom['item_name']
]
],
'unit_amount' => (isset($custom['amountTotal']) ? $custom['amountTotal'] : $custom['amount'])*100,
'currency' => $custom['currency_code'],
],
'quantity' => 1,
'description' => $custom['item_name'],
]],
'mode' => 'payment',
'success_url' => $url,
'cancel_url' => $request->cancel,
], ['stripe_account' => $_SESSION['param']->stripeUID]);
}catch(Exception $e) {
$api_error = $e->getMessage();
}
if(empty($api_error) && …Run Code Online (Sandbox Code Playgroud) stripe-payments ×10
asp.net-mvc ×2
c# ×2
javascript ×2
angular ×1
asp.net ×1
es6-promise ×1
laravel ×1
node.js ×1
php ×1
promise ×1
reactjs ×1
typescript ×1