示例#1
0
        /// <summary>
        /// Cancels a previously created subscription plan.
        /// </summary>
        /// <param name="planId">The unique identifier for the subscription plan.</param>
        /// <returns>A "CancelPlanResponse" object, containing the response from the NETELLER REST API.</returns>
        public static CancelPlanResponse CacelPlan(string planId)
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

            Dictionary<string, string> headers = new Dictionary<string, string>
            {
                {"Authorization", "Bearer " + token.accessToken}
            };

            string path = "v1/plans/" + planId + "/cancel";

            string response = api.Post(path, null, headers, null);

            DataContractJsonSerializer responseSerializer = new DataContractJsonSerializer(typeof (CancelPlanResponse));
            MemoryStream responseMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(response));

            CancelPlanResponse responseObject = (CancelPlanResponse) responseSerializer.ReadObject(responseMemoryStream);

            return responseObject;
        }
示例#2
0
        /// <summary>
        /// Cancels a previously created subscription.
        /// </summary>
        /// <param name="subscriptionId">The unique identifier for the subscription.</param>
        /// <param name="expand">Expands the specified resource. Possible values: "plan, customer"</param>
        /// <returns>A "CancelSubscriptionResponse" object, containing the response from the NETELLER REST API.</returns>
        public static CancelSubscriptionResponse CancelSubscription(string subscriptionId, string expand = "")
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

            Dictionary<string, string> headers = new Dictionary<string, string>
            {
                {"Authorization", "Bearer " + token.accessToken}
            };

            string path = "v1/subscriptions/" + subscriptionId + "/cancel";

            string response;

            if (!String.IsNullOrEmpty(expand))
            {
                Dictionary<string, string> queryParams = new Dictionary<string, string>
                {
                    {"expand", expand}
                };

                response = api.Post(path, queryParams, headers, null);
            }
            else
            {
                response = api.Post(path, null, headers, null);
            }

            DataContractJsonSerializer responseSerializer = new DataContractJsonSerializer(typeof (CancelSubscriptionResponse));
            MemoryStream responseMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(response));

            CancelSubscriptionResponse responseObject = (CancelSubscriptionResponse) responseSerializer.ReadObject(responseMemoryStream);

            return responseObject;
        }
示例#3
0
        /// <summary>
        /// Makes a request to the NETELLER REST API to exchange the authorization code for a new access token and refresh token. 
        /// </summary>
        /// <param name="authCode">The authorization code obtained from the authorization flow.</param>
        /// <param name="redirectUri">The redirect_uri used in the authorization flow. This value must match the uri used to obtain authorization, If not supplied during the authorization flow then the redirect_uri will be the registered redirect uri for your application (as set in the merchant.com portal under the APPS section) and should not be passed.</param>
        /// <returns>Returns a new access token of type "auth_code".</returns>
        public Token getToken_authCode(string authCode, string redirectUri = "")
        {
            NetellerApi api = new NetellerApi();

            Dictionary<string, string> queryParams = new Dictionary<string, string>
            {
                {"grant_type", "authorization_code"},
                {"code", authCode}
            };
            if (!String.IsNullOrEmpty(redirectUri))
            {
                queryParams.Add("redirect_uri", redirectUri);
            }

            Byte[] plainTextCredentials = Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret);
            string base64EncodedCredentials = Convert.ToBase64String(plainTextCredentials);

            Dictionary<string, string> headers = new Dictionary<string, string>
            {
                {"Authorization", "Basic " + base64EncodedCredentials}
            };

            const string path = "v1/oauth2/token";

            string response = api.Post(path, queryParams, headers, null);

            DataContractJsonSerializer responseSerializer = new DataContractJsonSerializer(typeof (Token));
            MemoryStream responseMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(response));

            Token responseObject = (Token) responseSerializer.ReadObject(responseMemoryStream);

            return responseObject;
        }
