Yort.Laybuy.InStore
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;