Skip to content

Commit

Permalink
Implement BLIK payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
getdatakick committed Apr 9, 2024
1 parent e88d50d commit 4483f54
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions classes/PaymentMethod/BlikMethod.php
@@ -0,0 +1,80 @@
<?php

namespace StripeModule\PaymentMethod;

use Cart;
use PrestaShopException;
use Stripe\Exception\ApiErrorException;
use StripeModule\ExecutionResult;
use StripeModule\PaymentMetadata;
use StripeModule\PaymentMethod;

class BlikMethod extends PaymentMethod
{
const METHOD_ID = 'blik';

/**
* @return string
*/
public function getMethodId(): string
{
return static::METHOD_ID;
}

/**
* @return string[]
*/
protected function getAllowedCurrencies(): array
{
return [ 'PLN' ];
}


/**
* @return array|string[]
*/
protected function getAllowedAccountCountries(): array
{
return static::ALL;
}

/**
* @return string[]
*/
protected function getAllowedCustomerCountries(): array
{
return static::ALL;
}

/**
* @param Cart $cart
*
* @return ExecutionResult
* @throws PrestaShopException
*/
public function executeMethod(Cart $cart): ExecutionResult
{
try {
$api = $this->getStripeApi();
$session = $api->createCheckoutSession(
$cart,
$this->getMethodId(),
[\Stripe\PaymentMethod::TYPE_BLIK],
[]
);
$metadata = PaymentMetadata::createForSession($this->getMethodId(), $cart, $session);
return ExecutionResult::redirect($metadata, $session->url);
} catch (ApiErrorException $e) {
return $this->handleApiException($e);
}
}


/**
* @return string
*/
public function getName(): string
{
return $this->l('Blik', 'stripe');
}
}
Binary file added views/img/blik.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4483f54

Please sign in to comment.