1. Go to this page and download the library: Download infoodle/hmrc-gift-aid library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$gaService = new GiftAid(
$authorised_official['id'],
$authorised_official['passwd'],
$vendor['id'],
$vendor['product'],
$vendor['version'],
true // Test mode. Leave this off or set to false for live claim submission
);
$gaService->setCharityId($charity['id']);
$gaService->setClaimToDate('2014-01-01'); // date of most recent donation
$gaService->setAuthorisedOfficial(
new AuthorisedOfficial(
$authorised_official['title'],
$authorised_official['name'],
$authorised_official['surname'],
$authorised_official['phone'],
$authorised_official['postcode']
)
);
$gaService->setClaimingOrganisation(
new ClaimingOrganisation(
$charity['name'],
$charity['id'],
$charity['regulator'],
$charity['reg_no']
)
);
$gaService->setCompress(true);
$response = $gaService->giftAidSubmit($claim_items);
if (isset($response['errors'])) {
// TODO: deal with the $response['errors']
} else {
// giftAidSubmit returned no errors
$correlation_id = $response['correlationid']; // TODO: store this !
$endpoint = $response['endpoint'];
}
if ($correlation_id !== NULL) {
$pollCount = 0;
while ($pollCount < 3 and $response !== false) {
$pollCount++;
if (
isset($response['interval']) and
isset($response['endpoint']) and
isset($response['correlationid'])
) {
sleep($response['interval']);
$response = $gaService->declarationResponsePoll(
$response['correlationid'],
$response['endpoint']
);
if (isset($response['errors'])) {
// TODO: deal with the $response['errors']
}
} elseif (
isset($response['correlationid']) and
isset($response['submission_response'])
) {
// TODO: store the submission_response and send the delete message
$hmrc_response => $response['submission_response']; // TODO: store this !
$response = !$gaService->sendDeleteRequest();
}
}
}
// submit an adjustment to a previously submitted claim
$gaService->setGaAdjustment('34.89', 'Refunds issued on two previous donations.');
$response = $gaService->requestClaimData();
foreach ($response['statusRecords'] as $status_record) {
// TODO: deal with the $status_record as you please
if (
$status_record['Status'] == 'SUBMISSION_RESPONSE' AND
$status_record['CorrelationID'] != ''
) {
$gaService->sendDeleteRequest($status_record['CorrelationID'], 'HMRC-CHAR-CLM');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.