diff --git a/Module.php b/Module.php index fd387b2..5679f8f 100755 --- a/Module.php +++ b/Module.php @@ -35,6 +35,11 @@ public function getConfig() return [ 'service_manager' => $configProvider->getDependencies(), + 'view_helpers' => [ + 'factories' => [ + 'stripeKey' => \ZfrStripeModule\View\Helper\StripeKeyFactory::class, + ], + ], ]; } } diff --git a/config/zfr_stripe.local.php.dist b/config/zfr_stripe.local.php.dist index 60b3240..2f56fb2 100755 --- a/config/zfr_stripe.local.php.dist +++ b/config/zfr_stripe.local.php.dist @@ -24,7 +24,10 @@ return array( * Secret key */ // 'secret_key' => '', - + /** + * Publishable key + */ + // 'publishable_key' => '', /** * Stripe SDK version to use */ diff --git a/src/View/Helper/StripeKey.php b/src/View/Helper/StripeKey.php new file mode 100644 index 0000000..1ae54ee --- /dev/null +++ b/src/View/Helper/StripeKey.php @@ -0,0 +1,24 @@ +publishableKey = $publishableKey; + } + + public function __invoke() + { + return sprintf("Stripe.setPublishableKey('%s');", $this->publishableKey); + } +} diff --git a/src/View/Helper/StripeKeyFactory b/src/View/Helper/StripeKeyFactory new file mode 100644 index 0000000..96f4988 --- /dev/null +++ b/src/View/Helper/StripeKeyFactory @@ -0,0 +1,15 @@ +get('Config'); + return new StripeKey($config['zfr_stripe']['publishable_key']); + } +}