Yort.Laybuy.InStore

An unofficial .Net client library for the Laybuy payments POS API (https://integrations.laybuy.com/reference#point-of-sale-integration-flow)

View project on GitHub

Yort.Laybuy.InStore

Status

Yort.Laybuy.InStore.Build License: MIT Coverage Status

Documentation

See the Laybuy API documentation for the low level details and what the API is capable of.

For getting started, samples and API reference for this library see the docs

If you really want a sample right here:

 var credentials = new LaybuyCredentials("YourMerchantId", "YourApiKey");
    var settings = new LaybuyClientConfiguration(credentials)
    {
        Environment = LaybuyEnvironment.Sandbox,
        DefaultBranch = "Test Branch"
    };

    ILaybuyClient client = new LaybuyClient(settings);

    var createRequest = new CreateOrderRequest()
    {
        MerchantReference = System.Guid.NewGuid().ToString(),
        Amount = 10,
        Customer = new RequestLaybuyCustomer() { Phone = "0210000000" }
    };

    var createResponse = await client.Create(createRequest);
    if (createResponse.Result != LaybuyStatus.Success)
        throw new InvalidOperationException(createResponse.Result);

    var done = false;
    var statusRequest = new OrderStatusRequest() 
    {  MerchantReference = createRequest.MerchantReference};
    OrderStatusResponse status = null;

    while (!done)
    {
        await Task.Delay(1000); 

        status = await client.GetStatus(statusRequest);

        if (status.Result == LaybuyStatus.Cancelled) throw new OperationCanceledException();
        done = status.Result == LaybuyStatus.Success;
    }

    return status.OrderId;