コード例 #1
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <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
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <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
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <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;
        }
コード例 #4
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <summary>
        /// Looks up a payment by provided merchantRefId or transactionId. 
        /// </summary>
        /// <param name="merchantRefId">Your unique identifier for this transaction that was supplied on your original request.</param>
        /// <param name="transactionId">The unique identifier for the transaction.</param>
        /// <param name="expand">Expands the specified resource. Possible values: "customer"</param>
        /// <returns>A "LookupPaymentResponse" object, containing the response from the NETELLER REST API.</returns>
        public static LookupPaymentResponse LookupPayment(string merchantRefId = "", string transactionId = "", string expand = "")
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

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

            string response = "";

            if (!String.IsNullOrEmpty(merchantRefId))
            {
                string path = "v1/payments/" + merchantRefId;

                Dictionary<string, string> queryParams = new Dictionary<string, string>
                {
                    {"refType", "merchantRefId"}
                };

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

                response = api.Get(path, queryParams, headers);
            }
            else if (!String.IsNullOrEmpty(transactionId))
            {
                string path = "v1/payments/" + transactionId;

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

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

                response = api.Get(path, queryParams, headers);
            }

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

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

            return responseObject;
        }
コード例 #5
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <summary>
        /// Look up details about a payment invoice issued for an order.
        /// </summary>
        /// <param name="orderId">The unique identifier for the order. (ie: ORD_7915d463-ccc8-4305-9d33-9e5c9310f12e)</param>
        /// <returns>A "LookupOrderInvoiceResponse" object, containing the response from the NETELLER REST API.</returns>
        public static LookupOrderInvoiceResponse LookupOrderInvoice(string orderId)
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

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

            string path = "v1/orders/" + orderId + "/invoice";

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

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

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

            return responseObject;
        }
コード例 #6
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <summary>
        /// Lookup details for a specific customer.
        /// </summary>
        /// <param name="customerId">The unique identifier for the customer.</param>
        /// <param name="email">The customer's NETELLER registered Email</param>
        /// <param name="accountId">The customer's NETELLER Account ID.</param>
        /// <returns>A "LookupCustomerResponse" object, containing the response from the NETELLER REST API.</returns>
        public static LookupCustomerResponse LookupCustomer(string customerId = "", string email = "",
            string accountId = "")
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

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

            string response = "";

            if (!String.IsNullOrEmpty(customerId))
            {
                string path = "v1/customers/" + customerId;

                response = api.Get(path, null, headers);
            }
            else if (!String.IsNullOrEmpty(email))
            {
                const string path = "v1/customers";

                Dictionary<string, string> queryParams = new Dictionary<string, string>
                {
                    {"email", email}
                };

                response = api.Get(path, queryParams, headers);
            }
            else if (!String.IsNullOrEmpty(accountId))
            {
                const string path = "v1/customers";

                Dictionary<string, string> queryParams = new Dictionary<string, string>
                {
                    {"accountId", accountId}
                };

                response = api.Get(path, queryParams, headers);
            }

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

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

            return responseObject;
        }
コード例 #7
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <summary>
        /// Lists all previously created subscriptions.
        /// </summary>
        /// <param name="limit">Sets the number of records to be returned.</param>
        /// <param name="offset">Sets the results offset.</param>
        /// <returns>A "ListSubscriptionsResponse" object, containing the response from the NETELLER REST API.</returns>
        public static ListSubscriptionsResponse ListSubscriptions(string limit = "", string offset = "")
        {
            NetellerApi api = new NetellerApi();
            Token token = api.getToken_clientCredentials();

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

            const string path = "v1/subscriptions";

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

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

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

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

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

            return responseObject;
        }
コード例 #8
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <summary>
        /// Deletes a previously created subscription plan.
        /// </summary>
        /// <param name="planId">The unique identifier for the subscription plan.</param>
        public static void DeletePlan(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;

            api.Delete(path, null, headers, null);
        }
コード例 #9
0
ファイル: NetellerAPI.cs プロジェクト: kibabiba/Examples
        /// <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;
        }