Я попытался искать в Google AI, но не повезло - Это не может дать мне результаты, которые я желаю заранее спасибо
Код: Выделить всё
// PaymentPopup.js
import React, { useState } from 'react';
import { View, TextInput, Button, Modal, Text } from 'react-native';
import axios from 'axios';
const PaymentPopup = ({ visible, onClose }) => {
const [amount, setAmount] = useState('');
const [paymentMethod, setPaymentMethod] = useState('card');
const [cardInfo, setCardInfo] = useState({ number: '', expiry: '', cvv: '' });
const [mobileNumber, setMobileNumber] = useState('');
const handleSubmit = async () => {
const url = ' https://sandbox.lenco.co/access/v2/'; // Replace with actual endpoint.
let data;
if (paymentMethod === 'card') {
data = {
amount,
card: {
number: cardInfo.number,
expiry: cardInfo.expiry,
cvv: cardInfo.cvv,
},
};
} else {
data = {
amount,
mobile: {
number: mobileNumber,
},
};
}
try {
const response = await axios.get(url, data, {
params: {page: '1'},
accept: 'application/json',
headers: { 'Authorization': `Bearer pub-
88dd921c0ecd73590459a1dd5a9343c77db0f3c344f222b9` },
});
console.log('Payment Response:', response.data);
// Handle successful payment
{ catch (error) {
console.error('Payment Error:', error);
// Handle error
}
};
return (
Amount:
Payment Method:
setPaymentMethod('card')} />
setPaymentMethod('mobile')} />
{paymentMethod === 'card' && (
Card Number:
setCardInfo({ ...cardInfo,
number: n })} />
Expiry Date:
setCardInfo({ ...cardInfo,
expiry: e })} />
CVV:
setCardInfo({ ...cardInfo, cvv: c
})} />
)}
{paymentMethod === 'mobile' && (
Mobile Number:
)}
);
};
export default PaymentPopup;
< /code>
Вот где я называю форму: < /p>
const [isPopupVisible, setPopupVisible] = useState(false);
setPopupVisible(true)} />
setPopupVisible(false)} />
< /code>
Я попытался позвонить его из Localhost, но он потерпел неудачу, поэтому я решил сделать песочницу для тестирования, который находится в коде, а также демонстрационный открытый ключ и API < /p>
Вот файл json < /p>
{
"status": true,
"message": "",
"data": [
{
"id": "d7bd9ccb-0737-4e72-a387-d00454341f21",
"initiatedAt": "2024-03-12T07:06:11.562Z",
"completedAt": "2024-03-12T07:14:10.412Z",
"amount": "10.00",
"fee": "0.25",
"bearer": "4276382",
"currency": "ZMW",
"reference": "ref-1",
"lencoReference": "240720004",
"type": "mobile-money",
"status": "successful",
"source": "d94aec3bd31743f9055192f4b43624430e57af1f16d8d9b532d3ef0e07973a89",
"reasonForFailure": null,
"settlementStatus": "settled",
"settlement": {
"id": "c04583d7-d026-4dfa-b8b5-e96f17f93bb8",
"amountSettled": "9.75",
"currency": "ZMW",
"createdAt": "2024-03-12T07:14:10.439Z",
"settledAt": "2024-03-12T07:14:10.496Z",
"status": "settled",
"type": "instant",
"accountId": "68f11209-451f-4a15-bfcd-d916eb8b09f4"
},
"mobileMoneyDetails": {
"country": "zm",
"phone": "0977433571",
"operator": "airtel",
"accountName": "Beata Jean"
},
"bankAccountDetails": null,
"cardDetails": null
}
],
"meta": {
"total": 6,
"pageCount": 1,
"perPage": 100,
"currentPage": 1
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... ntegration