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); } }
public void PaymentAuth() { // TODO uncomment below to test the method and replace null with proper value string orderToken = null; var authorization = authorizationApi.AuthorizationCreateToken(); orderToken = "001.u0hglki77ko70iuavgnb31vo2qq4ehold53brkdngfj9l73f"; var auth = new Auth("1", orderToken, "Auth for Order"); var authResponse = instance.PaymentAuth(auth); Assert.IsInstanceOf <Payment>(authResponse, "response is Payment"); }