在 Rails 5 中,我在订单控制器的 show 操作中创建了一个条带会话。我还有一个更新操作,用于处理用户是否为该订单选择送货或提货。在更新方法中,我尝试通过添加shipping_address_collection属性来更新stripe会话,以便stripe结账页面显示送货地址区域。我设法正确修改条带会话对象,但没有保存它。我有一个 :
NoMethodError (undefined method `save' for #<Stripe::Checkout::Session:0x00007fb60fe5f138>
Run Code Online (Sandbox Code Playgroud)
订单控制器:
def show
@session = Stripe::Checkout::Session.create(
payment_method_types: ['card'],
customer: customer.id,
line_items: line_items_order,
success_url: order_messages_url(@order),
cancel_url: order_failure_message_url(@order)
)
@user.stripe_id = customer.id
@user.save
@order.checkout_session_id = @session.id
@order.save
end
def update
@order = Order.find(params[:id])
@session = Stripe::Checkout::Session.retrieve("#{@order.checkout_session_id}")
if @order.collect_address == nil && @order.shipping_zone != nil
allowed_countries_item = {:allowed_countries => ['GB', 'BE', 'CZ', 'FR', 'DK', 'DE', 'EE', 'IE', 'HR', 'IT', 'CY', 'LV', 'LT', 'LU', 'HU', 'MT', 'NL', 'AT', 'PL', 'RO', 'SI', …Run Code Online (Sandbox Code Playgroud) 我想使用从用户那里获得的卡详细信息作为ConfirmPaymentIntentParams 的参数。不使用 CardInputWidget
txt_pay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("PAY 01 ", "paymentIntentClientSecret " + paymentIntentClientSecret);
CardInputWidget cardInputWidget = findViewById(R.id.cardInputWidget);
PaymentMethodCreateParams params = cardInputWidget.getPaymentMethodCreateParams();
if (params != null) {
ConfirmPaymentIntentParams confirmParams = ConfirmPaymentIntentParams.createWithPaymentMethodCreateParams(params, paymentIntentClientSecret);
stripe.confirmPayment(this, confirmParams);
} catch (JSONException e) {
e.printStackTrace();
Log.e("PAY 02 ", "exception " + e.getMessage());
}
}
});
Run Code Online (Sandbox Code Playgroud) 这是我的快速端点,它是通过Stripe 的 webhook调用的:
\nconst functions = require(\'firebase-functions\');\nconst bodyParser = require(\'body-parser\')\nconst app = require(\'express\')();\nconst stripe = require(\'stripe\')(functions.config().stripe.test.secret);\nconst endpointSecret = functions.config().stripe.test.webhookkey;\n\napp.post(\'/stripe_webhook\', bodyParser.raw({type: \'application/json\'}), async (request, response) => {\n const event = request.body;\n // Only verify the event if you have an endpoint secret defined.\n // Otherwise use the basic event deserialized with JSON.parse\n if (endpointSecret) {\n // Get the signature sent by Stripe\n const signature = request.headers[\'stripe-signature\'];\n try {\n const eventConstruct = stripe.webhooks.constructEvent(\n request.body,\n signature,\n endpointSecret\n );\n } catch (err) …Run Code Online (Sandbox Code Playgroud) node.js express stripe-payments firebase google-cloud-functions
阅读 ngx-stripe API,我找不到在启用“支付”按钮之前验证条带元素的方法(例如,信用卡信息完整)。有人可以提供示例代码片段吗?
谢谢。
我有一个条带结账已启动并正在运行(在测试模式下),并且测试卡运行良好。
现在我不明白为什么成功后它不通过电子邮件发送收据。
我在文档中看到我们需要 1) 允许在仪表板中自动发送电子邮件(已完成)和 2) 在函数中指定客户的电子邮件地址checkout.sessions.create。
目前,stripe 不会发送电子邮件,因为我没有在customer_email字段中指定电子邮件地址checkout.sessions.create。
我不明白的是为什么 stripe 不会自动填写地址并将收据发送给它,因为 stripe checkout 实际上是在“结账”页面上收集电子邮件,如果这有意义的话......
感谢您的帮助。
我正在尝试为用户设置一个按钮来管理他的 Stripe 客户门户及其 Firebase 集成的订阅。
问题,该文档对旧版本的 Firebase (8) 有效,而我正在使用新版本 Firebase 9。
我们在客户端,这就是 React.js。
这是他们调用该函数的js代码(您可以在这里看到完整的代码:https://github.com/stripe-samples/firebase-subscription- payments/blob/master/public/ javascript/app.js):
const functionLocation = 'us-east1';
const functionRef = firebase
.app()
.functions(functionLocation)
.httpsCallable('ext-firestore-stripe-subscriptions-createPortalLink');
const { data } = await functionRef({ returnUrl: window.location.origin });
window.location.assign(data.url);
});
Run Code Online (Sandbox Code Playgroud)
对于 Firebase 9,它应该是这样的:
const functions = getFunctions(firebaseApp)
export async function goToBillingPortal() {
const functionRef = httpsCallable(functions, 'ext-firestore-stripe-subscriptions-createPortalLink');
const { data } = await functionRef({ returnUrl: window.location.origin });
window.location.assign(data.url);
}
Run Code Online (Sandbox Code Playgroud)
控制台显示3个错误:
Access to fetch at 'https://us-central1-xxxxxxxxd76.cloudfunctions.net/ext-firestore-stripe-subscriptions-createPortalLink' from origin 'http://localhost:3000' has been …Run Code Online (Sandbox Code Playgroud) javascript stripe-payments firebase google-cloud-platform google-cloud-functions
我正在使用 Stripe 元素创建订阅,一切都很好...除非数量付款意图为 0 美元
来自 Stripe PaymentIntent 文档:
Run Code Online (Sandbox Code Playgroud)The minimum amount is $0.50 US or equivalent in charge currency.
这里我有使用 stripe 元素创建支付意图的方法
# Here I created an object of type subscription incompletely (@subscription)
# In such a way that the user can enter their credit card and with the help of
# @subscriptions confirm if everything is fine
def checkout
@subscription = Stripe::Subscription.create(
customer: current_user.stripe_customer_id, # stripe customer_id for suscription
items: [{
price: params[:price] # attached price of suscription …Run Code Online (Sandbox Code Playgroud) 我正在为用户开发 Stripe 集成,并为 Stripe 上的年度订阅计划制定一些非常具体的规则:
我的直接猜测是,案例#1 应该可以通过回溯、锚定、不按比例分配和/或试用期的组合来实现,尽管我还没有测试具体细节。
当下一次收费的时间超过 12 个月时,我该如何实施案例#2?据我所知,Stripe 不允许锚定日期比下一个自然计费日期(按年订阅为 12 个月)更远。Trial_end 也不可能晚于锚定日期。
我在后端使用 Laravel Cashier/PHP,但我怀疑它是开箱即用的,所以我只是在寻找用于以任何语言创建订阅的 API 选项。
我有 PaymentMethodPage,如下所示:
import React, { FC, useState } from 'react';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
import {
getClientSecret,
} from '../../api/PaymentCalls/PaymentCalls';
import PaymentMethodSetupForm from './PaymentMethodSetupForm/PaymentMethodSetupForm';
import AddPaymentMethodContainer from './AddPaymentMethodContainer/AddPaymentMethodContainer';
import {
ClientSecretResponse,
} from '../../interfaces/paymentMethod.interface';
const stripePromise = loadStripe(
process.env.REACT_APP_STRIPE_PUBLIC_KEY as string
);
const PaymentMethodPage: FC = () => {
const [enableAddPaymentMethod, setEnableAddPaymentMethod] =
useState<boolean>(false);
const {
data: clientSecretKeyData,
}: UseQueryResult<ClientSecretResponse, ExtendedError> = useQuery<
ClientSecretResponse,
ExtendedError
>('getClientSecret', getClientSecret, {
retry: false,
refetchOnWindowFocus: false, …Run Code Online (Sandbox Code Playgroud) 我目前正在处理我的 Webhooks,但我的 Webhooks 控制器中出现错误。
这是错误:
#<Stripe::SignatureVerificationError: No signatures found matching the expected signature for payload>
No template found for WebhooksController#create, rendering head :no_content
Completed 204 No Content in 1ms (Allocations: 594)
Run Code Online (Sandbox Code Playgroud)
经过一段时间尝试调试这个问题后,我发现它来自这些行,因为我在控制台中看到的最后一个代码是错误和“签名错误”...
rescue Stripe::SignatureVerificationError => e
# Invalid signature
puts "Signature error"
p e
return
end
Run Code Online (Sandbox Code Playgroud)
这是控制器:
class WebhooksController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
def create
payload = request.body.read
sig_header = request.env['HTTP_STRIPE_SIGNATURE']
event = nil
begin
event = Stripe::Webhook.construct_event(
payload, sig_header, Rails.application.credentials[:stripe][:webhook]
)
rescue JSON::ParserError => e
status 400 …Run Code Online (Sandbox Code Playgroud) stripe-payments ×10
javascript ×4
firebase ×2
node.js ×2
reactjs ×2
ruby ×2
android ×1
angular ×1
attributes ×1
checkout ×1
express ×1
java ×1
session ×1
strip ×1
typescript ×1
webhooks ×1