Aminu Babayo Shehu
03/02/2023, 2:31 PMGET route
in ktor
example: <https://api.paystack.co/transaction/verify/353532>
and after I called it, how can I get the response in form of json
August Lilleaas
03/02/2023, 2:33 PMAminu Babayo Shehu
03/02/2023, 2:35 PMget("/payments/verify/paystack/{ref}") {
val ref = call.parameters["ref"] ?: return@get call.respondText("Missing or malformed ref", status = HttpStatusCode.BadRequest)
//verify
val client = HttpClient(CIO)
val response = client.get("<https://api.paystack.co/transaction/verify/${ref}>") {
header("Authorization", "Bearer sk_test_4ty6ggfb5c94ef56c888fd576bd06841ac3f9fc364118f")
call.respond(response)
}
August Lilleaas
03/02/2023, 2:36 PMresponse
instead of forwarding it wholesale to call.respond()
Aminu Babayo Shehu
03/02/2023, 2:37 PMAugust Lilleaas
03/02/2023, 2:38 PMresponse
value is documented here: https://ktor.io/docs/response.htmlAminu Babayo Shehu
03/02/2023, 2:39 PMThomas Urbanitsch
03/02/2023, 2:43 PMAminu Babayo Shehu
03/02/2023, 2:44 PM}
Thomas Urbanitsch
03/02/2023, 2:47 PMAminu Babayo Shehu
03/02/2023, 2:48 PM{
"status": "success",
"message": "Transaction fetched successfully",
"data": {
"id": 1163068,
"tx_ref": "akhlm-pstmn-blkchrge-xx6",
"flw_ref": "FLW-M03K-02c21a8095c7e064b8b9714db834080b",
"device_fingerprint": "N/A",
"amount": 3000,
"currency": "NGN",
"charged_amount": 3000,
"app_fee": 1000,
"merchant_fee": 0,
"processor_response": "Approved",
"auth_model": "noauth",
"ip": "pstmn",
"narration": "Kendrick Graham",
"status": "successful",
"payment_type": "card",
"created_at": "2020-03-11T19:22:07.000Z",
"account_id": 73362,
"amount_settled": 2000,
"card": {
"first_6digits": "553188",
"last_4digits": "2950",
"issuer": " CREDIT",
"country": "NIGERIA NG",
"type": "MASTERCARD",
"token": "flw-t1nf-f9b3bf384cd30d6fca42b6df9d27bd2f-m03k",
"expiry": "09/22"
},
"customer": {
"id": 252759,
"name": "Kendrick Graham",
"phone_number": "0813XXXXXXX",
"email": "<mailto:user@example.com|user@example.com>",
"created_at": "2020-01-15T13:26:24.000Z"
}
}
}
Thomas Urbanitsch
03/02/2023, 2:56 PMAminu Babayo Shehu
03/02/2023, 2:57 PMjacksonObjectMapper().readTree(stringBody)