Skip to content

Commit

Permalink
shipment serviceに問い合わせずにshippingsテーブルを利用するように
Browse files Browse the repository at this point in the history
  • Loading branch information
d0riven committed Sep 8, 2019
1 parent 020bf61 commit 36e9492
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions php/src/App/Service.php
Expand Up @@ -637,31 +637,9 @@ public function transactions(Request $request, Response $response, array $args)
return $response->withStatus(StatusCode::HTTP_NOT_FOUND)->withJson(['error' => 'shipping not found']);
}

// too slow external service
$client = new Client();
$host = $this->getShipmentServiceURL();
try {
$r = $client->get($host . '/status', [
'headers' => ['Authorization' => self::ISUCARI_API_TOKEN, 'User-Agent' => self::HTTP_USER_AGENT],
'json' => ['reserve_id' => $shipping['reserve_id']],
]);
} catch (RequestException $e) {
$this->dbh->rollBack();
if ($e->hasResponse()) {
$this->logger->error($e->getResponse()->getReasonPhrase());
}
return $response->withStatus(StatusCode::HTTP_INTERNAL_SERVER_ERROR)->withJson(['error' => 'failed to request to shipment service']);
}
if ($r->getStatusCode() !== StatusCode::HTTP_OK) {
$this->logger->error(($r->getReasonPhrase()));
$this->dbh->rollBack();
return $response->withStatus(StatusCode::HTTP_INTERNAL_SERVER_ERROR)->withJson(['error' => 'failed to request to shipment service']);
}
$shippingResponse = json_decode($r->getBody());

$detail['transaction_evidence_id'] = $transactionEvidence['id'];
$detail['transaction_evidence_status'] = $transactionEvidence['status'];
$detail['shipping_status'] = $shippingResponse->status;
$detail['shipping_status'] = $shipping['status'];
}
}

Expand Down

0 comments on commit 36e9492

Please sign in to comment.