无卡复出
对GoCardless Droitin的取出流程进行反应绑定.
安装
以 npm 为单位 :
npm install --save @gocardless/react-dropin
用纱线:
yarn add @gocardless/react-dropin
实例
此库导出Resact chook 函数, 您可以用来触发 GoCardless Dropin的例子.
举个简单的例子 App 想要创建 Billing 请求流程
ID通过它的后端 API,然后提供 DropinButton 支付者可以点击
触发"滴滴".
import React, { useCallback, useState } from "react";
import {
useGoCardlessDropin,
GoCardlessDropinOptions,
GoCardlessDropinOnSuccess,
} from "@gocardless/react-dropin";
// Display a button that opens the Dropin on click, starting a checkout
// flow for the specified Billing Request Flow.
const DropinButton = (options: GoCardlessDropinOptions) => {
const { open } = useGoCardlessDropin({ ...options });
return (
<button type="button" onClick={() => open()}>
Start Dropin for <code>{options.billingRequestFlowID}</code> in{" "}
<code>{options.environment}</code>
</button>
);
};
// Example checkout flow, where we create a Billing Request Flow ID by talking
// with our backend API.
const App: FunctionComponent = () => {
const [flowID, setFlowID] = useState<string | null>(null);
// Build your backend with an API endpoint that:
//
// 1. Creates a Billing Request for the resources you wish to create
// 2. Create a Billing Request Flow against (1)
// 3. Return the ID from (2)
//
// See an example of this at Taking an Instant Bank Payment:
// https://developer.gocardless.com/getting-started/billing-requests/taking-an-instant-bank-payment/
React.useEffect(() => {
async function createFlow() {
// Expecting a JSON body like:
// {
// "flow_id": "BRF123456"
// }
let response = await fetch("/api/flows", {
method: "POST",
});
const { flow_id } = await response.json();
setFlowID(flow_id);
}
createFlow();
}, []);
// Only show the button once we have a Billing Request Flow ID
return flowID === null ? (
<div className="loader"></div>
) : (
<DropinButton billingRequestFlowID={flowID} environment={"live"} />
);
};
故事书
查看故事书流以查看 <GoCardlessDropinButton /> 行动中.
您可以使用"故事本"旋钮配置 Billing 请求流程ID,来自
您可以创建您的 Dropin 实例.
故事被运用到 gh-pages 该repo的分支,并托管于
https://gocardless.github.io/ react-dropin/ 页面存档备份,存于互联网档案馆。 。 。 .
出版
CircleCI的配置是为了为我们发布变化,通过构建的管道.
要触发新软件包版本 :
- 更新
package.json带有新版本编号( ie, v1. 0.0) - 推动这个承诺
master,则 剪切新发行 以 GitHub 为单位 带有匹配释放的标签名( ie, v1. 0.0)
这将触发 CI 管道,新的软件包版本将出现在 马上就好.