Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Merge remote-tracking branch 'remotes/github/develop' into PHPLIB-345/change/release-and-merge-external-pr #191

Merged
merged 4 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
## [1.2.8.0][1.2.8.0]

### Add
* Add curl error string to debug log.
* Add environment variable to enable/disable verbose curl output.
* Curl error string to debug log.
* Environment variable to enable/disable verbose curl output.
* Method to get the initial transaction from a payment.
* Parameter `css` to `Paypage` to enable custom styling. Special thanks to github user [bleenders](https://github.com/bleenders).

### Change
* Mask auth header in debug log.
Expand Down
11 changes: 5 additions & 6 deletions src/Resources/PaymentTypes/Paypage.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class Paypage extends BasePaymentType
/** @var bool $card3ds */
protected $card3ds;

/** @var array $css */
protected $css = [];
/** @var array|null $css */
protected $css;

/**
* Paypage constructor.
Expand Down Expand Up @@ -548,14 +548,13 @@ public function getCss(): ?array
}

/**
* @param array $styles
* @param array|null $styles
*
* @return Paypage
*/
public function setCss($styles): Paypage
{
foreach ($styles as $element => $css) {
$this->css[$element] = $css;
}
$this->css = empty($styles) ? null : $styles;
return $this;
}

Expand Down
13 changes: 13 additions & 0 deletions test/integration/PaymentTypes/PaypageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,17 @@ public function maximumPaypageAuthorizeShouldBeCreatable(): void
$this->assertNotNull($payment->getId());
$this->assertNotEmpty($paypage->getRedirectUrl());
}

/**
* Validate paypage css can be set empty array.
*
* @test
*/
public function cssShouldAllowForEmptyArray(): void
{
$paypage = new Paypage(100.0, 'EUR', self::RETURN_URL);
$this->assertEmpty($paypage->getId());
$paypage = $this->heidelpay->initPayPageAuthorize($paypage->setCss([]));
$this->assertNotEmpty($paypage->getId());
}
}
24 changes: 21 additions & 3 deletions test/unit/Resources/PaymentTypes/PayPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function getterAndSetterWorkAsExpected(): void
$this->assertNull($paypage->getShopDescription());
$this->assertNull($paypage->getShopName());
$this->assertNull($paypage->getTagline());
$this->assertNull($paypage->getCss());

// link urls
$this->assertNull($paypage->getContactUrl());
Expand Down Expand Up @@ -102,7 +103,13 @@ public function getterAndSetterWorkAsExpected(): void
->setPayment($payment)
->setRedirectUrl('https://redirect.url')
->addExcludeType(SepaDirectDebit::getResourceName())
->setCard3ds(true);
->setCard3ds(true)
->setCss([
'shopDescription' => 'color: purple',
'header' => 'background-color: red',
'helpUrl' => 'color: blue',
'contactUrl' => 'color: green',
]);

// ----------- VERIFY test values ------------
$this->assertEquals(321.0, $paypage->getAmount());
Expand All @@ -121,6 +128,12 @@ public function getterAndSetterWorkAsExpected(): void
$this->assertEquals('my shop description', $paypage->getShopDescription());
$this->assertEquals('my shop name', $paypage->getShopName());
$this->assertEquals('my shops tag line', $paypage->getTagline());
$this->assertEquals([
'shopDescription' => 'color: purple',
'header' => 'background-color: red',
'helpUrl' => 'color: blue',
'contactUrl' => 'color: green',
], $paypage->getCss());

// link urls
$this->assertEquals('my contact url', $paypage->getContactUrl());
Expand Down Expand Up @@ -167,6 +180,7 @@ public function responseHandlingShouldWorkProperly(): void
$this->assertNull($paypage->getShopDescription());
$this->assertNull($paypage->getShopName());
$this->assertNull($paypage->getTagline());
$this->assertNull($paypage->getCss());

$this->assertNull($paypage->getContactUrl());
$this->assertNull($paypage->getHelpUrl());
Expand All @@ -191,6 +205,7 @@ public function responseHandlingShouldWorkProperly(): void
$response->imprintUrl = 'imprint url';
$response->privacyPolicyUrl = 'privacy policy url';
$response->termsAndConditionUrl = 'tac url';
$response->css = ['my'=> 'styles'];
$paypage->handleResponse($response);

// then
Expand All @@ -207,6 +222,7 @@ public function responseHandlingShouldWorkProperly(): void
$this->assertEquals('shop description', $paypage->getShopDescription());
$this->assertEquals('shop name', $paypage->getShopName());
$this->assertEquals('tagline', $paypage->getTagline());
$this->assertEquals(['my' => 'styles'], $paypage->getCss());

$this->assertEquals('contact url', $paypage->getContactUrl());
$this->assertEquals('help url', $paypage->getHelpUrl());
Expand Down Expand Up @@ -330,7 +346,8 @@ public function exposeShouldSetBasicParams(): void
->setRedirectUrl('https://redirect.url')
->setOrderId('my order id')
->setInvoiceId('my invoice id')
->setEffectiveInterestRate(4.99);
->setEffectiveInterestRate(4.99)
->setCss(['my' => 'style']);

// then
$expected = [
Expand All @@ -356,7 +373,8 @@ public function exposeShouldSetBasicParams(): void
'orderId' => 'my order id',
'invoiceId' => 'my invoice id',
'excludeTypes' => [],
'additionalAttributes' => ['effectiveInterestRate' => 4.99]
'additionalAttributes' => ['effectiveInterestRate' => 4.99],
'css' => ['my' => 'style']
];
$this->assertEquals($expected, $paypage->expose());
}
Expand Down