Payment Status is Null After Successfully Generate Payment Invoice

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
brix14
Posts: 7
Joined: 07 Feb 2022, 08:44

Payment Status is Null After Successfully Generate Payment Invoice

Post by brix14 » 21 Feb 2022, 14:21

I don't know what are the error, There are times that when I generate Payment Invoice, the 'statuspayment' have value, but sometimes value is null. I Already check if there are errors in the request, but there isn't.

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by aimeos » 22 Feb 2022, 08:19

Hard to say what could be the problem without more information.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

brix14
Posts: 7
Joined: 07 Feb 2022, 08:44

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by brix14 » 04 Mar 2022, 07:37

Regarding on this issue, after I added product to the cart and generate invoice

order.datedelivery: null
order.datepayment: null
order.id: "205"
order.relatedid: null
order.statusdelivery: null
order.statuspayment: null
order.type: "jsonapi"

I the return of generate invoice api is null on the statuspayment, which is I cannot sent an email because it is null.

I review my request from adding product, address, service, cs=type all response is success.

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by aimeos » 06 Mar 2022, 14:24

Do you use the JSON API? Can you reproduce that in the demo?
https://laravel.demo.aimeos.org/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

brix14
Posts: 7
Joined: 07 Feb 2022, 08:44

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by brix14 » 08 Mar 2022, 01:02

Yes, I follow every steps in the json/api to generate the order invoice. And all request in success and no error response.

brix14
Posts: 7
Joined: 07 Feb 2022, 08:44

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by brix14 » 08 Mar 2022, 01:08

The main issue the status.payment is null, so if I run the cron "order/email/delivery order/email/payment" it won't send an email invoice to the user because the status.payment is null.

There is no error why it is null.

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by aimeos » 08 Mar 2022, 06:47

Can you post your code?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

brix14
Posts: 7
Joined: 07 Feb 2022, 08:44

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by brix14 » 14 Mar 2022, 01:29