示例#4
0
        /// <summary>
        /// Creates a new outgoing payment.
        /// </summary>
        /// <param name="request">A "TransferOutRequest" object containing the required data to be send to the API.</param>
        /// <returns>A "TransferOutResponse" object, containing the response from the NETELLER REST API.</returns>
        /// <param name = "expand">Expands the specified resource. Possible values: "customer"</param>
        public static TransferOutResponse TransferOut(TransferOutRequest request, string expand = "")
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

            Dictionary<string, string> headers = new Dictionary<string, string>
            {
                {"Authorization", "Bearer " + token.accessToken}
            };

            Dictionary<string, string> queryParams = new Dictionary<string, string>();

            if (!String.IsNullOrEmpty(expand))
            {
                queryParams.Add("expand",expand);
            }

            DataContractJsonSerializer requestSerializer = new DataContractJsonSerializer(typeof (TransferOutRequest));
            MemoryStream requestMemoryStream = new MemoryStream();

            requestSerializer.WriteObject(requestMemoryStream, request);
            string requestJson = Encoding.UTF8.GetString(requestMemoryStream.ToArray());

            const string path = "v1/transferOut";

            string response = api.Post(path, queryParams, headers, requestJson);

            DataContractJsonSerializer responseSerializer = new DataContractJsonSerializer(typeof (TransferOutResponse));
            MemoryStream responseMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(response));

            TransferOutResponse responseObject = (TransferOutResponse) responseSerializer.ReadObject(responseMemoryStream);

            return responseObject;
        }
示例#5
0
        /// <summary>
        /// Enrolls an existing NETELLER account holder in one of your subscription plans.
        /// </summary>
        /// <param name="request">A "CreateSubscriptionRequest" object containing the required data to be send to the API.</param>
        /// <param name="token">An access token of type "auth_code", authorized by the account holder.</param>
        /// <returns>A "CreateSubscriptionResponse" object, containing the response from the NETELLER REST API.</returns>
        /// <param name = "expand">Expands the specified resource. Possible values: "plan, customer"</param>
        public static CreateSubscriptionResponse CreateSubscription(CreateSubscriptionRequest request, string token, string expand = "")
        {
            NetellerApi api = new NetellerApi();

            Dictionary<string, string> headers = new Dictionary<string, string>
            {
                {"Authorization", "Bearer " + token}
            };

            Dictionary<string, string> queryParams = new Dictionary<string, string>();

            if (!String.IsNullOrEmpty(expand))
            {
                queryParams.Add("expand",expand);
            }

            const string path = "v1/subscriptions";

            DataContractJsonSerializer requestSerializer = new DataContractJsonSerializer(typeof (CreateSubscriptionRequest));
            MemoryStream requestMemoryStream = new MemoryStream();

            requestSerializer.WriteObject(requestMemoryStream, request);
            string requestJson = Encoding.UTF8.GetString(requestMemoryStream.ToArray());

            string response = api.Post(path, queryParams, headers, requestJson);

            DataContractJsonSerializer responseSerializer = new DataContractJsonSerializer(typeof (CreateSubscriptionResponse));
            MemoryStream responseMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(response));

            CreateSubscriptionResponse responseObject = (CreateSubscriptionResponse) responseSerializer.ReadObject(responseMemoryStream);

            return responseObject;
        }
示例#6
0
        /// <summary>
        /// Creates a subscription plan.
        /// </summary>
        /// <param name="request">A "CreatePlanRequest" object containing the required data to be send to the API.</param>
        /// <returns>A "CreatePlanResponse" object, containing the response from the NETELLER REST API.</returns>
        public static CreatePlanResponse CreatePlan(CreatePlanRequest request)
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

            Dictionary<string, string> headers = new Dictionary<string, string>
            {
                {"Authorization", "Bearer " + token.accessToken}
            };

            DataContractJsonSerializer requestSerializer = new DataContractJsonSerializer(typeof (CreatePlanRequest));
            MemoryStream requestMemoryStream = new MemoryStream();

            requestSerializer.WriteObject(requestMemoryStream, request);
            string requestJson = Encoding.UTF8.GetString(requestMemoryStream.ToArray());

            const string path = "vi/plans";

            string response = api.Post(path, null, headers, requestJson);

            DataContractJsonSerializer responseSerializer = new DataContractJsonSerializer(typeof (CreatePlanResponse));
            MemoryStream responseMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(response));

            CreatePlanResponse responseObject = (CreatePlanResponse) responseSerializer.ReadObject(responseMemoryStream);

            return responseObject;
        }