Skip to content

Commit

Permalink
Stabilize code to prepare beta freeze.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Apr 24, 2019
1 parent b8a72ce commit 2e277d6
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 61 deletions.
2 changes: 1 addition & 1 deletion htdocs/public/stripe/ipn.php
Expand Up @@ -144,7 +144,7 @@
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $societeName = $conf->global->MAIN_APPLICATION_TITLE;


dol_syslog("Stripe IPN was calle with event->type = ".$event->type);
dol_syslog("Stripe IPN was called with event->type = ".$event->type);


if ($event->type == 'payout.created') {
Expand Down
142 changes: 82 additions & 60 deletions htdocs/stripe/admin/stripe.php
Expand Up @@ -165,7 +165,7 @@
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("AccountParameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '<td>'.$langs->trans("Status").'</td>';
print '<td></td>';
print "</tr>\n";

print '<tr class="oddeven">';
Expand All @@ -177,7 +177,7 @@
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE);
}
print '</td></tr>';
print '</td><td></td></tr>';

if (empty($conf->stripeconnect->enabled))
{
Expand All @@ -195,41 +195,52 @@

print '<tr class="oddeven"><td>';
print '<span class="titlefield fieldrequired">'.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").'</span></td><td>';
print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_ID" value="'.$conf->global->STRIPE_TEST_WEBHOOK_ID.'">';
print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_ID" value="'.$conf->global->STRIPE_TEST_WEBHOOK_ID.'">';
print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
}
print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_KEY" value="'.$conf->global->STRIPE_TEST_WEBHOOK_KEY.'">';
print ' &nbsp; '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx';
$out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForTestWebhook").' ';
$url = dol_buildpath('/public/stripe/ipn.php?test', 3);
$url = dol_buildpath('/public/stripe/ipn.php?test', 3);
$out.= '<input type="text" id="onlinetestwebhookurl" class="minwidth500" value="'.$url.'">';
$out.= ajax_autoselect("onlinetestwebhookurl", 0);
print '<br />'.$out;
print '<br>'.$out;
print '</td><td>';
if ( !empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID) ) {
\Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents;
if ( GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID ) {
if ( empty(GETPOST('status', 'alpha')) ) {
$endpoint->disabled = true;
} else {
$endpoint->disabled = false;
}}
$endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
$endpoint->save();
if ($endpoint->status == 'enabled')
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
}
//print $endpoint;
} else print img_picto($langs->trans("inactive"), 'statut5');
print'</td></tr>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
if (!empty($conf->global->STRIPE_TEST_WEBHOOK_KEY) && !empty($conf->global->STRIPE_TEST_SECRET_KEY) && !empty($conf->global->STRIPE_TEST_WEBHOOK_ID))
{
\Stripe\Stripe::setApiKey($conf->global->STRIPE_TEST_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_TEST_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents;
if (GETPOST('webhook', 'alpha') == $conf->global->STRIPE_TEST_WEBHOOK_ID) {
if (empty(GETPOST('status', 'alpha'))) {
$endpoint->disabled = true;
} else {
$endpoint->disabled = false;
}
}
$endpoint->url = dol_buildpath('/public/stripe/ipn.php?test', 3);
$endpoint->save();
if ($endpoint->status == 'enabled')
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
}
//print $endpoint;
}
else
{
print img_picto($langs->trans("inactive"), 'statut5');
}
}
print'</td></tr>';
} else {
print '<tr class="oddeven"><td>'.$langs->trans("StripeConnect").'</td>';
print '<td><b>'.$langs->trans("StripeConnect_Mode").'</b><br/>';
Expand All @@ -238,7 +249,7 @@
print '% + ';
print price($conf->global->STRIPE_APPLICATION_FEE);
print ' '.$langs->getCurrencySymbol($conf->currency).' '.$langs->trans("minimum").' '.price($conf->global->STRIPE_APPLICATION_FEE_MINIMAL).' '.$langs->getCurrencySymbol($conf->currency).' </td></tr>';
print '</td></tr>';
print '</td><td></td></tr>';
}

if (empty($conf->stripeconnect->enabled))
Expand All @@ -256,47 +267,58 @@
print '</td><td></td></tr>';

print '<tr class="oddeven"><td>';
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_ID" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_ID.'">';
print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
print '<span class="titlefield fieldrequired">'.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").'</span></td><td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_ID" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_ID.'">';
print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
}
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_KEY" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_KEY.'">';
print ' &nbsp; '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx';
$out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForLiveWebhook").' ';
$url = dol_buildpath('/public/stripe/ipn.php', 3);
$out.= '<input type="text" id="onlinelivewebhookurl" class="minwidth500" value="'.$url.'">';
$out.= ajax_autoselect("onlinelivewebhookurl", 0);
print '<br />'.$out;
print '<br>'.$out;
print '</td><td>';
if ( !empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID) ) {
\Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents;
if ( GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID ) {
if ( empty(GETPOST('status', 'alpha')) ) {
$endpoint->disabled = true;
} else {
$endpoint->disabled = false;
}}
$endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
$endpoint->save();
if ($endpoint->status == 'enabled')
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
}
//print $endpoint;
} else print img_picto($langs->trans("inactive"), 'statut5');
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
if (!empty($conf->global->STRIPE_LIVE_WEBHOOK_KEY) && !empty($conf->global->STRIPE_LIVE_SECRET_KEY) && !empty($conf->global->STRIPE_LIVE_WEBHOOK_ID))
{
\Stripe\Stripe::setApiKey($conf->global->STRIPE_LIVE_SECRET_KEY);
$endpoint = \Stripe\WebhookEndpoint::retrieve($conf->global->STRIPE_LIVE_WEBHOOK_ID);
$endpoint->enabled_events = $stripearrayofwebhookevents;
if ( GETPOST('webhook', 'alpha') == $conf->global->STRIPE_LIVE_WEBHOOK_ID ) {
if ( empty(GETPOST('status', 'alpha')) ) {
$endpoint->disabled = true;
} else {
$endpoint->disabled = false;
}
}
$endpoint->url = dol_buildpath('/public/stripe/ipn.php', 3);
$endpoint->save();
if ($endpoint->status == 'enabled')
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=0">';
print img_picto($langs->trans("Activated"), 'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
print img_picto($langs->trans("Disabled"), 'switch_off');
}
//print $endpoint;
}
else
{
print img_picto($langs->trans("inactive"), 'statut5');
}
}
print '</td></tr>';
}
else
{
print '<tr class="oddeven"><td>'.$langs->trans("StripeConnect").'</td>';
print '<td>'.$langs->trans("StripeConnect_Mode").'</td></tr>';
print '<td>'.$langs->trans("StripeConnect_Mode").'</td><td></td></tr>';
}


Expand Down

0 comments on commit 2e277d6

Please sign in to comment.