public void main() { // Configure API key authorization, get an Access Token, Create an Order, Get an Order try { // Setup Authorization authorizationApi = new AuthorizationApi("https://merchant-auth-nz.sandbox.zip.co"); authorizationApi.Configuration.ClientId = "Your Client Id"; authorizationApi.Configuration.ClientSecret = "Your Client Secret"; // Create Acces Token var authorization = authorizationApi.AuthorizationCreateToken(); Debug.WriteLine(authorization); } catch (Exception e) { Debug.Print("Exception when calling AuthorizationApi: " + e.Message); } try { // Create Order ordersApi = new OrdersApi("https://sandbox.zip.co/nz/api"); var createOrderRequest = CreateRequest(CreateOrderRequest.PaymentFlowEnum.Payment); var authorization = authorizationApi.AuthorizationCreateToken(); // Create Order var createOrderResponse = ordersApi.OrderCreate(authorization, "Idempotency-Key", createOrderRequest); Debug.WriteLine(createOrderResponse); // Get Order var id = createOrderResponse.OrderId; var order = ordersApi.OrderGet(id); Debug.WriteLine(order); } catch (Exception e) { Debug.Print("Exception when calling OrdersApi: " + e.Message); } }
public void OrdersCreateTest() { // TODO uncomment below and replace AccessToken to test the basic method //var client = new RestClient("https://sandbox.zip.co/nz/api/order"); //client.Timeout = -1; //var request = new RestRequest(Method.POST); //request.AddHeader("Content-Type", "application/json"); //request.AddHeader("Authorization", "Bearer <AccessToken>"); //request.AddParameter("application/json", "{\r\n \"productType\": \"Classic\",\r\n \"amount\": 123,\r\n \"consumer\": {\r\n \"phoneNumber\": {\r\n \"number\": \"string\",\r\n \"isVerified\": true\r\n },\r\n \"givenNames\": \"string\",\r\n \"surname\": \"string\",\r\n \"email\": \"string\"\r\n },\r\n \"billing\": {\r\n \"addressLine1\": \"string\",\r\n \"addressLine2\": \"string\",\r\n \"suburb\": \"string\",\r\n \"city\": \"string\",\r\n \"postcode\": \"string\",\r\n \"state\": \"string\"\r\n },\r\n \"shipping\": {\r\n \"addressLine1\": \"string\",\r\n \"addressLine2\": \"string\",\r\n \"suburb\": \"string\",\r\n \"city\": \"string\",\r\n \"postcode\": \"string\",\r\n \"state\": \"string\"\r\n },\r\n \"description\": \"string\",\r\n \"items\": [\r\n {\r\n \"description\": \"string\",\r\n \"name\": \"string\",\r\n \"sku\": \"string\",\r\n \"quantity\": 123,\r\n \"price\": 123,\r\n \"merchantChannel\": \"string\"\r\n }\r\n ],\r\n \"merchant\": {\r\n \"redirectConfirmUrl\": \"https://v43demo.selectsystems.com.au/confirm\",\r\n \"redirectCancelUrl\": \"https://v43demo.selectsystems.com.au/cancel\"\r\n },\r\n \"merchantReference\": \"string\",\r\n \"taxAmount\": 123,\r\n \"shippingAmount\": 123,\r\n \"token\": \"string\",\r\n \"promotions\": [\r\n \"string\"\r\n ],\r\n \"pairing\": {\r\n \"token\": \"string\"\r\n },\r\n \"paymentFlow\": \"payment\"\r\n}", ParameterType.RequestBody); //IRestResponse response = client.Execute(request); //Console.WriteLine(response.Content); var authorization = authorizationApi.AuthorizationCreateToken("https://auth-dev.partpay.co.nz"); var createOrderRequest = CreateRequest(CreateOrderRequest.PaymentFlowEnum.Payment); var response = instance.OrderCreate(authorization, "IK001", createOrderRequest); Assert.IsInstanceOf <OrderCreateResponse>(response, "response is OrderCreateResponse"); }