Skip to content

Commit

Permalink
Webhook changes
Browse files Browse the repository at this point in the history
  • Loading branch information
franksmule committed Apr 21, 2014
1 parent 616a0e2 commit 31f6250
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion stripejs/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>stripejs</name>
<displayName><![CDATA[Stripe]]></displayName>
<version><![CDATA[1.0.1Beta]]></version>
<version><![CDATA[1.0.2Beta]]></version>
<description><![CDATA[Accept payments by Credit Card with Stripe (Visa, Mastercard, Amex, Discover and Diners Club)]]></description>
<author><![CDATA[PrestaShop + Ollie]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
7 changes: 3 additions & 4 deletions stripejs/controllers/front/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ public function webhook()
{
/* To double-check and for more security, we retrieve the original event directly from Stripe */
$event = Stripe_Event::retrieve($event_json->id);

/* We are only handling chargebacks, other events are ignored */
if ($event->type == 'charge.disputed')
if ($event->type == 'charge.dispute.created')
{
$id_order = (int)Db::getInstance()->getValue('SELECT id_order FROM '._DB_PREFIX_.'stripe_transaction WHERE id_stripe_transaction = \''.pSQL($event->id).'\' AND `charge_back` = 0');
if ($id_order)
Expand Down Expand Up @@ -86,15 +85,15 @@ public function webhook()
}
catch (Exception $e)
{
header('HTTP/1.1 501 NOT SUPPORTED');
header('HTTP/1.1 200 OK');
exit;
}
header('HTTP/1.1 200 OK');
exit;
}
}
}
header('HTTP/1.1 501 NOT SUPPORTED');
header('HTTP/1.1 200 OK');
exit;
}
}
4 changes: 2 additions & 2 deletions stripejs/stripejs.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct()
{
$this->name = 'stripejs';
$this->tab = 'payments_gateways';
$this->version = '1.0.1Beta';
$this->version = '1.0.2Beta';
$this->author = 'PrestaShop + Ollie McFarlane';
$this->need_instance = 0;
$this->currencies = true;
Expand Down Expand Up @@ -865,7 +865,7 @@ public function getContent()
<legend><img src="'.$this->_path.'img/checks-icon.gif" alt="" />'.$this->l('Webhooks').'</legend>
'.$this->l('In order to receive chargeback information from Stripe, you must provide a Webhook link in Stripe\'s admin panel.').'<br />
'.$this->l('To get started, please visit Stripe and setup the following Webhook:').'<br /><br />
<strong>'.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'modules/stripejs/webhooks.php?token='.Tools::safeOutput(Configuration::get('STRIPE_WEBHOOK_TOKEN')).'</strong>
<strong>'.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'index.php?process=webhook&fc=module&module=stripejs&controller=default&token='.Tools::safeOutput(Configuration::get('STRIPE_WEBHOOK_TOKEN')).'</strong>
</fieldset>
</div>
Expand Down

0 comments on commit 31f6250

Please sign in to comment.