所以这是我要嵌套一个div元素(一个paypal button)和一个button元素(提交表单的rails元素)的情况,所以在单击时,在paypal成功交易后才提交表单。想法如何也重定向到贝宝付款页面。###如果我沿错误的路径###,请以其他任何方式告诉我。这是代码
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
export const Page = ({ title }) => (
<div className="App">
<div className="App-header">
<h2>{title}</h2>
</div>
<p className="App-intro">
This is the {title} page.
</p>
<p>
<Link to="/">Home</Link>
</p>
<p>
<Link to="/about">About</Link>
</p>
<p>
<Link to="/settings">Settings</Link>
</p>
</div>
);
export const About = (props) => (
<Page title="About"/>
);
export const Settings = (props) => (
<Page title="Settings"/>
);
export const Home = (props) => (
<Page title="Home"/>
);
答案 0 :(得分:1)
如果表单提交取决于贝宝交易成功,则仅在onApprove回调上批准交易后才提交表单。像这样:
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
yourForm = document.getElementById('id_of_the_form');
Rails.fire(yourForm, 'submit');
});
}