Skip to content

Commit

Permalink
Fix 3D secure
Browse files Browse the repository at this point in the history
  • Loading branch information
firstred committed May 14, 2017
1 parent fc80349 commit 37dfa10
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 410 deletions.
6 changes: 5 additions & 1 deletion classes/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ function ($class) {
'ThirtybeesStripe\\Error\\InvalidRequest',
'ThirtybeesStripe\\Error\\Permission',
'ThirtybeesStripe\\Error\\RateLimit',
'ThirtybeesStripe\\Error\\SignatureVerification',
'ThirtybeesStripe\\HttpClient\\ClientInterface',
'ThirtybeesStripe\\HttpClient\\CurlClient',
'ThirtybeesStripe\\HttpClient\\GuzzleClient',
'ThirtybeesStripe\\Util\\AutoPagingIterator',
'ThirtybeesStripe\\Util\\DefaultLogger',
'ThirtybeesStripe\\Util\\LoggerInterface',
'ThirtybeesStripe\\Util\\RequestOptions',
'ThirtybeesStripe\\Util\\Set',
'ThirtybeesStripe\\Util\\Util',
Expand Down Expand Up @@ -108,7 +111,8 @@ function ($class) {
'ThirtybeesStripe\\Token',
'ThirtybeesStripe\\Transfer',
'ThirtybeesStripe\\TransferReversal',
'ThirtybeesStripe\\TransferReversal',
'ThirtybeesStripe\\Webhook',
'ThirtybeesStripe\\WebhookSignature',
])) {
// project-specific namespace prefix
$prefix = 'ThirtybeesStripe\\';
Expand Down
39 changes: 39 additions & 0 deletions controllers/front/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,45 @@ public function postProcess()
$stripeAmount = (int) ($stripeAmount * 100);
}

try {
$defaultCard = \ThirtybeesStripe\Source::retrieve($stripeCustomer->default_source);
} catch (Exception $e) {
$error = $e->getMessage();
$this->errors[] = $error;
$this->setTemplate('error.tpl');

return false;
}

/** @var \ThirtybeesStripe\Card $defaultCard */
$defaultCard = $defaultCard->card;

if (Configuration::get(Stripe::THREEDSECURE) && $defaultCard->three_d_secure !== 'not_supported' || $defaultCard->three_d_secure === 'required') {
try {
$source = \ThirtybeesStripe\Source::create(
[
'amount' => $stripeAmount,
'currency' => Tools::strtolower($currency->iso_code),
'type' => 'three_d_secure',
'three_d_secure' => [
'card' => $stripeCustomer->default_source,
],
'redirect' => [
'return_url' => $this->context->link->getModuleLink('stripe', 'sourcevalidation', ['stripe-id_cart' => (string) $cart->id, 'type' => 'three_d_secure'], true),
],
]
);
} catch (Exception $e) {
$error = $e->getMessage();
$this->errors[] = $error;
$this->setTemplate('error.tpl');

return false;
}

Tools::redirectLink($source->redirect->url);
}

try {
$stripeCharge = \ThirtybeesStripe\Charge::create(
[
Expand Down
Loading

0 comments on commit 37dfa10

Please sign in to comment.