Skip to content

Commit

Permalink
Adds support for commerce integration (#2)
Browse files Browse the repository at this point in the history
* Added commerce support

* Build files

* Add css fix back in that somehow disappeared
  • Loading branch information
jonerickson authored Aug 10, 2023
1 parent c2f015d commit 593befc
Show file tree
Hide file tree
Showing 94 changed files with 189 additions and 53 deletions.
13 changes: 0 additions & 13 deletions dev/html/front/verification/modal.phtml

This file was deleted.

34 changes: 6 additions & 28 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@ services:
ports:
- '80:80'
volumes:
- './invision:/var/www/html' # Edit For Your Local Environment
- './api/:/var/www/html/applications/stripeverification/api'
- './data/:/var/www/html/applications/stripeverification/data'
- './dev/:/var/www/html/applications/stripeverification/dev'
- './extensions/:/var/www/html/applications/stripeverification/extensions'
- './hooks/:/var/www/html/applications/stripeverification/hooks'
- './interface/:/var/www/html/applications/stripeverification/interface'
- './modules/:/var/www/html/applications/stripeverification/modules'
- './setup/:/var/www/html/applications/stripeverification/setup'
- './sources:/var/www/html/applications/stripeverification/sources'
- './tasks/:/var/www/html/applications/stripeverification/tasks'
- './widgets/:/var/www/html/applications/stripeverification/widgets'
- './Application.php:/var/www/html/applications/stripeverification/Application.php'
- './invision:/var/www/html'
- './src:/var/www/html/applications/stripeverification'
- './nginx/conf.d/site.conf:/etc/nginx/conf.d/site.conf'
networks:
- invision
Expand All @@ -28,26 +17,15 @@ services:
- mailhog
php:
build:
context: ./docker/8.0
context: .
dockerfile: Dockerfile
image: invision-8.0/app
volumes:
- './invision:/var/www/html' # Edit For Your Local Environment
- './api/:/var/www/html/applications/stripeverification/api'
- './data/:/var/www/html/applications/stripeverification/data'
- './dev/:/var/www/html/applications/stripeverification/dev'
- './extensions/:/var/www/html/applications/stripeverification/extensions'
- './hooks/:/var/www/html/applications/stripeverification/hooks'
- './interface/:/var/www/html/applications/stripeverification/interface'
- './modules/:/var/www/html/applications/stripeverification/modules'
- './setup/:/var/www/html/applications/stripeverification/setup'
- './sources:/var/www/html/applications/stripeverification/sources'
- './tasks/:/var/www/html/applications/stripeverification/tasks'
- './widgets/:/var/www/html/applications/stripeverification/widgets'
- './Application.php:/var/www/html/applications/stripeverification/Application.php'
- './invision:/var/www/html'
- './src:/var/www/html/applications/stripeverification'
- './php/conf.d/php.ini:/usr/local/etc/php/conf.d/100-custom.ini'
extra_hosts:
host.docker.internal: host-gateway
- 'host.docker.internal:host-gateway'
networks:
- invision
mysql:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions data/build.xml → src/data/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<build>
<module key="admin/system"><![CDATA[{"default_controller":"settings","protected":0,"default":0}]]></module>
<module key="front/system"><![CDATA[{"default_controller":"","protected":false,"default":null}]]></module>
<setting key="stripeverification_commerce_enabled"><![CDATA[{"key":"stripeverification_commerce_enabled","default":""}]]></setting>
<setting key="stripeverification_commerce_subscription"><![CDATA[{"key":"stripeverification_commerce_subscription","default":""}]]></setting>
<setting key="stripeverification_icon"><![CDATA[{"key":"stripeverification_icon","default":"fa fa-solid fa-circle-check"}]]></setting>
<setting key="stripeverification_icon_color"><![CDATA[{"key":"stripeverification_icon_color","default":"#1778f2"}]]></setting>
<setting key="stripeverification_publishable_key"><![CDATA[{"key":"stripeverification_publishable_key","default":""}]]></setting>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion data/javascript.xml → src/data/javascript.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<javascript app="stripeverification">
<file javascript_app="stripeverification" javascript_location="front" javascript_path="controllers/verification" javascript_name="ips.verification.main.js" javascript_type="controller" javascript_version="10005" javascript_position="1000050"><![CDATA[;( function($, _, undefined){
<file javascript_app="stripeverification" javascript_location="front" javascript_path="controllers/verification" javascript_name="ips.verification.main.js" javascript_type="controller" javascript_version="10006" javascript_position="1000050"><![CDATA[;( function($, _, undefined){
"use strict";
ips.controller.register('stripeverification.front.verification.main', {
Expand Down
11 changes: 10 additions & 1 deletion data/lang.xml → src/data/lang.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<language>
<app key="stripeverification" version="10005">
<app key="stripeverification" version="10006">
<word key="__app_stripeverification" js="0">Stripe Identity Verification</word>
<word key="menutab__stripeverification" js="0">Stripe Verification</word>
<word key="menutab__stripeverification_icon" js="0">cc-stripe</word>
Expand All @@ -22,10 +22,17 @@
<word key="mailsub__stripeverification_notification_verified" js="0">Verified</word>
<word key="mailsub__stripeverification_notification_unverified" js="0">Unverified</word>
<word key="stripeverification_userbar" js="0">Verification Status</word>
<word key="stripeverification_stripe_settings_tab" js="0">Stripe</word>
<word key="stripeverification_stripe_settings" js="0">Stripe Settings</word>
<word key="stripeverification_publishable_key" js="0">Publishable Key</word>
<word key="stripeverification_secret_key" js="0">Secret Key</word>
<word key="stripeverification_webhook_secret" js="0">Webhook Secret</word>
<word key="stripeverification_commerce_settings_tab" js="0">Commerce</word>
<word key="stripeverification_commerce_settings" js="0">Commerce Settings</word>
<word key="stripeverification_commerce_enabled" js="0">Enabled</word>
<word key="stripeverification_commerce_enabled_desc" js="0">Enable to integration Commerce with Stripe Identity Verification.</word>
<word key="stripeverification_commerce_subscription" js="0">Subscription</word>
<word key="stripeverification_commerce_subscription_desc" js="0">The subscription the member must be subscribed to, to show their verification status.</word>
<word key="stripeverification_icon_settings" js="0">Icon Settings</word>
<word key="stripeverification_icon_color" js="0">Color</word>
<word key="stripeverification_icon_color_desc" js="0">The color of the verification icon.</word>
Expand All @@ -36,6 +43,8 @@
<word key="stripeverification_verification_settings" js="0">Verification Settings</word>
<word key="stripverification_verified_button" js="0">Start Verification Process</word>
<word key="stripverification_verified_message" js="0">Your account was successfully verfied</word>
<word key="stripverification_purchase_subscription_button" js="0">Purchase Subscription</word>
<word key="stripverification_purchase_subscription_message" js="0">Identity Verification requires the purchase of a site subscription. Please purchase the subscription to continue the verification process.</word>
<word key="stripeverification_unverified_message" js="0">You are not currently verified. Please start the verification process to get verified.</word>
<word key="stripeverification_processing_message" js="0">Your verification is currently processing. Please wait for a notification within the next 24 hours to confirm your verification.</word>
<word key="stripeverification_submit_message" js="0">Your verification request was submitted and is now processing. Please wait for a notification within the next 24 hours to confirm your verification.</word>
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions data/settings.json → src/data/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"key": "stripeverification_commerce_enabled",
"default": ""
},
{
"key": "stripeverification_commerce_subscription",
"default": ""
},
{
"key": "stripeverification_icon",
"default": "fa fa-solid fa-circle-check"
Expand Down
File renamed without changes.
11 changes: 8 additions & 3 deletions data/theme.xml → src/data/theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
{{if \IPS\Member::loggedIn()->verification_processing}}
<div id="stripeverification_processing_message">{lang="stripeverification_processing_message"}</div>
{{elseif ! \IPS\Member::loggedIn()->verified}}
<div id="stripeverification_info_message">{lang="stripeverification_unverified_message"}</div>
<div id="stripeverification_submit_message" style="display: none;">{lang="stripeverification_submit_message"}</div>
<a href="#" data-verification-button class="ipsButton ipsButton_medium ipsButton_normal ipsSpacer_top">{lang="stripverification_verified_button"}</a>
{{if \IPS\Application::appIsEnabled('nexus') && \IPS\Settings::i()->stripeverification_commerce_enabled && !\IPS\Member::loggedIn()->verification_subscription}}
<div id="stripeverification_info_message">{lang="stripverification_purchase_subscription_message"}</div>
<a href="{url="app=stripeverification&module=system&controller=verification&do=subscription"}" data-verification-button class="ipsButton ipsButton_medium ipsButton_normal ipsSpacer_top">{lang="stripverification_purchase_subscription_button"}</a>
{{else}}
<div id="stripeverification_info_message">{lang="stripeverification_unverified_message"}</div>
<div id="stripeverification_submit_message" style="display: none;">{lang="stripeverification_submit_message"}</div>
<a href="#" data-verification-button class="ipsButton ipsButton_medium ipsButton_normal ipsSpacer_top">{lang="stripverification_verified_button"}</a>
{{endif}}
{{else}}
<div id="stripeverification_verified_message">{lang="stripverification_verified_message"} {datetime="\IPS\Member::loggedIn()->verified_at"}.</div>
{{endif}}
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion data/versions.json → src/data/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"10002": "1.0.2",
"10003": "1.0.3",
"10004": "1.0.4",
"10005": "1.0.5"
"10005": "1.0.5",
"10006": "1.0.6"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions src/dev/html/front/verification/modal.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ips:template parameters="" />
<div data-controller="stripeverification.front.verification.main" class="ipsPad ipsType_center ipsType_light ipsType_normal">
{{if \IPS\Member::loggedIn()->verification_processing}}
<div id="stripeverification_processing_message">{lang="stripeverification_processing_message"}</div>
{{elseif ! \IPS\Member::loggedIn()->verified}}
{{if \IPS\Application::appIsEnabled('nexus') && \IPS\Settings::i()->stripeverification_commerce_enabled && !\IPS\Member::loggedIn()->verification_subscription}}
<div id="stripeverification_info_message">{lang="stripverification_purchase_subscription_message"}</div>
<a href="{url="app=stripeverification&module=system&controller=verification&do=subscription"}" data-verification-button class="ipsButton ipsButton_medium ipsButton_normal ipsSpacer_top">{lang="stripverification_purchase_subscription_button"}</a>
{{else}}
<div id="stripeverification_info_message">{lang="stripeverification_unverified_message"}</div>
<div id="stripeverification_submit_message" style="display: none;">{lang="stripeverification_submit_message"}</div>
<a href="#" data-verification-button class="ipsButton ipsButton_medium ipsButton_normal ipsSpacer_top">{lang="stripverification_verified_button"}</a>
{{endif}}
{{else}}
<div id="stripeverification_verified_message">{lang="stripverification_verified_message"} {datetime="\IPS\Member::loggedIn()->verified_at"}.</div>
{{endif}}
</div>

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 12 additions & 1 deletion dev/lang.php → src/dev/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@

'stripeverification_userbar' => 'Verification Status',

'stripeverification_stripe_settings_tab' => 'Stripe',
'stripeverification_stripe_settings' => 'Stripe Settings',

'stripeverification_publishable_key' => 'Publishable Key',
'stripeverification_secret_key' => 'Secret Key',
'stripeverification_webhook_secret' => 'Webhook Secret',

'stripeverification_commerce_settings_tab' => 'Commerce',
'stripeverification_commerce_settings' => 'Commerce Settings',

'stripeverification_commerce_enabled' => 'Enabled',
'stripeverification_commerce_enabled_desc' => 'Enable to integration Commerce with Stripe Identity Verification.',
'stripeverification_commerce_subscription' => 'Subscription',
'stripeverification_commerce_subscription_desc' => 'The subscription the member must be subscribed to, to show their verification status.',

'stripeverification_icon_settings' => 'Icon Settings',

'stripeverification_icon_color' => 'Color',
Expand All @@ -51,6 +60,8 @@

'stripverification_verified_button' => 'Start Verification Process',
'stripverification_verified_message' => 'Your account was successfully verfied',
'stripverification_purchase_subscription_button' => 'Purchase Subscription',
'stripverification_purchase_subscription_message' => 'Identity Verification requires the purchase of a site subscription. Please purchase the subscription to continue the verification process.',
'stripeverification_unverified_message' => 'You are not currently verified. Please start the verification process to get verified.',
'stripeverification_processing_message' => 'Your verification is currently processing. Please wait for a notification within the next 24 hours to confirm your verification.',
'stripeverification_submit_message' => 'Your verification request was submitted and is now processing. Please wait for a notification within the next 24 hours to confirm your verification.',
Expand All @@ -64,5 +75,5 @@
'stripverification_verify' => 'Actions',

'modperms__stripeverification_Verifications' => 'Verifications',
'can_manage_verifications' => 'Can manage verifications?'
'can_manage_verifications' => 'Can manage verifications?',
];
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 24 additions & 1 deletion hooks/Member.php → src/hooks/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ public function get_verification()
}
}

/**
* @return false|\IPS\nexus\Subscription
*/
public function get_verification_subscription()
{
if (\IPS\Application::appIsEnabled('nexus') && $packageId = \IPS\Settings::i()->stripeverification_commerce_subscription) {
try {
$package = \IPS\nexus\Subscription\Package::load($packageId);

return \IPS\nexus\Subscription::loadByMemberAndPackage($this, $package);
} catch (\OutOfRangeException) {
}
}

return false;
}

/**
* @return bool
*/
Expand All @@ -107,7 +124,13 @@ public function get_verification_processing()
*/
public function get_verified()
{
return (bool) $this->verification?->verified;
$verified = (bool) $this->verification?->verified;

if (\IPS\Application::appIsEnabled('nexus') && \IPS\Settings::i()->stripeverification_commerce_enabled) {
$verified = $verified && $this->verification_subscription;
}

return $verified;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion hooks/css.php → src/hooks/css.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function hookData()
0 => [
'selector' => 'html > head',
'type' => 'add_inside_end',
'content' => '<link rel=\'stylesheet\' href=\'{expression="\IPS\Http\Url::external(reset(\IPS\Theme::i()->css(\'stripeverification.css\', \'stripeverification\', \'front\')))->setQueryString(\'v\',\IPS\Theme::i()->cssCacheBustKey())"}\' media=\'all\'>
'content' => '<link rel=\'stylesheet\' href=\'{expression="\IPS\Http\Url::external(reset(\IPS\Theme::i()->css(\'stripeverification.css\', \'stripeverification\', \'front\')))->setQueryString(\'v\',\IPS\Theme::i()->cssCacheBustKey())"}\' media=\'all\'>
',
],
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function manage()
$groups[$group->g_id] = $group->name;
}

$form->addTab('stripeverification_stripe_settings_tab');
$form->addHeader(\IPS\Member::loggedIn()->language()->addToStack('stripeverification_stripe_settings'));
$form->add(new \IPS\Helpers\Form\Text('stripeverification_publishable_key', \IPS\Settings::i()->stripeverification_publishable_key, true));
$form->add(new \IPS\Helpers\Form\Text('stripeverification_secret_key', \IPS\Settings::i()->stripeverification_secret_key, true));
Expand All @@ -55,7 +56,16 @@ protected function manage()
'multiple' => true,
]));

if ($values = $form->values()) {
if (\IPS\Application::appIsEnabled('nexus')) {
$form->addTab('stripeverification_commerce_settings_tab');
$form->addHeader(\IPS\Member::loggedIn()->language()->addToStack('stripeverification_commerce_settings'));
$form->add(new \IPS\Helpers\Form\YesNo('stripeverification_commerce_enabled', \IPS\Settings::i()->stripeverification_commerce_enabled));
$form->add(new \IPS\Helpers\Form\Node('stripeverification_commerce_subscription', \IPS\Settings::i()->stripeverification_commerce_subscription, false, [
'class' => \IPS\nexus\Subscription\Package::class,
]));
}

if ($form->values()) {
$form->saveAsSettings();
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,16 @@ protected function unverify()

\IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=core&module=modcp&controller=modcp&tab=stripeverification', 'front', 'modcp_stripeverification'), 'modcp_stripeverification_unverified');
}

/**
* @return void
*/
protected function subscription()
{
if (\IPS\Application::appIsEnabled('nexus') && \IPS\Settings::i()->stripeverification_commerce_enabled && $package = \IPS\Settings::i()->stripeverification_commerce_subscription) {
\IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=nexus&module=subscriptions&controller=subscriptions&id='.$package, 'front', 'nexus_subscription'));
}

\IPS\Output::i()->redirect(\IPS\Http\Url::internal(''));
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions src/setup/upg_10005/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": 10005,
"name": "1.0.5",
"steps": {
"queries": false,
"lang": true,
"theme": true,
"themeSettings": false,
"javascript": false,
"emailTemplates": false,
"hooks": false,
"acpSearchKeywords": false,
"settings": true,
"tasks": false,
"modules": false,
"widgets": false,
"customOptions": false,
"customRoutines": false
},
"forceMainUpgrader": false,
"forceManualDownloadNoCiC": false,
"forceManualDownloadCiC": false
}
22 changes: 22 additions & 0 deletions src/setup/upg_10005/lang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"normal": {
"added": [
"stripeverification_stripe_settings_tab",
"stripeverification_commerce_settings_tab",
"stripeverification_commerce_settings",
"stripeverification_commerce_enabled",
"stripeverification_commerce_enabled_desc",
"stripeverification_commerce_subscription",
"stripeverification_commerce_subscription_desc",
"stripverification_purchase_subscription_button",
"stripverification_purchase_subscription_message"
],
"edited": [],
"removed": []
},
"js": {
"added": [],
"edited": [],
"removed": []
}
}
8 changes: 8 additions & 0 deletions src/setup/upg_10005/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"added": [
"stripeverification_commerce_enabled",
"stripeverification_commerce_subscription"
],
"edited": [],
"removed": []
}
Loading

0 comments on commit 593befc

Please sign in to comment.