SELECT
cscart_payments.*,
cscart_payment_descriptions.*,
IF (
ISNULL(cscart_addons.status),
"A",
cscart_addons.status
) AS processor_status,
cscart_payment_processors.type AS processor_type,
cscart_payment_processors.processor_script AS processor_script
FROM
cscart_payments
LEFT JOIN cscart_payment_descriptions ON cscart_payment_descriptions.payment_id = cscart_payments.payment_id
AND cscart_payment_descriptions.lang_code = 'tr'
LEFT JOIN cscart_payment_processors ON cscart_payment_processors.processor_id = cscart_payments.processor_id
LEFT JOIN cscart_addons ON cscart_payment_processors.addon = cscart_addons.addon
LEFT JOIN cscart_storefronts_payments AS storefronts_payments ON storefronts_payments.payment_id = cscart_payments.payment_id
WHERE
cscart_payments.status = 'A'
AND (
cscart_payments.usergroup_ids = ''
OR FIND_IN_SET(
0, cscart_payments.usergroup_ids
)
OR FIND_IN_SET(
1, cscart_payments.usergroup_ids
)
)
AND (
storefronts_payments.storefront_id = 1
OR storefronts_payments.storefront_id IS NULL
)
HAVING
processor_status = 'A'
ORDER BY
cscart_payments.position