Class ZipClient
The main class used to interact with the Zip payments API.
Inherited Members
Namespace: Yort.Zip.InStore
Assembly: Yort.Zip.InStore.dll
Syntax
public class ZipClient : IZipClient, IDisposable
Constructors
| Improve this Doc View SourceZipClient(HttpClient, ZipClientConfiguration)
Full constructor.
Declaration
public ZipClient(HttpClient httpClient, ZipClientConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | httpClient | See the method remarks for important information. An HttpClient instance to use to access the Zip API, or null to have the ZipClient create it's own internally. Supply your own if you wish to apply handlers for logging, retry logic etc. |
ZipClientConfiguration | configuration | A ZipClientConfiguration instance providing client credentials, the API environment to access and other required details. |
Remarks
If you are injecting an instance of HttpClient via the httpClient
make sure the 'AllowAutoRedirect' property on the inner most handler (and any intermediate ones)
is set to false. The Zip API returns redirect responses in some situations that must be handled manually by the ZipClient instance for correct behaviour to be applied.
ZipClient(ZipClientConfiguration)
Partial constructor.
Declaration
public ZipClient(ZipClientConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
ZipClientConfiguration | configuration | A ZipClientConfiguration instance providing client credentials, the API environment to access and other required details. |
Methods
| Improve this Doc View SourceCancelOrderAsync(CancelOrderRequest)
Requests a previously created order be cancelled.
Declaration
public Task<CancelOrderResponse> CancelOrderAsync(CancelOrderRequest request)
Parameters
Type | Name | Description |
---|---|---|
CancelOrderRequest | request | A CancelOrderRequest providing details of the order to be cancelled and operation/terminal that is requesting cancellation. |
Returns
Type | Description |
---|---|
Task<CancelOrderResponse> | A CancelOrderResponse instance. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |
CommitOrderAsync(CommitOrderRequest)
Commits (completes) an order previously created via CreateOrderAsync(CreateOrderRequest) using the Auth flow.
Declaration
public Task CommitOrderAsync(CommitOrderRequest request)
Parameters
Type | Name | Description |
---|---|---|
CommitOrderRequest | request | A CommitOrderRequest containing details of the order to commit. |
Returns
Type | Description |
---|---|
Task | A task that can be awaited to know when the operation has completed. If the task does not return an exception, the auth completed succesfully. Use the GetOrderStatusAsync(OrderStatusRequest) to confirm. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |
CreateOrderAsync(CreateOrderRequest)
Creates a new order (payment) with Zip.
Declaration
public Task<CreateOrderResponse> CreateOrderAsync(CreateOrderRequest request)
Parameters
Type | Name | Description |
---|---|---|
CreateOrderRequest | request | Details of the order to be created. |
Returns
Type | Description |
---|---|
Task<CreateOrderResponse> | Details of the created order if succesful, otherwise throws an exception. |
Remarks
If the EnableUniqueMerchantReferenceCheck is true and the specified MerchantReference has been used before this method will behave in an idempotent way, returning a successful response but without creating a duplicate order. If EnableUniqueMerchantReferenceCheck is false and duplicate merchant reference is used, a dupliate order will be created in Zip.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |
Dispose()
Disposes this instance and all internal resources.
Declaration
public void Dispose()
See Also
| Improve this Doc View SourceDispose(Boolean)
Disposes resources used by this instance.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | True if dispose is being called explicitly by client code, or false if it is being called from a finalizer (indicating only unmanaged resources should be cleaned up). |
See Also
| Improve this Doc View SourceEnrolAsync(EnrolRequest)
Allows retrieval of the client id and secret used to request new auth tokens using the Zip device enrolment system.
Declaration
public Task<EnrolResponse> EnrolAsync(EnrolRequest request)
Parameters
Type | Name | Description |
---|---|---|
EnrolRequest | request | A EnrolRequest instance providing details of the device to enrol. |
Returns
Type | Description |
---|---|
Task<EnrolResponse> | A EnrolResponse instance containing details of the token returned. |
Remarks
On a successful response, not only does the EnrolResponse returned contain the client id and secret so the caller can persist them for future sessions, but the client id and secret returned will be automatically applied to the configuration for this ZipClient instance.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |
GetOrderStatusAsync(OrderStatusRequest)
Requests the current status of the specified order from the Zip API.
Declaration
public Task<OrderStatusResponse> GetOrderStatusAsync(OrderStatusRequest request)
Parameters
Type | Name | Description |
---|---|---|
OrderStatusRequest | request | A OrderStatusRequest providing details of the order to return the status of. |
Returns
Type | Description |
---|---|
Task<OrderStatusResponse> | If successful a OrderStatusResponse containing details of the specified order's status. Otherwise throws an exception. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |
RefundOrderAsync(RefundOrderRequest)
Refunds some or all of the money taken as part of a previously completed order.
Declaration
public Task<RefundOrderResponse> RefundOrderAsync(RefundOrderRequest request)
Parameters
Type | Name | Description |
---|---|---|
RefundOrderRequest | request | A RefundOrderRequest specifying details of the refund to create and the order to create it against. |
Returns
Type | Description |
---|---|
Task<RefundOrderResponse> | A RefundOrderResponse with details of a succesful outcome. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |
RollbackOrderAsync(RollbackOrderRequest)
Rolls back (cancels/undoes) an order previously created via CreateOrderAsync(CreateOrderRequest) using the Auth flow.
Declaration
public Task RollbackOrderAsync(RollbackOrderRequest request)
Parameters
Type | Name | Description |
---|---|---|
RollbackOrderRequest | request | A RollbackOrderRequest containing details of the order to rollback. |
Returns
Type | Description |
---|---|
Task | A task that can be awaited to know when the operation has completed. If the task does not return an exception, the auth rolled back succesfully. Use the GetOrderStatusAsync(OrderStatusRequest) to confirm. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ArgumentException | Thrown if any sub-property of |
ZipApiException | Thrown if the Zip API returns an error response. |
UnauthorizedAccessException | Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the ZipClientConfiguration. |
HttpRequestException | Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing. |
OperationCanceledException | Thrown if a timeout occurs calling the Zip API. |