diff --git a/.gitignore b/.gitignore index 1bc915c..c1ac7dd 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,6 @@ $RECYCLE.BIN/ # Mac desktop service store files .DS_Store + +# Visual Studio 2015 cache/options directory +.vs/ \ No newline at end of file diff --git a/Openpay/BankAccountService.cs b/Openpay/BankAccountService.cs index 77acb71..6a8c4fb 100644 --- a/Openpay/BankAccountService.cs +++ b/Openpay/BankAccountService.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Openpay.Entities; +using Openpay.Entities; using Openpay.Entities.Request; +using System.Collections.Generic; namespace Openpay { - public class BankAccountService : OpenpayResourceService + public class BankAccountService : OpenpayResourceService, IBankAccountService { public BankAccountService(string api_key, string merchant_id, bool production = false) @@ -32,7 +29,7 @@ public BankAccount Create(BankAccount bankAccount) return base.Create(null, bankAccount); } - + public new void Delete(string customer_id, string bankAccount_id) { diff --git a/Openpay/CardService.cs b/Openpay/CardService.cs index 6ba9b19..e21b5e0 100644 --- a/Openpay/CardService.cs +++ b/Openpay/CardService.cs @@ -1,14 +1,10 @@ using Openpay.Entities; using Openpay.Entities.Request; -using Openpay.Utils; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class CardService : OpenpayResourceService + public class CardService : OpenpayResourceService, ICardService { public CardService(string api_key, string merchant_id, bool production = false) : base(api_key, merchant_id, production) @@ -62,17 +58,17 @@ public List List(SearchParams filters = null) return base.List(null, filters); } - public PointsBalance Points(string card_id) - { - string ep = GetEndPoint(null, card_id) + "/points"; - return this.httpClient.Get(ep); - } + public PointsBalance Points(string card_id) + { + string ep = GetEndPoint(null, card_id) + "/points"; + return this.httpClient.Get(ep); + } - public PointsBalance Points(string customer_id, string card_id) - { - string ep = GetEndPoint(customer_id, card_id) + "/points"; - return this.httpClient.Get(ep); - } + public PointsBalance Points(string customer_id, string card_id) + { + string ep = GetEndPoint(customer_id, card_id) + "/points"; + return this.httpClient.Get(ep); + } - } + } } diff --git a/Openpay/ChargeService.cs b/Openpay/ChargeService.cs index 3852265..bb70a06 100644 --- a/Openpay/ChargeService.cs +++ b/Openpay/ChargeService.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Openpay.Entities; +using Openpay.Entities; using Openpay.Entities.Request; +using System; +using System.Collections.Generic; namespace Openpay { - public class ChargeService : OpenpayResourceService + public class ChargeService : OpenpayResourceService, IChargeService { public ChargeService(string api_key, string merchant_id, bool production = false) @@ -27,36 +25,36 @@ public Charge Refund(string charge_id, string description) return this.Refund(null, charge_id, description); } - public Charge Refund(string charge_id, string description, Decimal? amount) - { - return this.Refund(null, charge_id, description, amount); - } + public Charge Refund(string charge_id, string description, Decimal? amount) + { + return this.Refund(null, charge_id, description, amount); + } - public Charge Refund(string customer_id, string charge_id, string description) + public Charge Refund(string customer_id, string charge_id, string description) { return this.Refund(customer_id, charge_id, description, null); - } - - public Charge Refund(string customer_id, string charge_id, string description, Decimal? amount) - { - if (charge_id == null) - throw new ArgumentNullException("charge_id cannot be null"); - string ep = GetEndPoint(customer_id, charge_id) + "/refund"; - RefundRequest request = new RefundRequest(); - request.Description = description; - - if (amount != null) - request.Amount = amount; - - return this.httpClient.Post(ep, request); - } + } + + public Charge Refund(string customer_id, string charge_id, string description, Decimal? amount) + { + if (charge_id == null) + throw new ArgumentNullException("charge_id cannot be null"); + string ep = GetEndPoint(customer_id, charge_id) + "/refund"; + RefundRequest request = new RefundRequest(); + request.Description = description; + + if (amount != null) + request.Amount = amount; + + return this.httpClient.Post(ep, request); + } public Charge Capture(string charge_id, Decimal? amount) { return this.Capture(null, charge_id, amount); } - public Charge Capture(string customer_id , string charge_id, Decimal? amount) + public Charge Capture(string customer_id, string charge_id, Decimal? amount) { if (charge_id == null) throw new ArgumentNullException("charge_id cannot be null"); @@ -72,13 +70,13 @@ public Charge Create(ChargeRequest charge_request) } public new Charge Create(string customer_id, ChargeRequest charge_request) - { + { return base.Create(customer_id, charge_request); } public Charge CancelByMerchant(string merchant_id, string charge_id, ChargeRequest charge_request) { - return base.CancelByMerchant(merchant_id, charge_id, charge_request); + return base.CancelByMerchant(merchant_id, charge_id, charge_request); } public new Charge Get(string customer_id, string charge_id) @@ -100,6 +98,6 @@ public List List(SearchParams filters = null) { return base.List(null, filters); } - + } } diff --git a/Openpay/CustomerService.cs b/Openpay/CustomerService.cs index fc10b65..29230b6 100644 --- a/Openpay/CustomerService.cs +++ b/Openpay/CustomerService.cs @@ -1,14 +1,10 @@ using Openpay.Entities; using Openpay.Entities.Request; -using Openpay.Utils; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class CustomerService : OpenpayResourceService + public class CustomerService : OpenpayResourceService, ICustomerService { public CustomerService(string api_key, string merchant_id, bool production = false) diff --git a/Openpay/FeeService.cs b/Openpay/FeeService.cs index 2f58944..86eeb82 100644 --- a/Openpay/FeeService.cs +++ b/Openpay/FeeService.cs @@ -1,14 +1,11 @@ using Openpay.Entities; using Openpay.Entities.Request; -using Openpay.Utils; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class FeeService : OpenpayResourceService + public class FeeService : OpenpayResourceService, IFeeService { public FeeService(string api_key, string merchant_id, bool production = false) @@ -33,17 +30,17 @@ public List List(SearchParams filters = null) return base.List(null, filters); } - public Fee Refund(string charge_id, string description) - { - if (charge_id == null) - throw new ArgumentNullException("charge_id cannot be null"); - string ep = GetEndPoint(null, charge_id) + "/refund"; + public Fee Refund(string charge_id, string description) + { + if (charge_id == null) + throw new ArgumentNullException("charge_id cannot be null"); + string ep = GetEndPoint(null, charge_id) + "/refund"; - RefundRequest request = new RefundRequest(); - request.Description = description; + RefundRequest request = new RefundRequest(); + request.Description = description; - return this.httpClient.Post(ep, request); - } + return this.httpClient.Post(ep, request); + } - } + } } diff --git a/Openpay/IBankAccountService.cs b/Openpay/IBankAccountService.cs new file mode 100644 index 0000000..4ab3d58 --- /dev/null +++ b/Openpay/IBankAccountService.cs @@ -0,0 +1,18 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IBankAccountService + { + BankAccount Create(BankAccount bankAccount); + BankAccount Create(string customer_id, BankAccount bankAccount); + void Delete(string bankAccount_id); + void Delete(string customer_id, string bankAccount_id); + BankAccount Get(string bankAccount_id); + BankAccount Get(string customer_id, string bankAccount_id); + List List(SearchParams filters = null); + List List(string customer_id, SearchParams filters = null); + } +} \ No newline at end of file diff --git a/Openpay/ICardService.cs b/Openpay/ICardService.cs new file mode 100644 index 0000000..b4a5b21 --- /dev/null +++ b/Openpay/ICardService.cs @@ -0,0 +1,20 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface ICardService + { + Card Create(Card card); + Card Create(string customer_id, Card card); + void Delete(string card_id); + void Delete(string customer_id, string card_id); + Card Get(string card_id); + Card Get(string customer_id, string card_id); + List List(SearchParams filters = null); + List List(string customer_id, SearchParams filters = null); + PointsBalance Points(string card_id); + PointsBalance Points(string customer_id, string card_id); + } +} \ No newline at end of file diff --git a/Openpay/IChargeService.cs b/Openpay/IChargeService.cs new file mode 100644 index 0000000..ff9d9d3 --- /dev/null +++ b/Openpay/IChargeService.cs @@ -0,0 +1,23 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IChargeService + { + Charge CancelByMerchant(string merchant_id, string charge_id, ChargeRequest charge_request); + Charge Capture(string charge_id, decimal? amount); + Charge Capture(string customer_id, string charge_id, decimal? amount); + Charge Create(ChargeRequest charge_request); + Charge Create(string customer_id, ChargeRequest charge_request); + Charge Get(string charge_id); + Charge Get(string customer_id, string charge_id); + List List(SearchParams filters = null); + List List(string customer_id, SearchParams filters = null); + Charge Refund(string charge_id, string description); + Charge Refund(string charge_id, string description, decimal? amount); + Charge Refund(string customer_id, string charge_id, string description); + Charge Refund(string customer_id, string charge_id, string description, decimal? amount); + } +} \ No newline at end of file diff --git a/Openpay/ICustomerService.cs b/Openpay/ICustomerService.cs new file mode 100644 index 0000000..56be1ce --- /dev/null +++ b/Openpay/ICustomerService.cs @@ -0,0 +1,15 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface ICustomerService + { + Customer Create(Customer customer); + void Delete(string customer_id); + Customer Get(string customer_id); + List List(SearchParams filters = null); + Customer Update(Customer customer); + } +} \ No newline at end of file diff --git a/Openpay/IFeeService.cs b/Openpay/IFeeService.cs new file mode 100644 index 0000000..541fc70 --- /dev/null +++ b/Openpay/IFeeService.cs @@ -0,0 +1,13 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IFeeService + { + Fee Create(FeeRequest request); + List List(SearchParams filters = null); + Fee Refund(string charge_id, string description); + } +} \ No newline at end of file diff --git a/Openpay/IMerchantService.cs b/Openpay/IMerchantService.cs new file mode 100644 index 0000000..fae118e --- /dev/null +++ b/Openpay/IMerchantService.cs @@ -0,0 +1,9 @@ +using Openpay.Entities; + +namespace Openpay +{ + public interface IMerchantService + { + Merchant Get(); + } +} \ No newline at end of file diff --git a/Openpay/IOpenpayAPI.cs b/Openpay/IOpenpayAPI.cs new file mode 100644 index 0000000..0ed4a35 --- /dev/null +++ b/Openpay/IOpenpayAPI.cs @@ -0,0 +1,20 @@ +namespace Openpay +{ + public interface IOpenpayAPI + { + IBankAccountService BankAccountService { get; } + ICardService CardService { get; } + IChargeService ChargeService { get; } + ICustomerService CustomerService { get; } + IFeeService FeeService { get; } + IMerchantService MerchantService { get; set; } + IOpenpayFeesService OpenpayFeesService { get; } + IPayoutReportService PayoutReportService { get; } + IPayoutService PayoutService { get; } + IPlanService PlanService { get; } + bool Production { get; set; } + ISubscriptionService SubscriptionService { get; } + ITransferService TransferService { get; } + IWebhookService WebhooksService { get; set; } + } +} \ No newline at end of file diff --git a/Openpay/IOpenpayFeesService.cs b/Openpay/IOpenpayFeesService.cs new file mode 100644 index 0000000..f473cc3 --- /dev/null +++ b/Openpay/IOpenpayFeesService.cs @@ -0,0 +1,12 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IOpenpayFeesService + { + List Details(int year, int month, string fee_type, PaginationParams paginationParams); + OpenpayFeesSummary Summary(int year, int month); + } +} \ No newline at end of file diff --git a/Openpay/IPayoutReportService.cs b/Openpay/IPayoutReportService.cs new file mode 100644 index 0000000..ea8b2f0 --- /dev/null +++ b/Openpay/IPayoutReportService.cs @@ -0,0 +1,12 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IPayoutReportService + { + List Detail(string payout_id, PayoutReportDetailSearchParams searchParams); + PayoutSummary Get(string payout_id); + } +} \ No newline at end of file diff --git a/Openpay/IPayoutService.cs b/Openpay/IPayoutService.cs new file mode 100644 index 0000000..d5bac40 --- /dev/null +++ b/Openpay/IPayoutService.cs @@ -0,0 +1,18 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IPayoutService + { + void Cancel(string payout_id); + void Cancel(string customer_id, string payout_id); + Payout Create(PayoutRequest payout_request); + Payout Create(string customer_id, PayoutRequest payout_request); + Payout Get(string payout_id); + Payout Get(string customer_id, string payout_id); + List List(SearchParams filters = null); + List List(string customer_id, SearchParams filters = null); + } +} \ No newline at end of file diff --git a/Openpay/IPlanService.cs b/Openpay/IPlanService.cs new file mode 100644 index 0000000..8302013 --- /dev/null +++ b/Openpay/IPlanService.cs @@ -0,0 +1,16 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IPlanService + { + Plan Create(Plan plan); + void Delete(string plan_id); + Plan Get(string plan_id); + List List(SearchParams filters = null); + List Subscriptions(string plan_id, SearchParams filters = null); + Plan Update(Plan plan); + } +} \ No newline at end of file diff --git a/Openpay/ISubscriptionService.cs b/Openpay/ISubscriptionService.cs new file mode 100644 index 0000000..b6c477d --- /dev/null +++ b/Openpay/ISubscriptionService.cs @@ -0,0 +1,15 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface ISubscriptionService + { + Subscription Create(string customer_id, Subscription subscription); + void Delete(string customer_id, string subscription_id); + Subscription Get(string customer_id, string subscription_id); + List List(string customer_id, SearchParams filters = null); + Subscription Update(string customer_id, Subscription subscription); + } +} \ No newline at end of file diff --git a/Openpay/ITransferService.cs b/Openpay/ITransferService.cs new file mode 100644 index 0000000..28c9f9e --- /dev/null +++ b/Openpay/ITransferService.cs @@ -0,0 +1,13 @@ +using Openpay.Entities; +using Openpay.Entities.Request; +using System.Collections.Generic; + +namespace Openpay +{ + public interface ITransferService + { + Transfer Create(string customer_id, TransferRequest request); + Transfer Get(string customer_id, string transfer_id); + List List(string customer_id, SearchParams filters = null); + } +} \ No newline at end of file diff --git a/Openpay/IWebhookService.cs b/Openpay/IWebhookService.cs new file mode 100644 index 0000000..68a5241 --- /dev/null +++ b/Openpay/IWebhookService.cs @@ -0,0 +1,38 @@ +/* + * COPYRIGHT © 2014. OPENPAY. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Class: WebhookService.cs + * + * Change control: + * --------------------------------------------------------------------------------------- + * Version | Date | Name | Description + * --------------------------------------------------------------------------------------- + * 1.0 2014-12-01 Marcos Coronado marcos.coronado@openpay.mx Creating Class. + * + */ +using Openpay.Entities; +using System.Collections.Generic; + +namespace Openpay +{ + public interface IWebhookService + { + Webhook Create(Webhook webhook); + void Delete(string webhook_id); + Webhook Get(string webhook_id); + List List(); + void Verify(string webhook_id, string verification_code); + } +} \ No newline at end of file diff --git a/Openpay/MerchantService.cs b/Openpay/MerchantService.cs index dd2c3b4..7a4864d 100644 --- a/Openpay/MerchantService.cs +++ b/Openpay/MerchantService.cs @@ -1,14 +1,8 @@ using Openpay.Entities; -using Openpay.Entities.Request; -using Openpay.Utils; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Openpay { - public class MerchantService : OpenpayResourceService + public class MerchantService : OpenpayResourceService, IMerchantService { public MerchantService(string api_key, string merchant_id, bool production = false) @@ -27,6 +21,6 @@ public Merchant Get() { return base.Get(null, null); } - + } } diff --git a/Openpay/Openpay.csproj b/Openpay/Openpay.csproj index 8fb7891..554cdf2 100644 --- a/Openpay/Openpay.csproj +++ b/Openpay/Openpay.csproj @@ -50,6 +50,20 @@ + + + + + + + + + + + + + + @@ -107,6 +121,9 @@ Designer + + +