[英]PayPal React Integration not creating transaction
I'm trying to integrate with PayPal checkout using the react library (@paypal/react-paypal-js), the response of the payment is successful, but when I use the live client id it doesn't bill from my credit card.我正在尝试使用反应库(@paypal/react-paypal-js)与 PayPal 结帐集成,付款响应成功,但是当我使用实时客户端 ID 时,它不会从我的信用卡中计费。
import { api } from "../services/api";
import { PayPalButtons, PayPalScriptProvider } from "@paypal/react-paypal-js";
export default function Pagamento() {
function createOrder(data, actions) {
return actions.order.create({
intent: "CAPTURE",
purchase_units: [
{
amount: {
value: "2.00",
},
},
],
});
}
function onApprove(data, actions) {
console.log(data);
const paymentID = data.paymentID;
const orderID = data.orderID;
const payerID = data.payerID;
api
.get("update_pacientes", {
params: {
username: username,
column: "status",
paymentID: paymentID,
orderID: orderID,
payerID: payerID,
},
})
.then((response) => {
console.log(response);
// , location.reload();
});
}
return (
<div id="pagamento_wrapper">
<PayPalScriptProvider
options={{
"client-id": OMMITED FOR SECURITY REASONS
,
currency: "BRL",
}}
>
<PayPalButtons
style={{ color: "blue", shape: "pill", label: "pay", height: 40 }}
createOrder={(data, actions) => createOrder(data, actions)}
onApprove={(data, actions) => onApprove(data, actions)}
/>
</PayPalScriptProvider>
</div>
</div>
);
}
Your onApprove
function is not capturing the order after the payer approves it, so there is no PayPal transaction created.您的
onApprove
function 在付款人批准后未捕获订单,因此没有创建 PayPal 交易。
Since from inside createOrder
you used actions.order.create
to create on the client side, you should also capture on the client side via actions.order.capture
(from inside onApprove
)由于从
createOrder
内部您使用actions.order.create
在客户端创建,您还应该通过actions.order.capture
在客户端捕获(从onApprove
内部)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.