Skip to content

Commit dad0dce

Browse files
committed
Add PayPal header image url parameter. Closes thephpleague#55
1 parent 4354f9c commit dad0dce

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

src/Omnipay/PayPal/ExpressGateway.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function getDefaultParameters()
3030
$settings = parent::getDefaultParameters();
3131
$settings['solutionType'] = array('Sole', 'Mark');
3232
$settings['landingPage'] = array('Billing', 'Login');
33+
$settings['headerImageUrl'] = '';
3334

3435
return $settings;
3536
}
@@ -54,6 +55,25 @@ public function setLandingPage($value)
5455
return $this->setParameter('landingPage', $value);
5556
}
5657

58+
public function getHeaderImageUrl()
59+
{
60+
return $this->getParameter('headerImageUrl');
61+
}
62+
63+
/**
64+
* Header Image URL (Optional)
65+
*
66+
* URL for the image you want to appear at the top left of the payment page.
67+
* The image has a maximum size of 750 pixels wide by 90 pixels high.
68+
* PayPal recommends that you provide an image that is stored on a secure (https) server.
69+
* If you do not specify an image, the business name displays.
70+
* Character length and limitations: 127 single-byte alphanumeric characters
71+
*/
72+
public function setHeaderImageUrl($value)
73+
{
74+
return $this->setParameter('headerImageUrl', $value);
75+
}
76+
5777
public function authorize(array $parameters = array())
5878
{
5979
return $this->createRequest('\Omnipay\PayPal\Message\ExpressAuthorizeRequest', $parameters);

src/Omnipay/PayPal/Message/AbstractRequest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ public function setLandingPage($value)
6969
return $this->setParameter('landingPage', $value);
7070
}
7171

72+
public function getHeaderImageUrl()
73+
{
74+
return $this->getParameter('headerImageUrl');
75+
}
76+
77+
public function setHeaderImageUrl($value)
78+
{
79+
return $this->setParameter('headerImageUrl', $value);
80+
}
81+
7282
protected function getBaseData($method)
7383
{
7484
$data = array();

src/Omnipay/PayPal/Message/ExpressAuthorizeRequest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function getData()
3636
$data['RETURNURL'] = $this->getReturnUrl();
3737
$data['CANCELURL'] = $this->getCancelUrl();
3838

39+
if ($headerImageUrl = $this->getHeaderImageUrl()) {
40+
$data['HDRIMG'] = $headerImageUrl;
41+
}
42+
3943
if ($card = $this->getCard()) {
4044
$data['PAYMENTREQUEST_0_SHIPTONAME'] = $card->getName();
4145
$data['PAYMENTREQUEST_0_SHIPTOSTREET'] = $card->getAddress1();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Omnipay package.
5+
*
6+
* (c) Adrian Macneil <adrian@adrianmacneil.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Omnipay\PayPal\Message;
13+
14+
use Omnipay\TestCase;
15+
16+
class ExpressAuthorizeRequestTest extends TestCase
17+
{
18+
public function setUp()
19+
{
20+
parent::setUp();
21+
22+
$this->request = new ExpressAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
23+
$this->request->initialize(
24+
array(
25+
'amount' => 1000,
26+
'returnUrl' => 'https://www.example.com/return',
27+
'cancelUrl' => 'https://www.example.com/cancel',
28+
)
29+
);
30+
}
31+
32+
public function testHeaderImageUrl()
33+
{
34+
$this->request->setHeaderImageUrl('https://www.example.com/image.jpg');
35+
36+
$data = $this->request->getData();
37+
$this->assertEquals('https://www.example.com/image.jpg', $data['HDRIMG']);
38+
}
39+
}

0 commit comments

Comments
 (0)