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();
}
}