Esempio n. 1
0
        public void main()
        {
            // Configure API key authorization, get an Access Token, Create an Order, Get an Order

            try
            {
                authorizationApi = new AuthorizationApi("https://api-sandbox.afterpay.com/v2/");
                authorizationApi.Configuration.MerchantId        = "MerchantId";
                authorizationApi.Configuration.MerchantSecretKey = "MerchantSecretKey";
                authorizationApi.Configuration.UserAgent         = "Afterpay SDK; .netCore3.1; Git Example";

                // Create Acces Token
                var authentication = authorizationApi.AuthorizationCreateToken();

                checkoutsApi = new CheckoutsApi(authorizationApi.Configuration);
                paymentsApi  = new PaymentsApi(authorizationApi.Configuration);

                Debug.WriteLine(authentication);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling AuthorizationApi: " + e.Message);
            }

            try
            {
                // Create Checkout
                var createCheckoutRequest = CreateCheckoutRequest();

                var response = checkoutsApi.CheckoutsCreate(createCheckoutRequest);

                var checkout = checkoutsApi.CheckoutsGet(response.Token);

                string orderToken = null;

                var authorization = authorizationApi.AuthorizationCreateToken();

                orderToken = "OrderToken";

                var auth = new Auth("1", orderToken, "Auth for Order");

                var authResponse = paymentsApi.PaymentAuth(auth);

                var amount = new Money("0.00", "NZD");

                var capture = new Capture("1", "1", amount, "Capture for Order"); // Request Id needs to increas for each partial refund

                var id = "OrderId";

                var captureResponse = paymentsApi.PaymentCapture(id, capture);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling OrdersApi: " + e.Message);
            }
        }
Esempio n. 2
0
        public void CheckoutsCreateTest()
        {
            // TODO uncomment below to test the method and replace null with proper value

            var createCheckoutRequest = CreateCheckoutRequest();

            var response = instance.CheckoutsCreate(createCheckoutRequest);

            var checkout = instance.CheckoutsGet(response.Token);

            Assert.IsInstanceOf <Checkout> (response, "response is Checkout");

            // https://orders.yourwebsite.com/confirm?&status=SUCCESS&orderToken=001.gsafrj9iijmn5t3ti7el4jcm4fuqvgqfecv1j2ulr39fhg08
        }