green-school-10640
03/14/2024, 12:17 PMpayment-${Date.now()}
,
order: {
line_items: [
{
name: workflow.selectedMedicine,
quantity: workflow.medicineQuantity,
base_price_money: {
amount: parseFloat(workflow.totalAmount) * 100,
currency: 'GBP'
}
}
]
},
};
try {
const response = await axios.post(${squareApiUrl}/${locationId}/checkouts
, payload, {
headers: {
'Authorization': Bearer ${accessToken}
,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
const checkoutUrl = response.data.checkout.checkout_page_url;
workflow.url = checkoutUrl
const text = `You can complete your payment by clicking on the following link: ${checkoutUrl}`;
await bp.events.replyToEvent(event, { type: 'text', text });
} catch (error) {
console.error('Failed to create checkout session with Square:', error);
const errorMessage = 'Sorry, there was a problem processing your payment. Please try again later.';
await bp.events.replyToEvent(event, { type: 'text', text: errorMessage });
}
};
this is my code please somebody help mebumpy-butcher-41910
03/14/2024, 2:44 PM