我正在使用Stripe和Checkout来创建付款表单,我希望能够使用Checkout的真棒javascript库,但我还想将表单提交从普通的POST更改为AJAX POST.
所以我尝试在你应该拥有的表单元素中添加一个处理程序,但是我的控制台行从未被触发过,因此它不会使用给定的表单提交.
然后我尝试查看触发叠加时引发的代码.这有点令人困惑,我只是想知道是否还有其他人能够解决这个问题,或者它是否因为安全问题而变得困难?
// Stripe plugin
<form id="payment_form" method='post' action="{{url_for('process_payment')}}">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="test key">
</script>
</form>
// Form submit handler
$(document).ready(function(){
$("#payment_form").submit(function(e) {
console.log("Processing...");
ajax_payment();
return false;
});
});
Run Code Online (Sandbox Code Playgroud) 让我首先确认这不是重复(因为那里发布的答案没有解决我的问题).这篇文章基本上是我的确切问题:Capybara无法在Stripe模式中找到表单字段来填充它们.
这是我的水豚规格:
describe 'checkout', type: :feature, js: true do
it 'checks out correctly' do
visit '/'
page.should have_content 'Amount: $20.00'
page.find('#button-two').click_button 'Pay with Card'
Capybara.within_frame 'stripe_checkout_app' do
fill_in 'Email', with: 'example@example.com'
fill_in 'Name', with: 'Nick Cox'
fill_in 'Street', with: '123 Anywhere St.'
fill_in 'ZIP', with: '98117'
fill_in 'City', with: 'Seattle'
click_button 'Payment Info'
fill_in 'Card number', with: '4242424242424242' #test card number
fill_in 'MM/YY', with: '02/22'
fill_in 'CVC', with: '222'
click_button 'Pay'
end
page.should have_content 'Thanks'
end
end
Run Code Online (Sandbox Code Playgroud)
该规范中的文字是我最近的尝试. …
在某些形式中,Chrome自动填充功能会提示您使用信用卡自动填充功能.
编辑:添加屏幕截图.这与浏览器自动完成功能不同.您之前无需以相同的形式输入值.

我应该如何编写HTML表单,以便浏览器将其检测为信用卡字段并触发此行为?
使用条纹形式的一个例子是理想的.
我试图为我的Rails 3.2应用程序为Stripe的checkout.js [ https://checkout.stripe.com/checkout.js ] 编写集成测试.
手动测试(使用Stripe的测试键)时,条纹检查对我来说正常工作,但我无法让Capybara检测fill_in到Stripe checkout iframe模式中的电子邮件字段.
我正在使用无头javascript的poltergeist,虽然也用capybara-webkit和甚至selenium测试了同样的问题.
我要测试的是完整的订阅注册流程,以显示新用户在Stripe中输入付款详细信息后可以创建订阅者帐户 - 但我无法通过Stripe checkout弹出窗口.
这是我的before .. do:
describe "show Stripe checkout", :js => true do
before do
visit pricing_path
click_button 'plan-illuminated'
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
Capybara.within_frame stripe_iframe do
fill_in "email", :with => "test-user@example.com"
fill_in "billing-name", :with => "Mr Name"
fill_in "billing-street", :with => "test Street"
fill_in "billing-zip", :with => 10000
fill_in "billing-city", :with => "Berlin"
click_button "Payment Info"
end
end
it …Run Code Online (Sandbox Code Playgroud) testing ruby-on-rails capybara ruby-on-rails-3 stripe-payments
我目前正试图将Stripe整合到一个小网站中.
我可以在Firebug中看到,此get请求正确运行
https://checkout.stripe.com/api/bootstrap?locale=en&key=******************
Run Code Online (Sandbox Code Playgroud)
然而,另一个请求返回NetworkError:400 Bad Request
https://checkout.stripe.com/api/color?image_url=https%3A%2F%2Fwww.*******.com%2Fassets%2Fimages%2Flayout-images%2Fstripe-logo.jpg&key=
Run Code Online (Sandbox Code Playgroud)
在浏览器中打开URL时的JSON响应是
{
"error": {
"type": "invalid_request",
"message": "Unable to perform color detection."
}
}
Run Code Online (Sandbox Code Playgroud)
消息上的一些帖子表明它不应该担心.但我还没有找到任何关于具体错误的信息.有没有人知道导致这个错误的原因是什么?
我正在尝试创建使用条带支付的非常简单的示例.这是我的PHP文件
// Create a Stripe client
var stripe = Stripe('pk_test_XSHE4IYLLy9qCPe7lW7pK4ZE');
// Create an instance of Elements
var elements = stripe.elements();
// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a'
}
}; …Run Code Online (Sandbox Code Playgroud)我需要在自定义表单中添加一个额外的字段,我想添加信用卡的名称.
我试着用以下方式:
var cardNameElement = elements.create('cardName', {
style: style
//, placeholder: 'Custom card number placeholder',
});
cardNameElement.mount('#card-name-element');
<div id="card-name-element" class="field"></div>
Run Code Online (Sandbox Code Playgroud)
但这不起作用,在其文档中只允许执行这些程序,仅验证四个元素或数据:cardNumber,cardExpiry,cardCvc,postalCode.
如何添加信用卡的名称并使用它进行验证 stripe.js
我的代码:
var stripe = Stripe('pk_test_6pRNASCoBOKtIshFeQd4XMUh');
var elements = stripe.elements();
var style = {
base: {
iconColor: '#666EE8',
color: '#31325F',
lineHeight: '40px',
fontWeight: 300,
fontFamily: 'Helvetica Neue',
fontSize: '15px',
'::placeholder': {
color: '#CFD7E0',
},
},
};
var cardNumberElement = elements.create('cardNumber', {
style: style
//, placeholder: 'Custom card number placeholder',
});
cardNumberElement.mount('#card-number-element');
var cardExpiryElement = elements.create('cardExpiry', { …Run Code Online (Sandbox Code Playgroud)我想根据我指定的日期范围获取费用清单(交易),即我指定的开始日期和结束日期之间的所有交易.
但在CHARGES API中,我看不到任何开始日期和结束日期参数.
我怎么能得到这个?
提前致谢.
我正在使用Stripe的默认表单进行付款处理.如何添加优惠券字段?我已经创建了优惠券,但我不确定如何处理优惠券代码.
<form class="efocus" action="form_process.php?source=payment" method="post">
<input type="hidden" name="fee" value="1795">
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-amount=1795 data-description="Month-to-month Package">
</script>
</form>
Run Code Online (Sandbox Code Playgroud)
这是可能的还是我需要构建一个自定义表单?
我想使用Stripe更新客户的默认卡.
在update customerAPI文档中,不清楚要为card参数提供什么.
在PHP中,我尝试设置card基于这样的retrieve card方法:
$customer->card=$card['id']
但这似乎不起作用.也没有像这样使用令牌:
$customer->source=$_POST['stripe_token]
所以我有点不知所措.思考?