I am calling those function
saveToBasket()
.then(() => {
createAddressService('payment')
.then(() => {
createDeliveryService()
.then(() => {
createPaymentService()
.then(() => {
setState((prevState) => {
return {
...prevState,
addressModalDisplay: !prevState.addressModalDisplay,
modalDisplay: !prevState.modalDisplay,
loader: !prevState.loader
}
})
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
}








/////////////////////////////////

async function saveToBasket() {
const data = {
data: items.map((val) => {
return {
attributes: {
'product.id': val.id,
quantity: val.quantity,
stocktype: 'default'
}
}
})
//
}
let url = '/jsonapi/basket?id=default&related=product'
let csrfItem = props.location.state.meta.csrf

// save state csrfItem
setCsrfToken(csrfItem)

if (csrfItem) {
// add CSRF token if available and therefore required
var csrf = {}
csrf[csrfItem.name] = csrfItem.value
url +=
(url.indexOf('?') === -1 ? '?' : '&') +
Object.keys(csrf)
.map((key) => key + '=' + csrf[key])
.join('&')
}

await axios
.post(url, JSON.stringify(data), {
'Content-Type': 'application/json'
})
.then(() => {
console.info('@create product to basket')
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
}

async function createDeliveryService() {
// fetch delivery
await axios
.get(
`/jsonapi/service?filter[cs_type]=delivery&include=text,price,media`,
{
'Content-Type': 'application/json'
}
)
.then((res1) => {
console.info('fetch delivery services')

let csrfItem = res1.data.meta.csrf
const urlParams = res1.data.data.filter(function (item) {
// this should be selected config for company
return (
item.type === 'service' &&
item.attributes['service.type'] == 'delivery'
)
})[1]

let url = urlParams.links['basket/service'].href
var params = {
data: [
{
id: 'delivery',
attributes: {
'service.id': urlParams.attributes['service.id']
}
}
]
}

if (csrfItem) {
var csrf = {}
csrf[csrfItem.name] = csrfItem.value
url +=
(url.indexOf('?') === -1 ? '?' : '&') +
Object.keys(csrf)
.map((key) => key + '=' + csrf[key])
.join('&')
}

axios
.post(url, JSON.stringify(params), {
'Content-Type': 'application/json'
})
.then(() => {
console.info('@created delivery service')
// set address for invoice
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
}

async function createAddressService(serviceId) {
let addressUrl = '/jsonapi/basket?id=default&related=address'
let csrfItem = props.location.state.meta.csrf
const params = {
data: [
{
id: serviceId, // or 'delivery'
attributes: {
'order.base.address.company': addressData.company_name, // (optional)
'order.base.address.firstname': addressData.first_name, // (optional)
'order.base.address.lastname': addressData.last_name, // (required)
'order.base.address.address1': addressData.street_address, // (required)
'order.base.address.address2': addressData.building_name, // (required)
'order.base.address.city': addressData.city, // (required)
'order.base.address.postal': addressData.postal_code, // (required)
'order.base.address.state': addressData.prefecture, // (required)
'order.base.address.telephone': addressData.number, // (required)
'order.base.address.email': addressData.email // (required)
}
}
]
}
await axios
.post(`${addressUrl}&_token=${csrfItem.value}`, JSON.stringify(params), {
'Content-Type': 'application/json'
})
.then((response) => {
history.push({ pathname: '/company/cart', state: response.data })
})
}

async function createPaymentService() {
await axios
.get(
`/jsonapi/service?filter[cs_type]=${SERVICE_TYPE}&include=text,price,media`,
{
'Content-Type': 'application/json'
}
)
.then((res1) => {
console.info('fetch payment service')
const urlParams = res1.data.data.filter(function (item) {
// this should be selected config for company
return (
item.type === 'service' &&
item.attributes['service.type'] == SERVICE_TYPE
)
})[0]

let url = urlParams.links['basket/service'].href
let csrfItem = res1.data.meta.csrf
var params = {
data: [
{
id: urlParams.attributes['service.type'],
attributes: {
'service.id': urlParams.attributes['service.id']
}
}
]
}

// create delivery service
if (csrfItem) {
// add CSRF token if available and therefore required
var csrf = {}
csrf[csrfItem.name] = csrfItem.value
url +=
(url.indexOf('?') === -1 ? '?' : '&') +
Object.keys(csrf)
.map((key) => key + '=' + csrf[key])
.join('&')
}

createServicePersistBasket(params, url)
})
}

const deleteBasketCache = (csrfItem) => {
axios
.delete(`/jsonapi/basket?id=default&_token=${csrfItem.value}`)
.then(() => {
console.info('@deleted basket items')
})
}

async function createServicePersistBasket(params, url) {
axios
.post(url, JSON.stringify(params), {
'Content-Type': 'application/json'
})
.then((res2) => {
console.info('create payment service')
let basketUrl = res2.data.links.self.href
let csrfItem = res2.data.meta.csrf
if (csrfItem) {
// add CSRF token if available and therefore required
var csrf = {}
csrf[csrfItem.name] = csrfItem.value
basketUrl +=
(basketUrl.indexOf('?') === -1 ? '?' : '&') +
Object.keys(csrf)
.map((key) => key + '=' + csrf[key])
.join('&')
}
// save basket order
axios
.post(basketUrl, {
'Content-Type': 'application/json'
})
.then((res3) => {
console.info('save order')
setOrderId({
orderId: res3.data.data.attributes['order.base.id'],
token: res3.data.meta.csrf.value
})
})
.catch((err) => {
deleteBasketCache(csrfItem)
handleError(err)
})
})
}



Here is the full code

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: Payment Status is Null After Successfully Generate Payment Invoice

Post by aimeos » 15 Mar 2022, 18:04

The code seems to be correct and the created order item contains a NULL value for order.paymentstatus if the payment service provider you are using and which is configured in the Aimeos backend does not set the payment status value of the order. You can see and example for updating the payment status value in the payment service provider here:
https://aimeos.org/docs/latest/provider ... he-payment

Usually, the payment service providers connect to a payment gateway, which sends a push notification about the payment status update which is processed by the updatePush() method of the Aimeos payment service provider implementation.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply