Skip to content

Commit

Permalink
Return response_details, so VAT can return the collection_date
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfrancis committed Dec 5, 2018
1 parent 5d552c5 commit 3f99e67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hmrc-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class hmrc_gateway extends check {
private $sender_name = NULL;
private $sender_pass = NULL;
private $sender_email = NULL;
private $request_ref = NULL;
private $response_code = NULL;
private $response_string = NULL;
private $response_object = NULL;
Expand Down Expand Up @@ -71,6 +72,7 @@ public function request_submit($request) {
// Setup message

$this->gateway_url = $this->submission_url_get();
$this->request_ref = $request;

$body_xml = $request->request_body_get_xml();

Expand Down Expand Up @@ -219,10 +221,16 @@ public function request_poll($request) {
'timeout' => (time() + $interval),
'status' => NULL,
'response' => NULL,
'response_details' => NULL,
);

} else if ($this->response_qualifier == 'response') {

$details = array();
if ($this->request_ref) {
$details = $this->request_ref->response_details($this->response_object);
}

return array(
'class' => $this->message_class,
'correlation' => $request['correlation'],
Expand All @@ -231,6 +239,7 @@ public function request_poll($request) {
'timeout' => time(),
'status' => 'SUBMISSION_RESPONSE',
'response' => $this->response_string,
'response_details' => $details,
);

} else {
Expand Down
6 changes: 6 additions & 0 deletions hmrc-rti.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public function request_header_get_xml() {

}

public function response_details($response_object) {

return array();

}

}

?>
8 changes: 8 additions & 0 deletions hmrc-vat.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ private function format_amount($decimals, $amount) {
return number_format($amount, $decimals, '.', '');
}

public function response_details($response_object) {

$details = array(
'collection_date' => strval($response_object->Body->SuccessResponse->ResponseData->VATDeclarationResponse->Body->PaymentNotification->DirectDebitPaymentStatus->CollectionDate),
);

}

}

?>

0 comments on commit 3f99e67

Please sign in to comment.