I'm implementing the Inline Checkout from Bambora. The authorization step works without any problem. But when it comes to capturing the payment I always get the error Transaction not found
.
This is what I do:
const options = {
headers: { Authorization: `Basic ${ apiKey }` },
};
const { payload } = {
amount
};
const { data } = await axios.post(`https://transaction-v1.api-eu.bambora.com/transactions/${ txnid }/capture`, payload, options);
I also tried making the request with included transactionoperations
:
const options = {
headers: { Authorization: `Basic ${ apiKey }` },
};
const { payload } = {
amount,
transactionoperations: [{ id: txnid }],
};
const { data } = await axios.post(`https://transaction-v1.api-eu.bambora.com/transactions/${ txnid }/capture`, payload, options);
I get the same error when trying to get transaction information:
const options = {
headers: { Authorization: `Basic ${ apiKey }` },
};
const { data } = await axios.get(`https://merchant-v1.api-eu.bambora.com/transactions/${ txnid }`, options);
As I understand the documentation I'm doing everything right, but I can't get it to work.
After looking at Bamboras own implementation in PHP I can't see any issues with my code.
After looking at the Report Dashboard for a specific order in the URL doesn't match the ID I have saved in the database. The value of txnid
returned on the Inline Checkout Authorize event doesn't seem to be accurate.
I was way off of where the problem was in our code. With help from the Bambora support and @Evelijn nudging in the right direction the problem is solved.
When sending the txnid
from the client to the server the validation ensured that the value only contained digits. What I had missed was that it also changed it to a Number type.
The txnid
is a String of 18 digits, javascript can handle numbers that are at most 17 digits big. When txnid
was changed to a Number the last digit would be rounded to 0.
So 123456789012345678
would become 123456789012345680
.
When I changed the validation not to cast txnid
to a Number everything works.