public async Task <IActionResult> PreApprovedPay(string regkey) { var reserve = new PreApprovedPay() { Amount = 1, Capture = true, Currency = Currency.JPY, ProductName = "チョコレート", OrderId = Guid.NewGuid().ToString() }; var response = await client.PreApprovedPayAsync(regkey, reserve); return(new OkObjectResult(JsonConvert.SerializeObject(response))); }
/// <summary> /// Preapproved Payment API /// When the payment type of the Reserve Payment API was set as PREAPPROVED, a regKey is returned with the /// payment result.Preapproved Payment API uses this regKey to directly complete a payment without using the LINE app. /// </summary> /// <param name="regKey">Registration Key</param> /// <param name="preApprovedPay">PreApprovedPay</param> /// <returns></returns> public async Task <PreApprovedPayResponse> PreApprovedPayAsync(string regKey, PreApprovedPay preApprovedPay) { var request = new HttpRequestMessage(HttpMethod.Post, $"/{version}/payments/preapprovedPay/{regKey}/payment"); request.Content = new StringContent(JsonConvert.SerializeObject(preApprovedPay, serializerSettings), Encoding.UTF8, "application/json"); var response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <PreApprovedPayResponse>(await response.Content.ReadAsStringAsync())); } else { throw new Exception(await response.Content.ReadAsStringAsync()); } }