Skip to content

Commit

Permalink
add Ideal Processing as separate payment method, also removed duplica…
Browse files Browse the repository at this point in the history
…te NoServiceSpecifiedPayment in $payments array
  • Loading branch information
vegimcarkaxhija committed Mar 12, 2024
1 parent 5e9e363 commit c6e8e7b
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/PaymentMethods/PaymentMethodFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Buckaroo\PaymentMethods\iDin\iDin;
use Buckaroo\PaymentMethods\SEPA\SEPA;
use Buckaroo\PaymentMethods\iDeal\iDeal;
use Buckaroo\PaymentMethods\iDealProcessing\iDealProcessing;
use Buckaroo\PaymentMethods\MBWay\MBWay;
use Buckaroo\PaymentMethods\Tinka\Tinka;
use Buckaroo\Exceptions\BuckarooException;
Expand Down Expand Up @@ -92,7 +93,8 @@ class PaymentMethodFactory
],
CreditClick::class => ['creditclick'],
CreditManagement::class => ['credit_management'],
iDeal::class => ['ideal', 'idealprocessing'],
iDeal::class => ['ideal'],
iDealProcessing::class => ['idealprocessing'],
iDealQR::class => ['ideal_qr'],
iDin::class => ['idin'],
In3::class => ['in3'],
Expand Down Expand Up @@ -120,7 +122,6 @@ class PaymentMethodFactory
Przelewy24::class => ['przelewy24'],
PointOfSale::class => ['pospayment'],
Giropay::class => ['giropay'],
NoServiceSpecifiedPayment::class => ['noservice'],
GiftCard::class => [
'giftcard', 'westlandbon', 'babygiftcard', 'babyparkgiftcard',
'beautywellness', 'boekenbon', 'boekenvoordeel',
Expand Down
28 changes: 28 additions & 0 deletions src/PaymentMethods/iDealProcessing/Models/Pay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\PaymentMethods\iDealProcessing\Models;

use Buckaroo\Models\ServiceParameter;

class Pay extends ServiceParameter
{
protected string $issuer;
}
75 changes: 75 additions & 0 deletions src/PaymentMethods/iDealProcessing/iDealProcessing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

declare(strict_types=1);

namespace Buckaroo\PaymentMethods\iDealProcessing;

use Buckaroo\Exceptions\BuckarooException;
use Buckaroo\Models\Model;
use Buckaroo\PaymentMethods\iDealProcessing\Models\Pay;
use Buckaroo\PaymentMethods\PayablePaymentMethod;
use Buckaroo\Services\TraitHelpers\HasIssuers;
use Buckaroo\Transaction\Response\TransactionResponse;

class iDealProcessing extends PayablePaymentMethod

Check failure on line 32 in src/PaymentMethods/iDealProcessing/iDealProcessing.php

View workflow job for this annotation

GitHub Actions / PHP 7.4 - prefer-stable -

Class name "iDealProcessing" is not in PascalCase format

Check failure on line 32 in src/PaymentMethods/iDealProcessing/iDealProcessing.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 - prefer-stable -

Class name "iDealProcessing" is not in PascalCase format

Check failure on line 32 in src/PaymentMethods/iDealProcessing/iDealProcessing.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 - prefer-stable -

Class name "iDealProcessing" is not in PascalCase format
{
use HasIssuers {
issuers as traitIssuers;
}

/**
* @var string
*/
protected string $paymentName = 'idealprocessing';
/**
* @var array|string[]
*/
protected array $requiredConfigFields = ['currency', 'returnURL', 'returnURLCancel', 'pushURL'];

/**
* @param Model|null $model
* @return TransactionResponse
*/
public function pay(?Model $model = null)
{
return parent::pay($model ?? new Pay($this->payload));
}

/**
* @param Model|null $model
* @return TransactionResponse
*/
public function payRemainder(?Model $model = null): TransactionResponse
{
return parent::payRemainder($model ?? new Pay($this->payload));
}

/**
* @return array
* @throws BuckarooException
*/
public function issuers(): array
{
$this->serviceVersion = 2;

return $this->traitIssuers();
}
}
90 changes: 90 additions & 0 deletions tests/Buckaroo/Payments/IdealProcessingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to support@buckaroo.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact support@buckaroo.nl for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Tests\Buckaroo\Payments;

use Tests\Buckaroo\BuckarooTestCase;
use Buckaroo\Config\Config;


class CustomConfig extends Config
{
public function __construct()
{
$websiteKey = 'Set Key';
$secretKey = 'From other resources like DB/ENV/Platform Config';

parent::__construct($websiteKey, $secretKey);
}
}

class IdealProcessingTest extends BuckarooTestCase
{
protected array $paymentPayload;
protected function setUp(): void
{
$this->paymentPayload = [
'invoice' => uniqid(),
'amountDebit' => 10.10,
'issuer' => 'ABNANL2A',
'pushURL' => 'https://buckaroo.dev/push',
'returnURL' => 'https://buckaroo.dev/return',
'clientIP' => [
'address' => '123.456.789.123',
'type' => 0,
],
'customParameters' => [
'CustomerBillingFirstName' => 'test'
],
'additionalParameters' => [
'initiated_by_magento' => 1,
'service_action' => 'something',
],
];
}

/**
* @return void
* @test
*/
public function it_get_idealprocessing_issuers()
{
$response = $this->buckaroo->method('idealprocessing')->issuers();

$this->assertIsArray($response);
foreach ($response as $item)
{
$this->assertIsArray($item);
$this->assertArrayHasKey('id', $item);
$this->assertArrayHasKey('name', $item);
}
}

/**
* @return void
* @test
*/
public function it_creates_a_idealprocessing_payment()
{
$response = $this->buckaroo->method('idealprocessing')->pay($this->paymentPayload);

$this->assertTrue($response->isPendingProcessing());
}
}
2 changes: 1 addition & 1 deletion tests/Buckaroo/Payments/IdealTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function it_get_ideal_issuers()
*/
public function it_creates_a_ideal_payment()
{
$response = $this->buckaroo->method('idealprocessing')->pay($this->paymentPayload);
$response = $this->buckaroo->method('ideal')->pay($this->paymentPayload);

$this->assertTrue($response->isPendingProcessing());
}
Expand Down

0 comments on commit c6e8e7b

Please sign in to comment.