├── .gitignore
├── tests
├── bootstrap.php
└── GovTalk
│ └── GiftAid
│ ├── Mock
│ ├── SubmitAckResponse.txt
│ ├── DeleteResponse.txt
│ ├── DeclarationResponsePoll.txt
│ ├── SubmitAuthFailureResponse.txt
│ └── RequestClaimDataResponse.txt
│ ├── AuthorisedOfficialTest.php
│ ├── IndividualTest.php
│ ├── TestCase.php
│ ├── ClaimingOrganisationTest.php
│ └── GiftAidTest.php
├── .travis.yml
├── phpunit.xml.dist
├── src
├── AuthorisedOfficial.php
├── Individual.php
├── ClaimingOrganisation.php
└── GiftAid.php
├── composer.json
├── README.md
└── LICENSE.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | composer.lock
3 | composer.phar
4 | phpunit.xml
5 |
--------------------------------------------------------------------------------
/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 | add('GovTalk\\GiftAid\\',__DIR__);
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - "5.6"
5 | - "7.0"
6 | - "7.1"
7 |
8 | before_script:
9 | - composer self-update
10 | - composer --version
11 | - composer install -n --dev --prefer-source
12 |
13 | script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
14 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/Mock/SubmitAckResponse.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Connection: Keep-Alive
3 | Content-Length: 597
4 | Content-Type: text/xml; charset=utf-8
5 |
6 | 2.0HMRC-CHAR-CLMacknowledgementsubmitA19FA1A31BCB42D887EA323292AACD88https://secure.dev.gateway.gov.uk/poll2014-04-11T15:41:39.775
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/Mock/DeleteResponse.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Connection: Keep-Alive
3 | Content-Length: 608
4 | Content-Type: text/xml; charset=utf-8
5 |
6 | 2.0HMRC-CHAR-CLMresponsedelete1397246982960165000B2676DE67004EEFB75F71B3011BEA3Dhttps://secure.dev.gateway.gov.uk/poll2014-04-11T20:10:02.159
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests/
15 |
16 |
17 |
18 |
19 | ./src
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/AuthorisedOfficial.php:
--------------------------------------------------------------------------------
1 | 2.0HMRC-CHAR-CLMresponsesubmit1397246967544096000B2676DE67004EEFB75F71B3011BEA3Dhttps://secure.dev.gateway.gov.uk/pollXML2014-04-11T20:09:52.192
7 |
8 |
9 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/Mock/SubmitAuthFailureResponse.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Connection: Keep-Alive
3 | Content-Length: 791
4 | Content-Type: text/xml; charset=utf-8
5 |
6 | 2.0UndefinedClasserrorsubmithttps://secure.dev.gateway.gov.uk/poll2014-04-11T13:25:05.042Gateway1046fatalAuthentication Failure. The supplied user credentials failed validation for the requested service.
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "justinbusschau/hmrc-gift-aid",
3 | "type": "library",
4 | "description": "A library for charities and CASCs to claim Gift Aid (including Small Donations) from HMRC",
5 | "homepage": "https://github.com/justinbusschau/hmrc-gift-aid",
6 | "license": "GPL-3.0-only",
7 | "authors": [
8 | {
9 | "name": "Jonathon Wardman - Fubra Limited",
10 | "homepage": "http://www.fubra.com/"
11 | },
12 | {
13 | "name": "Long Luong - Veda Consulting",
14 | "email": "long@vedaconsulting.co.uk",
15 | "homepage": "http://www.vedaconsulting.co.uk/uk-hrmc-gift-aid-online-submission/"
16 | },
17 | {
18 | "name": "Justin Busschau",
19 | "email": "justin.busschau@gmail.com"
20 | }
21 | ],
22 | "autoload": {
23 | "psr-4": { "GovTalk\\GiftAid\\" : "src/" }
24 | },
25 | "require": {
26 | "php": ">=5.3.2",
27 | "justinbusschau/php-govtalk": "~0.2.1"
28 | },
29 | "require-dev": {
30 | "guzzle/plugin-mock": "~3.1",
31 | "mockery/mockery": "~0.8",
32 | "phpunit/phpunit": "~3.7.16",
33 | "squizlabs/php_codesniffer": "~1.4"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/Mock/RequestClaimDataResponse.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Connection: Keep-Alive
3 | Content-Length: 649
4 | Content-Type: text/xml; charset=utf-8
5 |
6 | 2.0HMRC-CHAR-CLMresponselist139725685700024100https://secure.dev.gateway.gov.uk/poll2014-04-11T22:54:40.04914/08/2013 14:34:47723F63DC1F4F4133A26EEF5E169BADF3A130814001SUBMISSION_RESPONSE14/08/2013 14:56:4085D984356BA14871B7862C83240CE3A76A10SUBMISSION_RESPONSE14/08/2013 15:06:33EFAACE46039B41CEB382F76DD447338C6A11SUBMISSION_RESPONSE14/08/2013 15:09:06A3371786E84E4B9BB654696C9FC7196A6A12SUBMISSION_RESPONSE14/08/2013 15:11:041A25F3F24488464CA62ED5C452C1D0E06A13SUBMISSION_RESPONSE15/08/2013 15:17:45BE6622CBCA354E77A5A10BC24C29A0A7A4BEBA03C9FC44D78940C89373D465FESUBMISSION_RESPONSE
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/AuthorisedOfficialTest.php:
--------------------------------------------------------------------------------
1 | officer = new AuthorisedOfficial(
26 | 'Mr',
27 | 'Rex',
28 | 'Muck',
29 | '077 1234 5678',
30 | 'SW1A 1AA'
31 | );
32 | }
33 |
34 | public function testAuthorisedOfficialCreation()
35 | {
36 | $this->assertEquals($this->officer->getTitle(), 'Mr');
37 | $this->assertEquals($this->officer->getSurname(), 'Muck');
38 | $this->assertEquals($this->officer->getForename(), 'Rex');
39 | $this->assertEquals($this->officer->getPhone(), '077 1234 5678');
40 | $this->assertEquals($this->officer->getPostcode(), 'SW1A 1AA');
41 | }
42 |
43 | public function testUpdateAuthorisedOfficial()
44 | {
45 | $this->officer->setTitle('Mrs');
46 | $this->officer->setSurname('Malady');
47 | $this->officer->setForename('Regina');
48 | $this->officer->setPhone('020 8765 4321');
49 | $this->officer->setPostcode('NW1A 1AA');
50 |
51 | $this->assertEquals($this->officer->getTitle(), 'Mrs');
52 | $this->assertEquals($this->officer->getSurname(), 'Malady');
53 | $this->assertEquals($this->officer->getForename(), 'Regina');
54 | $this->assertEquals($this->officer->getPhone(), '020 8765 4321');
55 | $this->assertEquals($this->officer->getPostcode(), 'NW1A 1AA');
56 | }
57 |
58 | public function testHouseNumOmission()
59 | {
60 | $this->assertNull($this->officer->getHouseNum());
61 |
62 | $this->officer->setHouseNum('any');
63 |
64 | $this->assertNull($this->officer->getHouseNum());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/Individual.php:
--------------------------------------------------------------------------------
1 | title = $title;
27 | $this->surname = $surname;
28 | $this->forename = $name;
29 | $this->phone = $phone;
30 | $this->houseNum = $houseNum;
31 | $this->postcode = $postcode;
32 | $this->isOverseas = $overseas;
33 | }
34 |
35 | public function getTitle()
36 | {
37 | return $this->title;
38 | }
39 |
40 | public function setTitle($value)
41 | {
42 | $this->title = $value;
43 | }
44 |
45 | public function getSurname()
46 | {
47 | return $this->surname;
48 | }
49 |
50 | public function setSurname($value)
51 | {
52 | $this->surname = $value;
53 | }
54 |
55 | public function getForename()
56 | {
57 | return $this->forename;
58 | }
59 |
60 | public function setForename($value)
61 | {
62 | $this->forename = $value;
63 | }
64 |
65 | public function getPhone()
66 | {
67 | return $this->phone;
68 | }
69 |
70 | public function setPhone($value)
71 | {
72 | $this->phone = $value;
73 | }
74 |
75 | public function getHouseNum()
76 | {
77 | return $this->houseNum;
78 | }
79 |
80 | public function setHouseNum($value)
81 | {
82 | $this->houseNum = substr($value, 0, 40);
83 | }
84 |
85 | public function getPostcode()
86 | {
87 | return $this->postcode;
88 | }
89 |
90 | public function setPostcode($value)
91 | {
92 | $this->postcode = $value;
93 | }
94 |
95 | public function getIsOverseas()
96 | {
97 | return ($this->isOverseas === true) ? 'yes' : 'no';
98 | }
99 |
100 | public function setIsOverseas($value)
101 | {
102 | $this->isOverseas = $value;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/ClaimingOrganisation.php:
--------------------------------------------------------------------------------
1 | name = $name;
31 | $this->hmrcRef = $hmrcRef;
32 | $this->regulator = $regulator;
33 | $this->regNo = $regNo;
34 | }
35 |
36 | public function getName()
37 | {
38 | return $this->name;
39 | }
40 |
41 | public function setName($value)
42 | {
43 | $this->name = $value;
44 | }
45 |
46 | public function getHmrcRef()
47 | {
48 | return $this->hmrcRef;
49 | }
50 |
51 | public function setHmrcRef($value)
52 | {
53 | $this->hmrcRef = $value;
54 | }
55 |
56 | public function getRegulator()
57 | {
58 | return $this->regulator;
59 | }
60 |
61 | public function setRegulator($value)
62 | {
63 | $this->regulator = $value;
64 | }
65 |
66 | public function getRegNo()
67 | {
68 | return $this->regNo;
69 | }
70 |
71 | public function setRegNo($value)
72 | {
73 | $this->regNo = $value;
74 | }
75 |
76 | public function getHasConnectedCharities()
77 | {
78 | return $this->hasConnectedCharities;
79 | }
80 |
81 | public function setHasConnectedCharities($value)
82 | {
83 | if (is_bool($value)) {
84 | $this->hasConnectedCharities = $value;
85 | } else {
86 | $this->hasConnectedCharities = false;
87 | }
88 | }
89 |
90 | public function getConnectedCharities()
91 | {
92 | return $this->connectedCharities;
93 | }
94 |
95 | public function addConnectedCharity(ClaimingOrganisation $connectedCharity)
96 | {
97 | $this->connectedCharities[] = $connectedCharity;
98 | }
99 |
100 | public function clearConnectedCharities()
101 | {
102 | $this->connectedCharities = array();
103 | }
104 |
105 | public function getUseCommunityBuildings()
106 | {
107 | return $this->useCommunityBuildings;
108 | }
109 |
110 | public function setUseCommunityBuildings($value)
111 | {
112 | if (is_bool($value)) {
113 | $this->useCommunityBuildings = $value;
114 | } else {
115 | $this->useCommunityBuildings = false;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/IndividualTest.php:
--------------------------------------------------------------------------------
1 | individual = new Individual(
26 | 'Mr',
27 | 'Rex',
28 | 'Muck',
29 | '077 1234 5678',
30 | '3',
31 | 'SW1A 1AA'
32 | );
33 |
34 | $this->foreign = new Individual(
35 | 'Ds',
36 | 'Johannes',
37 | 'Doper',
38 | '011 452 1256',
39 | '27',
40 | '',
41 | true
42 | );
43 | }
44 |
45 | public function testIndividualCreation()
46 | {
47 | $this->assertEquals($this->individual->getTitle(), 'Mr');
48 | $this->assertEquals($this->individual->getSurname(), 'Muck');
49 | $this->assertEquals($this->individual->getForename(), 'Rex');
50 | $this->assertEquals($this->individual->getPhone(), '077 1234 5678');
51 | $this->assertEquals($this->individual->getHouseNum(), '3');
52 | $this->assertEquals($this->individual->getPostcode(), 'SW1A 1AA');
53 | $this->assertEquals($this->individual->getIsOverseas(), 'no');
54 | }
55 |
56 | public function testForeignIndividualCreation()
57 | {
58 | $this->assertEquals($this->foreign->getTitle(), 'Ds');
59 | $this->assertEquals($this->foreign->getSurname(), 'Doper');
60 | $this->assertEquals($this->foreign->getForename(), 'Johannes');
61 | $this->assertEquals($this->foreign->getPhone(), '011 452 1256');
62 | $this->assertEquals($this->foreign->getHouseNum(), '27');
63 | $this->assertEquals($this->foreign->getPostcode(), '');
64 | $this->assertEquals($this->foreign->getIsOverseas(), 'yes');
65 | }
66 |
67 | public function testUpdateIndividual()
68 | {
69 | $this->individual->setTitle('Mrs');
70 | $this->individual->setSurname('Malady');
71 | $this->individual->setForename('Regina');
72 | $this->individual->setPhone('020 8765 4321');
73 | $this->individual->setHouseNum('2');
74 | $this->individual->setPostcode('NW1A 1AA');
75 | $this->individual->setIsOverseas(false);
76 |
77 | $this->assertEquals($this->individual->getTitle(), 'Mrs');
78 | $this->assertEquals($this->individual->getSurname(), 'Malady');
79 | $this->assertEquals($this->individual->getForename(), 'Regina');
80 | $this->assertEquals($this->individual->getPhone(), '020 8765 4321');
81 | $this->assertEquals($this->individual->getHouseNum(), '2');
82 | $this->assertEquals($this->individual->getPostcode(), 'NW1A 1AA');
83 | $this->assertEquals($this->individual->getIsOverseas(), 'no');
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/TestCase.php:
--------------------------------------------------------------------------------
1 | httpClient === null) {
35 | $this->httpClient = new HttpClient;
36 | }
37 |
38 | return $this->httpClient;
39 | }
40 |
41 | /**
42 | * Mark a request as being mocked
43 | *
44 | * @param GuzzleRequestInterface $request
45 | * @return self
46 | */
47 | public function addMockedHttpRequest(GuzzleRequestInterface $request)
48 | {
49 | $this->mockHttpRequests[] = $request;
50 |
51 | return $this;
52 | }
53 |
54 | /**
55 | * Get a mock response for a client by mock file name
56 | *
57 | * @param string $path Relative path to the mock response file
58 | * @return Response
59 | */
60 | public function getMockHttpResponse($path)
61 | {
62 | if ($path instanceof Response) {
63 | return $path;
64 | }
65 |
66 | $ref = new ReflectionObject($this);
67 | $dir = dirname($ref->getFileName());
68 |
69 | // if mock file doesn't exist, check parent directory
70 | if (!file_exists($dir.'/Mock/'.$path) && file_exists($dir.'/../Mock/'.$path)) {
71 | return MockPlugin::getMockFile($dir.'/../Mock/'.$path);
72 | }
73 |
74 | return MockPlugin::getMockFile($dir.'/Mock/'.$path);
75 | }
76 |
77 | /**
78 | * Set a mock response from a mock file for the next client request.
79 | *
80 | * @param string $paths Path to the mock response file
81 | * @return MockPlugin returns the mock plugin
82 | */
83 | public function setMockHttpResponse($paths)
84 | {
85 | $this->mockHttpRequests = array();
86 | $that = $this;
87 | $mock = new MockPlugin(null, true);
88 | $this->getHttpClient()->getEventDispatcher()->removeSubscriber($mock);
89 | $mock->getEventDispatcher()->addListener('mock.request', function(Event $event) use ($that) {
90 | $that->addMockedHttpRequest($event['request']);
91 | });
92 |
93 | foreach ((array) $paths as $path) {
94 | $mock->addResponse($this->getMockHttpResponse($path));
95 | }
96 |
97 | $this->getHttpClient()->getEventDispatcher()->addSubscriber($mock);
98 |
99 | return $mock;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/ClaimingOrganisationTest.php:
--------------------------------------------------------------------------------
1 | claimant = new ClaimingOrganisation(
26 | 'A Charitible Crowd',
27 | 'AB12345',
28 | 'CCEW',
29 | '2584789658'
30 | );
31 | }
32 |
33 | public function testOrganisationCreation()
34 | {
35 | $this->assertEquals($this->claimant->getName(), 'A Charitible Crowd');
36 | $this->assertEquals($this->claimant->getHmrcRef(), 'AB12345');
37 | $this->assertEquals($this->claimant->getRegulator(), 'CCEW');
38 | $this->assertEquals($this->claimant->getRegNo(), '2584789658');
39 | }
40 |
41 | public function testOrganisationChange()
42 | {
43 | $this->claimant->setName('Another Fine Bunch');
44 | $this->claimant->setHmrcRef('CD67890');
45 | $this->claimant->setRegulator('OSCR');
46 | $this->claimant->setRegNo('3695897469');
47 |
48 | $this->assertEquals($this->claimant->getName(), 'Another Fine Bunch');
49 | $this->assertEquals($this->claimant->getHmrcRef(), 'CD67890');
50 | $this->assertEquals($this->claimant->getRegulator(), 'OSCR');
51 | $this->assertEquals($this->claimant->getRegNo(), '3695897469');
52 | }
53 |
54 | public function testConnectedCharities()
55 | {
56 | $this->claimant->setHasConnectedCharities(true);
57 | $this->assertTrue($this->claimant->getHasConnectedCharities());
58 |
59 | // non-bool values are treated as false
60 | $this->claimant->setHasConnectedCharities('0');
61 | $this->assertFalse($this->claimant->getHasConnectedCharities());
62 |
63 | $org = new ClaimingOrganisation(
64 | 'Giving Is Good',
65 | 'EF24680',
66 | 'CCEW',
67 | '8526321452'
68 | );
69 |
70 | $this->claimant->addConnectedCharity($org);
71 |
72 | $org_a = $this->claimant->getConnectedCharities();
73 | $this->assertEquals(count($org_a), 1);
74 |
75 | $org->setName('Greater Give');
76 | $org->setHmrcRef('GH13579');
77 | $org->setRegulator('OSCR');
78 | $org->setRegNo('6542147854');
79 | $this->claimant->addConnectedCharity($org);
80 |
81 | $org_a = $this->claimant->getConnectedCharities();
82 | $this->assertEquals(count($org_a), 2);
83 |
84 | $this->claimant->clearConnectedCharities();
85 | $org_a = $this->claimant->getConnectedCharities();
86 | $this->assertEquals(count($org_a), 0);
87 | }
88 |
89 | public function testCommunityBuildings()
90 | {
91 | $this->claimant->setUseCommunityBuildings(false);
92 | $this->assertFalse($this->claimant->getUseCommunityBuildings());
93 |
94 | // non-bool values are treated as false
95 | $this->claimant->setUseCommunityBuildings('1');
96 | $this->assertFalse($this->claimant->getUseCommunityBuildings());
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HMRC (Gift Aid) Charity Repayment Claims
2 |
3 | **A library for charities and CASCs to claim Gift Aid (including Small Donations) from HMRC**
4 |
5 | [](https://travis-ci.org/JustinBusschau/hmrc-gift-aid)
6 | [](https://packagist.org/packages/justinbusschau/hmrc-gift-aid)
7 | [](https://packagist.org/packages/justinbusschau/hmrc-gift-aid)
8 | [](https://packagist.org/packages/justinbusschau/hmrc-gift-aid)
9 |
10 | 'Gift Aid' is a UK tax incentive that enables tax-effective giving by individuals to charities
11 | in the United Kingdom. Gift Aid increases the value of donations to charities and Community
12 | Amateur Sports Clubs (CASCs) by allowing them to reclaim basic rate tax on a donor's gift.
13 |
14 | 'HMRC Charity Repayment Claims' is a library for submitting Gift Aid claims to HMRC.
15 |
16 |
17 | ## Installation
18 |
19 | The library can be installed via [Composer](http://getcomposer.org/). To install, simply add
20 | it to your `composer.json` file:
21 |
22 | ```json
23 | {
24 | "require": {
25 | "justinbusschau/hmrc-gift-aid": "0.*"
26 | }
27 | }
28 | ```
29 |
30 | And run composer to update your dependencies:
31 |
32 | $ curl -s http://getcomposer.org/installer | php
33 | $ php composer.phar update
34 |
35 |
36 | ## Some notes on the library and Data Persistance
37 |
38 | From the introduction to the [IRMark Specification](http://www.hmrc.gov.uk/softwaredevelopers/hmrcmark/generic-irmark-specification-v1-2.pdf):
39 |
40 | > There is legislation in place that states that in the case of a civil dispute between the
41 | > Inland Revenue (IR) and a taxpayer with regards to an Internet online submission, the
42 | > submission held by the Inland Revenue is presumed to be correct unless the taxpayer can
43 | > prove otherwise. In other words the burden of proof is on the taxpayer. There is therefore
44 | > a requirement to enable the IR Online services and software that uses the services to provide
45 | > a mechanism to aid a taxpayer to prove whether or not the submission held by IR is indeed the
46 | > submission they sent.
47 |
48 | That is a very roundabout way of saying the XML that you submit must include a signiture of some
49 | sort. The signature can be used to prove that what the HMRC received is actually what you
50 | intended to send. HMRC will, in their turn, include a similar signiture in any responses they
51 | send to you. In the case of submissions to the HMRC Government Gateway, this signature is the
52 | IRmark (pronounced IR Mark).
53 |
54 | It is strongly recommended that both the XML that you send and the XML that you receive should
55 | be stored in case there is any dispute over the claim - be that a dispute over the submission
56 | of the claim or over the content of the claim itself.
57 |
58 | This library will generate the appropriate IRmark signature for all outgoing messages and check
59 | the IRmark on all incoming messages. This library, however, does not attempt to store or in any
60 | way persist any data whatsoever. This means that your application will need to store a number of
61 | pieces of information for use during dispute resolution. Having said that, it is not necessary
62 | to store ALL messages sent to or received from the gateway. The following is a recommended set
63 | of data to be stored by your application.
64 |
65 | - **HMRC Correlation ID** This will be generated by HMRC when you send your request and returned
66 | in all subsequent messages. You will also need to supply this correlation ID when submitting
67 | any messages or queries related to the claim. While it is not essential to store this, I do
68 | recommend it.
69 |
70 | - **The Claim Request** The communication protocol requires a number of messages to be exchanged
71 | in the course of a claim submission. I recommend storing only the initial claim request as this
72 | is the message that will contain all the claim data. Other messages simply facilitate the
73 | assured delivery of that initial message.
74 |
75 | - **The Claim Response** This is not necessarily the first message you get back after sending
76 | your Request - there will be polling and other protocol messages first. HMRC will first verify
77 | the validity of the submitted claim (*__note__ this is verifying that the structure of the
78 | message is valid and that the data conforms to the required standards*). Once this is done you
79 | will receive a response message with an acknowledgement similar to this:
80 | ```
81 | HMRC has received the HMRC-CHAR-CLM document ref: AA12345 at 09.10 on 01/01/2014. The
82 | associated IRmark was: XXX9XXX9XXX9XXX9XXX9XXX9XXX9XXX9. We strongly recommend that you
83 | keep this receipt electronically, and we advise that you also keep your submission
84 | electronically for your records. They are evidence of the information that you submitted
85 | to HMRC.
86 | ```
87 |
88 | See the sample source code below to see how and where to extract the above data from the
89 | library.
90 |
91 | ## Basic Usage
92 |
93 | ### Preparing your data
94 |
95 | The first thing you need is to identify both the organisation(s) and the individual
96 | submitting the Gift Aid claim.
97 |
98 | The `Vendor` data identifies the company and software product used to submit the claims. Each
99 | vendor is assigned a Vendor ID and is required to identify the software that will submit the
100 | claims. To obtain an ID, please see the
101 | [Charities Online Service Recognition Process](http://www.hmrc.gov.uk/softwaredevelopers/gift-aid-repayments.htm#5).
102 |
103 | ```php
104 | $vendor = array(
105 | 'id' => '4321',
106 | 'product' => 'ProductNameHere',
107 | 'version' => '0.1.2'
108 | );
109 | ```
110 |
111 | The `Authorised Official` is an individual within the organisation (Charity or CASC) that
112 | has been previously identified to HMRC as having the authority to submit claims on behalf of
113 | the organisation. That individual will register for an account to log in to Charities Online
114 | and the user ID and password are required when submitting claims. The additional data sent
115 | with the claim - name and contact details - must be consistent with that held by HMRC.
116 |
117 | ```php
118 | $authorised_official = array(
119 | 'id' => '323412300001',
120 | 'passwd' => 'testing1',
121 | 'title' => 'Mr',
122 | 'name' => 'Rex',
123 | 'surname' => 'Muck',
124 | 'phone' => '077 1234 5678',
125 | 'postcode' => 'SW1A 1AA'
126 | );
127 | ```
128 |
129 | Each Charity or CASC that is registered with HMRC will have two identifiers. The first is the
130 | `Charity ID` which is a number issued by HMRC when registering as a charity. The second is the
131 | `Charities Commission Reference` which is issued by the relevant charity regulator. We also
132 | need to know which regulator the charity is registered with.
133 |
134 | ```php
135 | $charity = array(
136 | 'name' => 'A charitible organisation',
137 | 'id' => 'AB12345',
138 | 'reg_no' => '2584789658',
139 | 'regulator' => 'CCEW'
140 | );
141 | ```
142 |
143 | Finally, you will need to build a list of all donations for which you want to claim a Gift Aid
144 | repayment. For each donation you will also need to know the name and last known address of the
145 | donor.
146 |
147 | ```php
148 | $claim_items = array(
149 | array(
150 | 'donation_date' => '2014-01-01',
151 | 'title' => 'Mr',
152 | 'first_name' => 'Jack',
153 | 'last_name' => 'Peasant',
154 | 'house_no' => '3',
155 | 'postcode' => 'EC1A 2AB',
156 | 'amount' => '123.45'
157 | ),
158 | array(
159 | 'donation_date' => '2014-01-01',
160 | 'title' => 'Mrs',
161 | 'first_name' => 'Josephine',
162 | 'last_name' => 'Peasant',
163 | 'house_no' => '3',
164 | 'postcode' => 'EC1A 2AB',
165 | 'amount' => '876.55'
166 | )
167 | );
168 | ```
169 |
170 | And now that you have all the data you need, you can submit a claim.
171 |
172 | ### Preparing to send a request
173 |
174 | This applies to all cases below. Whenever you need to send something to HMRC you will need to
175 | prepare the gaService object as shown here.
176 |
177 | ```php
178 | $gaService = new GiftAid(
179 | $authorised_official['id'],
180 | $authorised_official['passwd'],
181 | $vendor['id'],
182 | $vendor['product'],
183 | $vendor['version'],
184 | true // Test mode. Leave this off or set to false for live claim submission
185 | );
186 |
187 | $gaService->setCharityId($charity['id']);
188 | $gaService->setClaimToDate('2014-01-01'); // date of most recent donation
189 |
190 | $gaService->setAuthorisedOfficial(
191 | new AuthorisedOfficial(
192 | $authorised_official['title'],
193 | $authorised_official['name'],
194 | $authorised_official['surname'],
195 | $authorised_official['phone'],
196 | $authorised_official['postcode']
197 | )
198 | );
199 |
200 | $gaService->setClaimingOrganisation(
201 | new ClaimingOrganisation(
202 | $charity['name'],
203 | $charity['id'],
204 | $charity['regulator'],
205 | $charity['reg_no']
206 | )
207 | );
208 | ```
209 |
210 | ### Submitting a new claim
211 |
212 | Once you have prepared the gaService object and collected your donations and donor data, you
213 | are ready to send the claim.
214 |
215 | ```php
216 | $gaService->setCompress(true);
217 |
218 | $response = $gaService->giftAidSubmit($claim_items);
219 |
220 | if (isset($response['errors'])) {
221 | // TODO: deal with the $response['errors']
222 | } else {
223 | // giftAidSubmit returned no errors
224 | $correlation_id = $response['correlationid']; // TODO: store this !
225 | $endpoint = $response['endpoint'];
226 | }
227 |
228 | if ($correlation_id !== NULL) {
229 | $pollCount = 0;
230 | while ($pollCount < 3 and $response !== false) {
231 | $pollCount++;
232 | if (
233 | isset($response['interval']) and
234 | isset($response['endpoint']) and
235 | isset($response['correlationid'])
236 | ) {
237 | sleep($response['interval']);
238 |
239 | $response = $gaService->declarationResponsePoll(
240 | $response['correlationid'],
241 | $response['endpoint']
242 | );
243 |
244 | if (isset($response['errors'])) {
245 | // TODO: deal with the $response['errors']
246 | }
247 |
248 | } elseif (
249 | isset($response['correlationid']) and
250 | isset($response['submission_response'])
251 | ) {
252 | // TODO: store the submission_response and send the delete message
253 | $hmrc_response => $response['submission_response']; // TODO: store this !
254 |
255 | $response = !$gaService->sendDeleteRequest();
256 | }
257 | }
258 | }
259 | ```
260 |
261 | ### Submitting adjustments with a claim
262 |
263 | If you submit a claim and then subsequently need to reverse or refund a donation for which
264 | you have already claimed Gift Aid, you will need to submit an adjustment with your next claim.
265 | The adjustment value is set to the value of the refund you have already been paid for the
266 | refunded donation. In other words if you claim Gift Aid on a £100.00 donation you will be paid
267 | £25.00 by HMRC. If you subsequently refund that £100.00 you submit an adjustment to HMRC for
268 | the £25.00.
269 |
270 | Prepare the gaService object and your claim items as usual, but before calling `giftAidSubmit`
271 | add the adjustment as shown below.
272 |
273 | ```php
274 | // submit an adjustment to a previously submitted claim
275 | $gaService->setGaAdjustment('34.89', 'Refunds issued on two previous donations.');
276 | ```
277 |
278 | ### Querying a previously submitted claim
279 |
280 | Prepare the gaService object in the usual way and then call `requestClaimData`. This will
281 | return a list of all previously submitted claims with status. It's a good idea to delete older
282 | claim records - if nothing else it prevents having to download them all every time you need to
283 | call `requestClaimData`.
284 |
285 | ```php
286 | $response = $gaService->requestClaimData();
287 | foreach ($response['statusRecords'] as $status_record) {
288 | // TODO: deal with the $status_record as you please
289 |
290 | if (
291 | $status_record['Status'] == 'SUBMISSION_RESPONSE' AND
292 | $status_record['CorrelationID'] != ''
293 | ) {
294 | $gaService->sendDeleteRequest($status_record['CorrelationID'], 'HMRC-CHAR-CLM');
295 | }
296 | }
297 | ```
298 |
299 |
300 | ## More Information
301 |
302 | For more information on the Gift Aid scheme as it applies to Charities and Community Amateur
303 | Sports Clubs, and for information on Online Claim Submission, please see the
304 | [HMRC](http://www.hmrc.gov.uk/charities/) website.
305 |
306 | For information on developing and testing using HMRC Document Submission Protocol, please see
307 | [HMRC Software Developers](http://www.hmrc.gov.uk/softwaredevelopers/gift-aid-repayments.htm).
308 |
309 |
--------------------------------------------------------------------------------
/tests/GovTalk/GiftAid/GiftAidTest.php:
--------------------------------------------------------------------------------
1 | gatewayUserID = 'XMLGatewayTestUserID';
57 | $this->gatewayUserPassword = 'XMLGatewayTestPassword';
58 | $this->gatewayVendorID = 'GatewaySubmitter';
59 | $this->gatewaySoftware = 'GivingSoft';
60 | $this->gatewaySoftVersion = '1.2.0';
61 |
62 | /**
63 | * An authorised official for testing ...
64 | */
65 | $this->officer = new AuthorisedOfficial(
66 | null,
67 | 'Bob',
68 | 'Smith',
69 | '01234 567890',
70 | 'AB12 3CD'
71 | );
72 |
73 | /**
74 | * A claiming organisation
75 | */
76 | $this->claimant = new ClaimingOrganisation(
77 | 'A Fundraising Organisation',
78 | 'AB12345',
79 | 'CCEW',
80 | '123456'
81 | );
82 |
83 | /**
84 | * A test claim
85 | */
86 | $this->claim = array(
87 | array(
88 | 'donation_date' => '2013-04-07',
89 | 'title' => 'Mrs',
90 | 'first_name' => 'Mary',
91 | 'last_name' => 'Smith',
92 | 'house_no' => '100',
93 | 'postcode' => 'AB23 4CD',
94 | 'overseas' => false,
95 | 'amount' => 500.00,
96 | 'sponsored' => true
97 | ),
98 | array(
99 | 'donation_date' => '2013-04-15',
100 | 'title' => null,
101 | 'first_name' => 'Jim',
102 | 'last_name' => 'Harris',
103 | 'house_no' => '25 High St Anytown Foreignshire',
104 | 'postcode' => null,
105 | 'overseas' => true,
106 | 'amount' => 10.00
107 | ),
108 | array(
109 | 'donation_date' => '2013-04-17',
110 | 'title' => null,
111 | 'first_name' => 'Bill',
112 | 'last_name' => 'Hill-Jones',
113 | 'house_no' => '1',
114 | 'postcode' => 'BA23 9CD',
115 | 'overseas' => false,
116 | 'amount' => 2.50
117 | ),
118 | array(
119 | 'donation_date' => '2013-04-20',
120 | 'title' => null,
121 | 'first_name' => 'Bob',
122 | 'last_name' => 'Hill-Jones',
123 | 'house_no' => '1',
124 | 'postcode' => 'BA23 9CD',
125 | 'overseas' => false,
126 | 'amount' => 12.00
127 | ),
128 | array(
129 | 'donation_date' => '2013-04-20',
130 | 'amount' => 1000.00,
131 | 'aggregation' => 'Aggregated donation of 200 x �5 payments from members'
132 | )
133 | );
134 |
135 | /**
136 | * The following call sets up the service object used to interact with the
137 | * Government Gateway. Setting parameter 4 to null will force the test to
138 | * use the httpClient created on the fly within the GovTalk class and may
139 | * also effectively disable mockability.
140 | * Set parameter 5 to a valid path in order to log messages
141 | */
142 | $this->gaService = $this->setUpService();
143 | }
144 |
145 | private function setUpService()
146 | {
147 | return new GiftAid(
148 | $this->gatewayUserID,
149 | $this->gatewayUserPassword,
150 | $this->gatewayVendorID,
151 | $this->gatewaySoftware,
152 | $this->gatewaySoftVersion,
153 | true,
154 | $this->getHttpClient()
155 | );
156 | }
157 |
158 | public function testServiceCreation()
159 | {
160 | $this->gaService->setAgentDetails('company', array('ln1','ln2','pc'), array('07123456789'));
161 | $this->assertInstanceOf('GovTalk\GiftAid\GiftAid', $this->gaService);
162 | }
163 |
164 | public function testCharityId()
165 | {
166 | $value = uniqid();
167 | $this->gaService->setCharityId($value);
168 | $this->assertSame($value, $this->gaService->getCharityId());
169 | }
170 |
171 | public function testVendorId()
172 | {
173 | $value = uniqid();
174 | $this->gaService->setVendorId($value);
175 | $this->assertSame($value, $this->gaService->getVendorId());
176 | }
177 |
178 | public function testProductUri()
179 | {
180 | $value = uniqid();
181 | $this->gaService->setProductUri($value);
182 | $this->assertSame($value, $this->gaService->getProductUri());
183 | }
184 |
185 | public function testProductName()
186 | {
187 | $value = uniqid();
188 | $this->gaService->setProductName($value);
189 | $this->assertSame($value, $this->gaService->getProductName());
190 | }
191 |
192 | public function testProductVersion()
193 | {
194 | $value = uniqid();
195 | $this->gaService->setProductVersion($value);
196 | $this->assertSame($value, $this->gaService->getProductVersion());
197 | }
198 |
199 | public function testConnectedCharities()
200 | {
201 | $this->gaService->setConnectedCharities(false);
202 | $this->assertFalse($this->gaService->getConnectedCharities());
203 |
204 | $this->gaService->setConnectedCharities(true);
205 | $this->assertTrue($this->gaService->getConnectedCharities());
206 |
207 | // non-bool values are treated as false
208 | $this->gaService->setConnectedCharities('1');
209 | $this->assertFalse($this->gaService->getConnectedCharities());
210 | }
211 |
212 | public function testCommunityBuildings()
213 | {
214 | $this->gaService->setCommunityBuildings(false);
215 | $this->assertFalse($this->gaService->getCommunityBuildings());
216 |
217 | $this->gaService->setCommunityBuildings(true);
218 | $this->assertTrue($this->gaService->getCommunityBuildings());
219 |
220 | // non-bool values are treated as false
221 | $this->gaService->setCommunityBuildings('1');
222 | $this->assertFalse($this->gaService->getCommunityBuildings());
223 | }
224 |
225 | public function testCbcd()
226 | {
227 | $this->gaService->addCbcd('bldg', 'address', 'postcode', '2014', 12.34);
228 | $this->gaService->resetCbcd();
229 | }
230 |
231 | public function testClaimToDate()
232 | {
233 | $value = uniqid();
234 | $this->gaService->setClaimToDate($value);
235 | $this->assertSame($value, $this->gaService->getClaimToDate());
236 | }
237 |
238 | public function testAuthorisedOfficial()
239 | {
240 | $this->gaService->setAuthorisedOfficial($this->officer);
241 | $this->assertSame($this->officer, $this->gaService->getAuthorisedOfficial());
242 | }
243 |
244 | public function testClaimingOrganisation()
245 | {
246 | $this->gaService->setClaimingOrganisation($this->claimant);
247 | $this->assertSame($this->claimant, $this->gaService->getClaimingOrganisation());
248 | }
249 |
250 | public function testEndpoint()
251 | {
252 | $testEndpoint = $this->gaService->getEndpoint(true);
253 | $liveEndpoint = $this->gaService->getEndpoint(false);
254 |
255 | $this->assertNotSame($liveEndpoint, $testEndpoint);
256 | }
257 |
258 | public function testAdjustments()
259 | {
260 | $clear = array('amount' => 0.00, 'reason' => '');
261 | $adjust = array('amount' => 16.47, 'reason' => 'Refunds issued on previous donations.');
262 |
263 | $this->gaService->setGaAdjustment(
264 | $adjust['amount'],
265 | $adjust['reason']
266 | );
267 | $this->assertSame($adjust, $this->gaService->getGaAdjustment());
268 |
269 | $this->gaService->clearGaAdjustment();
270 | $this->assertSame($clear, $this->gaService->getGaAdjustment());
271 | }
272 |
273 | public function testGasds()
274 | {
275 | $clear = array('amount' => 0.00, 'reason' => '');
276 | $adjust = array('amount' => 16.47, 'reason' => 'Refunds issued on previous GASDS donations.');
277 |
278 | $this->gaService->setGasdsAdjustment(
279 | $adjust['amount'],
280 | $adjust['reason']
281 | );
282 | $this->assertSame($adjust, $this->gaService->getGasdsAdjustment());
283 |
284 | $this->gaService->setGasdsAdjustment(
285 | $clear['amount'],
286 | $clear['reason']
287 | );
288 | $this->assertSame($clear, $this->gaService->getGasdsAdjustment());
289 |
290 | $this->gaService->addGasds('2014', 15.26);
291 | $this->gaService->resetGasds();
292 | }
293 |
294 | public function testCompress()
295 | {
296 | $this->gaService->setCompress(false);
297 | $this->assertFalse($this->gaService->getCompress());
298 |
299 | $this->gaService->setCompress(true);
300 | $this->assertTrue($this->gaService->getCompress());
301 |
302 | // non-bool values are treated as false
303 | $this->gaService->setCompress('1');
304 | $this->assertFalse($this->gaService->getCompress());
305 | }
306 |
307 | public function testClaimSubmissionAuthFailure()
308 | {
309 | $this->setMockHttpResponse('SubmitAuthFailureResponse.txt');
310 |
311 | $this->gaService->setAuthorisedOfficial($this->officer);
312 | $this->gaService->setClaimingOrganisation($this->claimant);
313 | $response = $this->gaService->giftAidSubmit($this->claim);
314 |
315 | $this->assertArrayHasKey('errors', $response);
316 | $this->assertArrayHasKey('fatal', $response['errors']);
317 | $this->assertSame('1046', $response['errors']['fatal'][0]['number']);
318 | $this->assertSame(
319 | 'Authentication Failure. The supplied user credentials failed validation for the requested service.',
320 | $response['errors']['fatal'][0]['text']
321 | );
322 | }
323 |
324 | public function testClaimSubmissionAck()
325 | {
326 | $this->setMockHttpResponse('SubmitAckResponse.txt');
327 |
328 | $this->gaService->setAuthorisedOfficial($this->officer);
329 | $this->gaService->setClaimingOrganisation($this->claimant);
330 | $response = $this->gaService->giftAidSubmit($this->claim);
331 |
332 | $this->assertArrayNotHasKey('errors', $response);
333 | //$this->assertSame('acknowledgement', $this->gaService->getResponseQualifier());
334 | $this->assertArrayHasKey('correlationid', $response);
335 | $this->assertArrayHasKey('endpoint', $response);
336 | $this->assertArrayHasKey('interval', $response);
337 | $this->assertSame('A19FA1A31BCB42D887EA323292AACD88', $response['correlationid']);
338 | }
339 |
340 | public function testDeclarationResponsePoll()
341 | {
342 | $this->setMockHttpResponse('DeclarationResponsePoll.txt');
343 |
344 | $response = $this->gaService->declarationResponsePoll(
345 | 'A19FA1A31BCB42D887EA323292AACD88',
346 | 'https://secure.dev.gateway.gov.uk/poll'
347 | );
348 |
349 | $this->assertArrayNotHasKey('errors', $response);
350 | //$this->assertSame('response', $this->gaService->getResponseQualifier());
351 | $this->assertArrayHasKey('correlationid', $response);
352 | $this->assertSame('A19FA1A31BCB42D887EA323292AACD88', $response['correlationid']);
353 | }
354 |
355 | public function testRequestClaimData()
356 | {
357 | $this->setMockHttpResponse('RequestClaimDataResponse.txt');
358 |
359 | $this->gaService->setAuthorisedOfficial($this->officer);
360 | $this->gaService->setClaimingOrganisation($this->claimant);
361 | $response = $this->gaService->requestClaimData();
362 |
363 | $this->assertArrayNotHasKey('errors', $response);
364 | }
365 |
366 | public function testDeleteRequest()
367 | {
368 | $this->setMockHttpResponse('DeleteResponse.txt');
369 |
370 | $this->gaService->setAuthorisedOfficial($this->officer);
371 | $this->gaService->setClaimingOrganisation($this->claimant);
372 | $response = $this->gaService->sendDeleteRequest(
373 | 'BE6622CBCA354E77A5A10BC24C29A0A7',
374 | 'HMRC-CHAR-CLM'
375 | );
376 |
377 | $this->assertTrue($response);
378 | }
379 | }
380 |
--------------------------------------------------------------------------------
/src/GiftAid.php:
--------------------------------------------------------------------------------
1 | getEndpoint($test);
167 |
168 | $this->setProductUri($route_uri);
169 | $this->setProductName($software_name);
170 | $this->setProductVersion($software_version);
171 | $this->setTestFlag($test);
172 |
173 | parent::__construct(
174 | $endpoint,
175 | $sender_id,
176 | $password,
177 | $httpClient,
178 | $messageLogLocation
179 | );
180 |
181 | $this->setMessageAuthentication('clear');
182 | }
183 |
184 | /**
185 | * Find out which endpoint to use
186 | *
187 | * @param $test TRUE if in test mode, else (default) FALSE
188 | */
189 | public function getEndpoint($test = false)
190 | {
191 | $test = is_bool($test) ? $test : false;
192 |
193 | return $test ? $this->devEndpoint : $this->liveEndpoint;
194 | }
195 |
196 | /**
197 | * Some getters and setters for our internal properties.
198 | */
199 | public function getCharityId()
200 | {
201 | if (!is_null($this->getClaimingOrganisation())) {
202 | return $this->getClaimingOrganisation()->getHmrcRef();
203 | } else {
204 | return false;
205 | }
206 | }
207 |
208 | public function setCharityId($value)
209 | {
210 | if (is_null($this->getClaimingOrganisation())) {
211 | $this->setClaimingOrganisation(
212 | new ClaimingOrganisation()
213 | );
214 | }
215 | $this->getClaimingOrganisation()->setHmrcRef($value);
216 | }
217 |
218 | public function getVendorId()
219 | {
220 | return $this->vendorId;
221 | }
222 |
223 | public function setVendorId($value)
224 | {
225 | $this->vendorId = $value;
226 | }
227 |
228 | public function getProductUri()
229 | {
230 | return $this->productUri;
231 | }
232 |
233 | public function setProductUri($value)
234 | {
235 | $this->productUri = $value;
236 | }
237 |
238 | public function getProductName()
239 | {
240 | return $this->productName;
241 | }
242 |
243 | public function setProductName($value)
244 | {
245 | $this->productName = $value;
246 | }
247 |
248 | public function getProductVersion()
249 | {
250 | return $this->productVersion;
251 | }
252 |
253 | public function setProductVersion($value)
254 | {
255 | $this->productVersion = $value;
256 | }
257 |
258 | public function clearGaAdjustment()
259 | {
260 | $this->gaAdjustment = 0.00;
261 | $this->gaAdjReason = '';
262 | }
263 |
264 | public function setGaAdjustment($amount, $reason)
265 | {
266 | $this->gaAdjustment = $amount;
267 | $this->gaAdjReason = $reason;
268 | }
269 |
270 | public function getGaAdjustment()
271 | {
272 | return array('amount' => $this->gaAdjustment, 'reason' => $this->gaAdjReason);
273 | }
274 |
275 | public function getConnectedCharities()
276 | {
277 | return $this->connectedCharities;
278 | }
279 |
280 | public function setConnectedCharities($value)
281 | {
282 | if (is_bool($value)) {
283 | $this->connectedCharities = $value;
284 | } else {
285 | $this->connectedCharities = false;
286 | }
287 | }
288 |
289 | public function getCommunityBuildings()
290 | {
291 | return $this->communityBuildings;
292 | }
293 |
294 | public function setCommunityBuildings($value)
295 | {
296 | if (is_bool($value)) {
297 | $this->communityBuildings = $value;
298 | } else {
299 | $this->communityBuildings = false;
300 | }
301 | }
302 |
303 | public function getClaimingOrganisation()
304 | {
305 | return $this->claimingOrganisation;
306 | }
307 |
308 | public function setClaimingOrganisation(ClaimingOrganisation $value)
309 | {
310 | $this->claimingOrganisation = $value;
311 | }
312 |
313 | public function getAuthorisedOfficial()
314 | {
315 | return $this->authorisedOfficial;
316 | }
317 |
318 | public function setAuthorisedOfficial(AuthorisedOfficial $value)
319 | {
320 | $this->authorisedOfficial = $value;
321 | }
322 |
323 | public function getClaimToDate()
324 | {
325 | return $this->claimToDate;
326 | }
327 |
328 | public function setClaimToDate($value)
329 | {
330 | $this->claimToDate = $value;
331 | }
332 |
333 | public function getCompress()
334 | {
335 | return $this->compress;
336 | }
337 |
338 | public function setCompress($value)
339 | {
340 | if (is_bool($value)) {
341 | $this->compress = $value;
342 | } else {
343 | $this->compress = false;
344 | }
345 | }
346 |
347 | public function addCbcd($bldg, $address, $postcode, $year, $amount)
348 | {
349 | $this->haveCbcd = true;
350 | $this->cbcdBldg[] = $bldg;
351 | $this->cbcdAddr[] = $address;
352 | $this->cbcdPoCo[] = $postcode;
353 | $this->cbcdYear[] = $year;
354 | $this->cbcdAmount[] = $amount;
355 | }
356 |
357 | public function resetCbcd()
358 | {
359 | $this->haveCbcd = false;
360 | $this->cbcdBldg = array();
361 | $this->cbcdAddr = array();
362 | $this->cbcdPoCo = array();
363 | $this->cbcdYear = array();
364 | $this->cbcdAmount = array();
365 | }
366 |
367 | public function addGasds($year, $amount)
368 | {
369 | $this->haveGasds = true;
370 | $this->gasdsYear[] = $year;
371 | $this->gasdsAmount[] = $amount;
372 | }
373 |
374 | public function resetGasds()
375 | {
376 | $this->haveGasds = false;
377 | $this->gasdsYear = array();
378 | $this->gasdsAmount = array();
379 | }
380 |
381 | public function setGasdsAdjustment($amount, $reason)
382 | {
383 | $this->gasdsAdjustment = $amount;
384 | $this->gasdsAdjReason = $reason;
385 | }
386 |
387 | public function getGasdsAdjustment()
388 | {
389 | return array('amount' => $this->gasdsAdjustment, 'reason' => $this->gasdsAdjReason);
390 | }
391 |
392 | /**
393 | * Sets details about the agent submitting the declaration.
394 | *
395 | * The agent company's address should be specified in the following format:
396 | * line => Array, each element containing a single line information.
397 | * postcode => The agent company's postcode.
398 | * country => The agent company's country. Defaults to England.
399 | *
400 | * The agent company's primary contact should be specified as follows:
401 | * name => Array, format as follows:
402 | * title => Contact's title (Mr, Mrs, etc.)
403 | * forename => Contact's forename.
404 | * surname => Contact's surname.
405 | * email => Contact's email address (optional).
406 | * telephone => Contact's telephone number (optional).
407 | * fax => Contact's fax number (optional).
408 | *
409 | * @param string $company The agent company's name.
410 | * @param array $address The agent company's address in the format specified above.
411 | * @param array $contact The agent company's key contact (optional, may be skipped with a null value).
412 | * @param string $reference An identifier for the agent's own reference (optional).
413 | */
414 | public function setAgentDetails($company, array $address, array $contact = null, $reference = null)
415 | {
416 | if (preg_match('/[A-Za-z0-9 &\'\(\)\*,\-\.\/]*/', $company)) {
417 | $this->agentDetails['company'] = $company;
418 | $this->agentDetails['address'] = $address;
419 | if (!isset($this->agentDetails['address']['country'])) {
420 | $this->agentDetails['address']['country'] = 'England';
421 | }
422 | if ($contact !== null) {
423 | $this->agentDetails['contact'] = $contact;
424 | }
425 | if (($reference !== null) && preg_match('/[A-Za-z0-9 &\'\(\)\*,\-\.\/]*/', $reference)) {
426 | $this->agentDetails['reference'] = $reference;
427 | }
428 | } else {
429 | return false;
430 | }
431 | }
432 |
433 | /**
434 | * Takes the $donor_data array as supplied to $this->giftAidSubmit
435 | * and adds it into the $package XMLWriter document.
436 | *
437 | * $donor_data structure is as follows
438 | * 'donation_date',
439 | * 'title',
440 | * 'first_name',
441 | * 'last_name',
442 | * 'house_no',
443 | * 'postcode', - must be a uk postcode for any uk address
444 | * 'overseas', - must be true if no postcode provided
445 | * 'sponsored' - set to true if this money is for a sponsored event
446 | * 'aggregation' - description of aggregated donations - else leave empty
447 | * 'amount'
448 | *
449 | * @param array $donor_data
450 | */
451 | private function buildClaimXml($donor_data)
452 | {
453 | $package = new XMLWriter();
454 | $package->openMemory();
455 | $package->setIndent(true);
456 |
457 | $package->startElement('Claim');
458 | $package->writeElement('OrgName', $this->getClaimingOrganisation()->getName());
459 | $package->writeElement('HMRCref', $this->getClaimingOrganisation()->getHmrcRef());
460 |
461 | $package->startElement('Regulator');
462 | $package->writeElement('RegName', $this->getClaimingOrganisation()->getRegulator());
463 | $package->writeElement('RegNo', $this->getClaimingOrganisation()->getRegNo());
464 | $package->endElement(); # Regulator
465 |
466 | $package->startElement('Repayment');
467 | $earliestDate = strtotime(date('Y-m-d'));
468 | foreach ($donor_data as $d) {
469 | if (isset($d['donation_date'])) {
470 | $dDate = strtotime($d['donation_date']);
471 | $earliestDate = ($dDate < $earliestDate) ? $dDate : $earliestDate;
472 | }
473 | $package->startElement('GAD');
474 | if (!isset($d['aggregation']) or empty($d['aggregation'])) {
475 | $package->startElement('Donor');
476 | $person = new Individual(
477 | $d['title'],
478 | $d['first_name'],
479 | $d['last_name'],
480 | '',
481 | $d['house_no'],
482 | $d['postcode'],
483 | (bool) $d['overseas']
484 | );
485 |
486 | $title = $person->getTitle();
487 | $fore = $person->getForename();
488 | $sur = $person->getSurname();
489 | $house = $person->getHouseNum();
490 | $postcode = $person->getPostcode();
491 | $overseas = $person->getIsOverseas();
492 |
493 | if (!empty($title)) {
494 | $package->writeElement('Ttl', $title);
495 | }
496 | $package->writeElement('Fore', $fore);
497 | $package->writeElement('Sur', $sur);
498 | $package->writeElement('House', $house);
499 | if (!empty($postcode)) {
500 | $package->writeElement('Postcode', $postcode);
501 | } else {
502 | $package->writeElement('Overseas', $overseas);
503 | }
504 | $package->endElement(); # Donor
505 | } elseif (!empty($d['aggregation'])) {
506 | $package->writeElement('AggDonation', $d['aggregation']);
507 | }
508 | if (isset($d['sponsored']) and $d['sponsored'] === true) {
509 | $package->writeElement('Sponsored', 'yes');
510 | }
511 | $package->writeElement('Date', $d['donation_date']);
512 | $package->writeElement('Total', number_format($d['amount'], 2, '.', ''));
513 | $package->endElement(); # GAD
514 | }
515 | $package->writeElement('EarliestGAdate', date('Y-m-d', $earliestDate));
516 |
517 | if (!empty($this->gaAdjustment)) {
518 | $package->writeElement('Adjustment', number_format($this->gaAdjustment, 2, '.', ''));
519 | }
520 | $package->endElement(); # Repayment
521 |
522 | $package->startElement('GASDS');
523 | $package->writeElement(
524 | 'ConnectedCharities',
525 | $this->getClaimingOrganisation()->getHasConnectedCharities() ? 'yes' : 'no'
526 | );
527 | foreach ($this->getClaimingOrganisation()->getConnectedCharities() as $cc) {
528 | $package->startElement('Charity');
529 | $package->writeElement('Name', $cc->getName());
530 | $package->writeElement('HMRCref', $cc->getHmrcRef());
531 | $package->endElement(); # Charity
532 | }
533 | foreach ($this->gasdsYear as $key => $val) {
534 | $package->startElement('GASDSClaim');
535 | $package->writeElement('Year', $this->gasdsYear[$key]);
536 | $package->writeElement('Amount', number_format($this->gasdsAmount[$key], 2, '.', ''));
537 | $package->endElement(); # GASDSClaim
538 | }
539 |
540 | $package->writeElement('CommBldgs', ($this->haveCbcd == true) ? 'yes' : 'no');
541 | foreach ($this->cbcdAddr as $key => $val) {
542 | $package->startElement('Building');
543 | $package->writeElement('BldgName', $this->cbcdBldg[$key]);
544 | $package->writeElement('Address', $this->cbcdAddr[$key]);
545 | $package->writeElement('Postcode', $this->cbcdPoCo[$key]);
546 | $package->startElement('BldgClaim');
547 | $package->writeElement('Year', $this->cbcdYear[$key]);
548 | $package->writeElement('Amount', number_format($this->cbcdAmount[$key], 2, '.', ''));
549 | $package->endElement(); # BldgClaim
550 | $package->endElement(); # Building
551 | }
552 |
553 | if (!empty($this->gasdsAdjustment)) {
554 | $package->writeElement('Adj', number_format($this->gasdsAdjustment, 2, '.', ''));
555 | }
556 |
557 | $package->endElement(); # GASDS
558 |
559 | $otherInfo = array();
560 | if (!empty($this->gasdsAdjustment)) {
561 | $otherInfo[] = $this->gasdsAdjReason;
562 | }
563 | if (!empty($this->gaAdjustment)) {
564 | $otherInfo[] = $this->gaAdjReason;
565 | }
566 | if (count($otherInfo) > 0) {
567 | $package->writeElement('OtherInfo', implode(' AND ', $otherInfo));
568 | }
569 |
570 | $package->endElement(); # Claim
571 |
572 | return $package->outputMemory();
573 | }
574 |
575 | /**
576 | * Submit a GA Claim - this is the crux of the biscuit.
577 | *
578 | * @param array $donor_data
579 | */
580 | public function giftAidSubmit($donor_data)
581 | {
582 | $cChardId = $this->getClaimingOrganisation()->getHmrcRef();
583 | $cOrganisation = 'IR';
584 |
585 | $dReturnPeriod = $this->getClaimToDate();
586 |
587 | $sDefaultCurrency = 'GBP'; // currently HMRC only allows GBP
588 | $sIRmark = 'IRmark+Token';
589 | $sSender = 'Individual';
590 |
591 | if ($this->getAuthorisedOfficial() == null) {
592 | return false;
593 | }
594 |
595 | // Set the message envelope
596 | $this->setMessageClass('HMRC-CHAR-CLM');
597 | $this->setMessageQualifier('request');
598 | $this->setMessageFunction('submit');
599 | $this->setMessageCorrelationId(null);
600 | $this->setMessageTransformation('XML');
601 | $this->addTargetOrganisation($cOrganisation);
602 |
603 | $this->addMessageKey('CHARID', $cChardId);
604 |
605 | $this->addChannelRoute(
606 | $this->getProductUri(),
607 | $this->getProductName(),
608 | $this->getProductVersion()
609 | );
610 |
611 | // Build message body...
612 | $package = new XMLWriter();
613 | $package->openMemory();
614 | $package->setIndent(true);
615 |
616 | $package->startElement('IRenvelope');
617 | $package->writeAttribute('xmlns', 'http://www.govtalk.gov.uk/taxation/charities/r68/2');
618 |
619 | $package->startElement('IRheader');
620 | $package->startElement('Keys');
621 | $package->startElement('Key');
622 | $package->writeAttribute('Type', 'CHARID');
623 | $package->text($cChardId);
624 | $package->endElement(); # Key
625 | $package->endElement(); # Keys
626 | $package->writeElement('PeriodEnd', $dReturnPeriod);
627 | $package->writeElement('DefaultCurrency', $sDefaultCurrency);
628 | $package->startElement('IRmark');
629 | $package->writeAttribute('Type', 'generic');
630 | $package->text($sIRmark);
631 | $package->endElement(); #IRmark
632 | $package->writeElement('Sender', $sSender);
633 | $package->endElement(); #IRheader
634 |
635 | $package->startElement('R68');
636 | $package->startElement('AuthOfficial');
637 | $package->startElement('OffName');
638 | $title = $this->getAuthorisedOfficial()->getTitle();
639 | if (!empty($title)) {
640 | $package->writeElement('Ttl', $title);
641 | }
642 | $package->writeElement('Fore', $this->getAuthorisedOfficial()->getForename());
643 | $package->writeElement('Sur', $this->getAuthorisedOfficial()->getSurname());
644 | $package->endElement(); #OffName
645 | $package->startElement('OffID');
646 | $package->writeElement('Postcode', $this->getAuthorisedOfficial()->getPostcode());
647 | $package->endElement(); #OffID
648 | $package->writeElement('Phone', $this->getAuthorisedOfficial()->getPhone());
649 | $package->endElement(); #AuthOfficial
650 | $package->writeElement('Declaration', 'yes');
651 |
652 | $claimDataXml = $this->buildClaimXml($donor_data, false);
653 | if ($this->compress == true) {
654 | $package->startElement('CompressedPart');
655 | $package->writeAttribute('Type', 'gzip');
656 | $package->text(base64_encode(gzencode($claimDataXml, 9, FORCE_GZIP)));
657 | $package->endElement(); # CompressedPart
658 | } else {
659 | $package->writeRaw($claimDataXml);
660 | }
661 |
662 | $package->endElement(); #R68
663 | $package->endElement(); #IRenvelope
664 |
665 | // Send the message and deal with the response...
666 | $this->setMessageBody($package);
667 |
668 | if ($this->sendMessage() && ($this->responseHasErrors() === false)) {
669 | $returnable = $this->getResponseEndpoint();
670 | $returnable['correlationid'] = $this->getResponseCorrelationId();
671 | } else {
672 | $returnable = array('errors' => $this->getResponseErrors());
673 | }
674 | $returnable['claim_data_xml'] = $claimDataXml;
675 | $returnable['submission_request'] = $this->fullRequestString;
676 |
677 | return $returnable;
678 | }
679 |
680 | /**
681 | * Submit a request for GA Claim Data
682 | */
683 | public function requestClaimData()
684 | {
685 | $this->setMessageClass('HMRC-CHAR-CLM');
686 | $this->setMessageQualifier('request');
687 | $this->setMessageFunction('list');
688 | $this->setMessageCorrelationId('');
689 | $this->setMessageTransformation('XML');
690 |
691 | $this->addTargetOrganisation('IR');
692 |
693 | $this->addMessageKey('CHARID', $this->getClaimingOrganisation()->getHmrcRef());
694 |
695 | $this->addChannelRoute(
696 | $this->getProductUri(),
697 | $this->getProductName(),
698 | $this->getProductVersion()
699 | );
700 |
701 | $this->setMessageBody('');
702 |
703 | if ($this->sendMessage() && ($this->responseHasErrors() === false)) {
704 | $returnable = $this->getResponseEndpoint();
705 | foreach ($this->fullResponseObject->Body->StatusReport->StatusRecord as $node) {
706 | $array = array();
707 | foreach ($node->children() as $child) {
708 | $array[$child->getName()] = (string) $child;
709 | }
710 | $returnable['statusRecords'][] = $array;
711 | }
712 | } else {
713 | $returnable = array('errors' => $this->getResponseErrors());
714 | }
715 | $returnable['submission_request'] = $this->fullRequestString;
716 |
717 | return $returnable;
718 | }
719 |
720 | /**
721 | * Polls the Gateway for a submission response / error following a VAT
722 | * declaration request. By default the correlation ID from the last response
723 | * is used for the polling, but this can be over-ridden by supplying a
724 | * correlation ID. The correlation ID can be skipped by passing a null value.
725 | *
726 | * If the resource is still pending this method will return the same array
727 | * as declarationRequest() -- 'endpoint', 'interval' and 'correlationid' --
728 | * if not then it'll return lots of useful information relating to the return
729 | * and payment of any VAT due in the following array format:
730 | *
731 | * message => an array of messages ('Thank you for your submission', etc.).
732 | * accept_time => the time the submission was accepted by the HMRC server.
733 | * period => an array of information relating to the period of the return:
734 | * id => the period ID.
735 | * start => the start date of the period.
736 | * end => the end date of the period.
737 | * payment => an array of information relating to the payment of the return:
738 | * narrative => a string representation of the payment (generated by HMRC)
739 | * netvat => the net value due following this return.
740 | * payment => an array of information relating to the method of payment:
741 | * method => the method to be used to pay any money due, options are:
742 | * - nilpayment: no payment is due.
743 | * - repayment: a repayment from HMRC is due.
744 | * - directdebit: payment will be taken by previous direct debit.
745 | * - payment: payment should be made by alternative means.
746 | * additional => additional information relating to this payment.
747 | *
748 | * @param string $correlationId The correlation ID of the resource to poll. Can be skipped with a null value.
749 | * @param string $pollUrl The URL of the Gateway to poll.
750 | *
751 | * @return mixed An array of details relating to the return and the original request, or false on failure.
752 | */
753 | public function declarationResponsePoll($correlationId = null, $pollUrl = null)
754 | {
755 | if ($correlationId === null) {
756 | $correlationId = $this->getResponseCorrelationId();
757 | }
758 |
759 | if ($this->setMessageCorrelationId($correlationId)) {
760 | if ($pollUrl !== null) {
761 | $this->setGovTalkServer($pollUrl);
762 | }
763 | $this->setMessageClass('HMRC-CHAR-CLM');
764 | $this->setMessageQualifier('poll');
765 | $this->setMessageFunction('submit');
766 | $this->setMessageTransformation('XML');
767 | $this->resetMessageKeys();
768 | $this->setMessageBody('');
769 | if ($this->sendMessage() && ($this->responseHasErrors() === false)) {
770 | $messageQualifier = (string) $this->fullResponseObject->Header->MessageDetails->Qualifier;
771 | if ($messageQualifier == 'response') {
772 | return array(
773 | 'correlationid' => $correlationId,
774 | 'submission_request' => $this->fullRequestString,
775 | 'submission_response' => $this->fullResponseString
776 | );
777 |
778 | } elseif ($messageQualifier == 'acknowledgement') {
779 | $returnable = $this->getResponseEndpoint();
780 | $returnable['correlationid'] = $this->getResponseCorrelationId();
781 | $returnable['submission_request'] = $this->fullRequestString;
782 |
783 | return $returnable;
784 | } else {
785 | return false;
786 | }
787 | } else {
788 | if ($this->responseHasErrors()) {
789 | return array(
790 | 'errors' => $this->getResponseErrors(),
791 | 'fullResponseString' => $this->fullResponseString
792 | );
793 | }
794 |
795 | return false;
796 | }
797 | } else {
798 | return false;
799 | }
800 | }
801 |
802 | /**
803 | * Adds a valid IRmark to the given package.
804 | *
805 | * This function over-rides the packageDigest() function provided in the main
806 | * php-govtalk class.
807 | *
808 | * @param string $package The package to add the IRmark to.
809 | *
810 | * @return string The new package after addition of the IRmark.
811 | */
812 | protected function packageDigest($package)
813 | {
814 | $packageSimpleXML = simplexml_load_string($package);
815 | $packageNamespaces = $packageSimpleXML->getNamespaces();
816 |
817 | $body = $packageSimpleXML->xpath('GovTalkMessage/Body');
818 |
819 | preg_match('#
(.*)<\/Body>#su', $packageSimpleXML->asXML(), $matches);
820 | $packageBody = $matches[1];
821 |
822 | $irMark = base64_encode($this->generateIRMark($packageBody, $packageNamespaces));
823 | $package = str_replace('IRmark+Token', $irMark, $package);
824 |
825 | return $package;
826 | }
827 |
828 | /**
829 | * Generates an IRmark hash from the given XML string for use in the IRmark
830 | * node inside the message body. The string passed must contain one IRmark
831 | * element containing the string IRmark (ie. IRmark+Token) or the
832 | * function will fail.
833 | *
834 | * @param $xmlString string The XML to generate the IRmark hash from.
835 | *
836 | * @return string The IRmark hash.
837 | */
838 | private function generateIRMark($xmlString, $namespaces = null)
839 | {
840 | if (is_string($xmlString)) {
841 | $xmlString = preg_replace(
842 | '/<(vat:)?IRmark Type="generic">[A-Za-z0-9\/\+=]*<\/(vat:)?IRmark>/',
843 | '',
844 | $xmlString,
845 | - 1,
846 | $matchCount
847 | );
848 | if ($matchCount == 1) {
849 | $xmlDom = new DOMDocument;
850 |
851 | if ($namespaces !== null && is_array($namespaces)) {
852 | $namespaceString = array();
853 | foreach ($namespaces as $key => $value) {
854 | if ($key !== '') {
855 | $namespaceString[] = 'xmlns:' . $key . '="' . $value . '"';
856 | } else {
857 | $namespaceString[] = 'xmlns="' . $value . '"';
858 | }
859 | }
860 | $bodyCompiled = '' . $xmlString . '';
861 | } else {
862 | $bodyCompiled = '' . $xmlString . '';
863 | }
864 | $xmlDom->loadXML($bodyCompiled);
865 |
866 | return sha1($xmlDom->documentElement->C14N(), true);
867 | } else {
868 | return false;
869 | }
870 | } else {
871 | return false;
872 | }
873 | }
874 |
875 | public function getResponseErrors()
876 | {
877 | $govTalkErrors = parent::getResponseErrors();
878 |
879 | foreach ($govTalkErrors['business'] as $b_index => $b_err) {
880 | if ($b_err['number'] == "3001") {
881 | unset($govTalkErrors['business'][$b_index]);
882 | }
883 | }
884 |
885 | $has_gt_errors = false;
886 | foreach ($govTalkErrors as $type) {
887 | if (count($type) > 0) {
888 | $has_gt_errors = true;
889 | }
890 | }
891 |
892 | if (!$has_gt_errors) {
893 | // lay out the GA errors
894 | foreach ($this->fullResponseObject->Body->ErrorResponse->Error as $gaError) {
895 | $govTalkErrors['business'][] = array(
896 | 'number' => (string) $gaError->Number,
897 | 'text' => (string) $gaError->Text,
898 | 'location' => (string) $gaError->Location
899 | );
900 | }
901 | }
902 |
903 | return $govTalkErrors;
904 | }
905 | }
906 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/}
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see {http://www.gnu.org/licenses/}.
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | php-govtalk Copyright (C) 2013 Fubra Limited
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | {http://www.gnu.org/licenses/}.
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | {http://www.gnu.org/philosophy/why-not-lgpl.html}.
675 |
--------------------------------------------------------------------------------