Skip to content

kenakamu/line-pay-csharp

Repository files navigation

LINE Pay dotnet core C# SDK

※日本語のドキュメントはこちら

This is unofficial SDK for LINE Pay for C# developers.
You can find detail API document here

Getting Started

This repository contains sample web application to use the SDK. Update ChannelId, ChannelSecret and ServerUri.

Create sandbox

Go to LINE Pay Developers and create your sandbox. You can retrieve Channel Id and Channel Secret Key after successful login to LINE Pay Console. You also need to configure white lists of server ip addresses which access to LINE Pay API.

How to use the SDK

Instantiate client Pass channel information and if you use sandbox or not.

var channelId = "channel id";
var channelSecret = "channel secret";
var isSandbox = true;
var client = new LinePayClient(
                channelId,
                channelSecret,
                isSandbox);

Reserve the order Instantiate reserve object and pass to ReserveAsync

var reserve = new Reserve()
{
    ProductName = "Chocolate",
    Amount = 2.2,
    Currency = Currency.USD,
    OrderId =  Guid.NewGuid().ToString(), // Unique order id
    ConfirmUrl = $"{configuration["ServerUri"]}/api/pay/confirm", // Cancel Url
    CancelUrl = $"{configuration["ServerUri"]}/api/pay/cancel", // Confirm Url
}

var response = await client.ReserveAsync(reserve);

Confirm the order Instantiate confirm object by using reserve you created, and call ConfirmAsync.

var transactionId = Int64.Parse(HttpContext.Request.Query["transactionId"]);

var reserve = //get your reserve from db.

var confirm = new Confirm()
{
    Amount = reserve.Amount,
    Currency = reserve.Currency
}

var response = await client.ConfirmAsync(transactionId, confirm);

See the sample web app in the repository for more detail.

License

MIT

Releases

No releases published

Packages

No packages published