Hello @manhta,
I followed your suggestion but I have some trouble.
Let me show what I did:
1) /lib/vendor/composer/autoload_static.php I added the following code:
'Omnipay\\PagopaBps\\' =>
array(
0 => __DIR__ . '/..' . '/omnipay/pagopabps/src',
),
2) lib/vendor/composer/autoload_psr4.php I added the following code:
'Omnipay\\PagopaBps\\' => array($vendorDir . '/omnipay/pagopabps/src'),
3) /lib/helper.php I added the last line as follow
$gateway_properties = array(
'Stripe' => array('card' => false),
'Stripesca' => array('card' => false),
'PagopaBps' => array('card' => false),
4) /tmpl/stripesca.php I copied the file into plugins\system\ja_payment\tmpl\pagopabps.php and I modified the file for testing purpose removing for the moment the redirect, only to see if it was showing.
<?php
defined('_JEXEC') or die('Restricted access');
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pago PA BPS Checkout</title>
<style>
.wrapper {
text-align: center;
}
.loader {
margin: 0 auto;
border: 10px solid #f3f3f3;
border-radius: 50%;
border-top: 10px solid #3498db;
width: 40px;
height: 40px;
-webkit-animation: spin 2s linear infinite;
/* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="wrapper">
<h2>Ti stiamo reindirizzando al sito PagoPA ...</h2>
<div class="loader"></div>
</div>
</body>
</html>
5) /xml/Stripesca.xml I copied the file into \plugins\system\ja_payment\xml\PagopaBps.xml and this is the content
<fields name="PagopaBps">
<fieldset name="PagopaBPS" label="PAGOPABPS" addfieldpath="/plugins/system/ja_payment/fields/">
<field name="codiceServizio" type="text" default="" label="PAGOPABPS_CODICE_SERVIZIO"
description="PAGOPABPS_CODICE_SERVIZIO_DESC"/>
<field name="logo" type="media" default="" label="PAGOPABPS_LOGO" description="PAGOPABPS_LOGO_DESC"/>
</fieldset>
</fields>
6) /xml/gateway.json I added the following code
"PagopaBps": {
"codiceServizio": "",
"logo": ""
},
7) I duplicated /lib/vendor/omnipay/stripesca in \plugins\system\ja_payment\lib\vendor\omnipay\pagopabps
and changed the code of gateway.php in this way
<?php
namespace Omnipay\PagopaBps;
use Omnipay\Stripe\Gateway as PagopaBPSGateway;
class Gateway extends PagopaBPSGateway
{
public function getName()
{
return 'PagopaBps';
}
public function purchase(array $param = array())
{
try {
$config = array(
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => strtolower($param['currency']),
'unit_amount' => $param['amount'] * 100,
'product_data' => [
'name' => \JText::_('DT_INVOICE') . ': ' . $param['invoice_number'] . ' | ' . $param['description'],
],
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => $param['success'],
'cancel_url' => $param['cancel'],
);
print_r($param);
print_r($config);
ob_clean();
require_once \JPluginHelper::getLayoutPath('system', 'ja_payment', 'pagopabps');
die;
} catch (\Exception $e) {
throw new Exception($e->getMessage(), $e->getCode());
}
}
public function getDefaultParameters()
{
return array(
'codiceServizio' => ''
);
}
}
Then I configured the JA Payment plugin enabling PagopaBps and Paypal Standard only for testing purpose.
At the same time I enabled in the default "Payment option" the same 2 gateways.
Then I insert in the frontend I loggedin as a registered user, and inserted in my Dt register cart an event.
Enabling system debug in Joomla, attached you can see the Session debug output
I don'tt understand why it references to Stripesca instead of PagopaBps, and I don't understand if it is an issue
"config": {
"Stripesca": {
"codiceServizio": "1234567",
"logo": "images\/dtregister\/uploads\/pagopabps.jpg"
},
"Paypalstandard":
and most important is that if I click on checkout in my cart (see attachment) , it redirects to Paypal instead of asking which payment method I want. If I remove Paypal Standard from possible payment methods in the event, clicking on checkout it alerts me to choose the payment method (ignoring completly the possibility to use PagopaBps).
Please could you check fastly my code and let me know what I'm missing?
Kind regards,
Matt