Page 1 of 2

Payment method

Posted: 14 Aug 2025, 14:40
by landed
I have been using AI to code very successfully in Joomla and wish to see if I can also do this for payment options? I haven't seen any plugins and can't find where these files would be. Is this something anyone could help me with?

Re: Payment method

Posted: 14 Aug 2025, 18:31
by Nidzo
For payments you need to develop Phoca Cart payment plugin. Here are some free https://www.phoca.cz/download/99-phoca- ... rt-plugins
For payment gateways like Stripe, Molie etc. there are paid third party plugins or you can try to develop your own.

Re: Payment method

Posted: 14 Aug 2025, 23:53
by Jan
The basic payment method like PayPal can be found in main package, so you can inspire there.

See:
https://www.phoca.cz/phocacart-extensio ... =1-payment

for list of different payment methods for Phoca Cart.

Jan

Re: Payment method

Posted: 15 Aug 2025, 14:34
by landed
I couldn't find where it is, can you pass me the folder location please? I'd rather pay you 49 euros per year than a 3rd party for a payment option.

Re: Payment method

Posted: 15 Aug 2025, 15:19
by Benno
Hi,
download Phoca Cart v5.2.0 Package.
Unzip it local on your PC --> Click on 'packages' folder and unzip 'plg_pcp_paypal_standard_v5.1.1.zip'
This is the basic Phoca Cart payment plugin PayPal.

Kind regards,
Benno

Re: Payment method

Posted: 15 Aug 2025, 17:40
by landed
Thank You

Re: Payment method

Posted: 15 Aug 2025, 18:59
by Benno
You're welcome!

Kind regards,
Benno

Re: Payment method

Posted: 05 Sep 2025, 18:24
by landed
Is there anything special which PhocaCart is doing as my plugin function is not firing:onPCPbeforeSetPaymentForm.
I created it very much the same way as the Paypal standard. Is there any gotcha which I need to know about. Thanks.

Re: Payment method

Posted: 08 Sep 2025, 15:00
by Jan
Hi, first of all you need to detect if the plugin is active at all. Print some debug info in the event. Check if the plugin is installed, active and assigned to selected payment method, then try to print some debug and exit the code in the plugin to see if it is active.

If not installed try to use n3t debug, which will display you important information when debugging: https://n3t.bitbucket.io/extension/n3t-debug/

Jan

Re: Payment method

Posted: 09 Sep 2025, 09:41
by landed
Yes it installs and can be selected in checkout, there is no redirect however to input payment. So the checkout finishes without needing to insert card information. In backend shows pending. There is no debug run.

<?php
/**
* @package Joomla.Plugin
* @subpackage Pcp.Stripe_Standard
* @copyright (C) 2025
* @license GNU/GPL
*/

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Uri\Uri;

require_once JPATH_SITE . '/plugins/pcp/stripe_standard/helpers/webhooklistener.php';

class plgPCPStripe_Standard extends CMSPlugin
{
protected $name = 'stripe_standard';

public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}

/**
* Build the form that redirects/calls Stripe Checkout
*/
public function onPCPbeforeSetPaymentForm(&$form, $paramsC, $params, $order, $eventData)
{
if (!isset($eventData['pluginname']) || $eventData['pluginname'] !== $this->name) {
return false;
}

$publishableKey = $params->get('publishable_key', '');
$secretKey = $params->get('secret_key', '');
$sandbox = (int) $params->get('sandbox', 1);

if (!$publishableKey || !$secretKey) {
throw new \RuntimeException('Stripe keys not configured.');
}

// Load Stripe SDK (installed by composer)
\Stripe\Stripe::setApiKey($secretKey);

// Create Stripe Checkout Session
try {
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => strtolower($order['common']->currency_code),
'product_data' => [
'name' => Text::_('COM_PHOCACART_ORDER') . ': ' . $order['common']->order_number,
],
'unit_amount' => (int) round($order['total'][count($order['total']) - 1]->amount * 100), // in cents
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => Uri::root(false) . 'index.php?option=com_phocacart&view=response&task=response.paymentrecieve&type=stripe_standard&oid=' . (int) $order['common']->id,
'cancel_url' => Uri::root(false) . 'index.php?option=com_phocacart&view=response&task=response.paymentcancel&type=stripe_standard&oid=' . (int) $order['common']->id,
'metadata' => [
'order_id' => (int) $order['common']->id,
],
]);
} catch (\Exception $e) {
throw new \RuntimeException('Stripe error: ' . $e->getMessage());
}

// Render form / redirect script
$form = '<script src="https://js.stripe.com/v3/"></script>
<script>
var stripe = Stripe("' . htmlspecialchars($publishableKey, ENT_QUOTES, 'UTF-8') . '");
stripe.redirectToCheckout({ sessionId: "' . $session->id . '" });
</script>';

return true;
}

/**
* Called when PhocaCart wants to validate payment notification (webhook style)
*/
public function onPCPbeforeCheckPayment($pid, $eventData)
{
if (!isset($eventData['pluginname']) || $eventData['pluginname'] !== $this->name) {
return false;
}

// Load listener
if (!class_exists('PhocacartStripeWebhookListener')) {
require_once(JPATH_SITE . '/plugins/pcp/stripe_standard/helpers/webhooklistener.php');
}

$paymentTemp = new PhocacartPayment();
$paymentOTemp = $paymentTemp->getPaymentMethod((int) $pid);
$paramsPaymentTemp = $paymentOTemp->params;

$listener = new PhocacartStripeWebhookListener($paramsPaymentTemp);
return $listener->handle();
}
}