From bb06ba5497aee0b40c947f0ebaa204ffc9520f4a Mon Sep 17 00:00:00 2001 From: Asawari Vaidya Date: Thu, 20 Oct 2016 17:37:28 +0530 Subject: [PATCH] sdk with sample applications --- Paysafe.sln | 34 + Paysafe/CardPayments/AccordD.cs | 182 +++ Paysafe/CardPayments/AcquireResponse.cs | 444 ++++++++ Paysafe/CardPayments/Authorization.cs | 840 ++++++++++++++ Paysafe/CardPayments/AuthorizationReversal.cs | 362 ++++++ Paysafe/CardPayments/BillingDetails.cs | 135 +++ Paysafe/CardPayments/Card.cs | 308 +++++ Paysafe/CardPayments/CardPaymentService.cs | 631 ++++++++++ Paysafe/CardPayments/CardPaymentsConstants.cs | 64 ++ Paysafe/CardPayments/Filter.cs | 51 + Paysafe/CardPayments/MasterPass.cs | 121 ++ Paysafe/CardPayments/MerchantDescriptor.cs | 124 ++ Paysafe/CardPayments/Pagerator.cs | 64 ++ Paysafe/CardPayments/PaysafeAuthentication.cs | 247 ++++ Paysafe/CardPayments/Profile.cs | 154 +++ Paysafe/CardPayments/Refund.cs | 363 ++++++ Paysafe/CardPayments/Settlement.cs | 382 +++++++ Paysafe/CardPayments/ShippingDetails.cs | 229 ++++ Paysafe/CardPayments/Verification.cs | 571 ++++++++++ .../CardPayments/VisaAdditionalAuthData.cs | 119 ++ Paysafe/Common/APIException.cs | 47 + Paysafe/Common/AbstractPagerator.cs | 156 +++ Paysafe/Common/AddressDetails.cs | 160 +++ Paysafe/Common/BaseJSONBuilder.cs | 40 + Paysafe/Common/CardExpiry.cs | 121 ++ Paysafe/Common/CommonConstants.cs | 33 + Paysafe/Common/Email.cs | 33 + Paysafe/Common/EntityNotFoundException.cs | 47 + Paysafe/Common/Error.cs | 137 +++ Paysafe/Common/FieldError.cs | 82 ++ Paysafe/Common/GenericJSONBuilder.cs | 34 + Paysafe/Common/GlobalConstants.cs | 358 ++++++ Paysafe/Common/InvalidCredentialsException.cs | 47 + Paysafe/Common/InvalidRequestException.cs | 47 + Paysafe/Common/JSONObject.cs | 471 ++++++++ Paysafe/Common/JsonHelper.cs | 67 ++ Paysafe/Common/Link.cs | 82 ++ Paysafe/Common/NestedJSONBuilder.cs | 54 + Paysafe/Common/PaysafeException.cs | 71 ++ Paysafe/Common/PermissionException.cs | 28 + Paysafe/Common/RecipientDateOfBirth.cs | 100 ++ Paysafe/Common/Request.cs | 126 ++ Paysafe/Common/RequestConflictException.cs | 47 + Paysafe/Common/RequestDeclinedException.cs | 47 + Paysafe/Common/Url.cs | 33 + Paysafe/CustomerVault/ACHBankAccounts.cs | 449 ++++++++ Paysafe/CustomerVault/Address.cs | 329 ++++++ Paysafe/CustomerVault/BACSBankAccounts.cs | 450 ++++++++ Paysafe/CustomerVault/BillingAddress.cs | 144 +++ Paysafe/CustomerVault/Card.cs | 744 ++++++++++++ .../CustomerVault/CustomerVaultConstants.cs | 49 + Paysafe/CustomerVault/CustomerVaultService.cs | 1013 +++++++++++++++++ Paysafe/CustomerVault/DateOfBirth.cs | 97 ++ Paysafe/CustomerVault/EFTBankAccounts.cs | 448 ++++++++ Paysafe/CustomerVault/Mandates.cs | 330 ++++++ Paysafe/CustomerVault/Profile.cs | 654 +++++++++++ Paysafe/CustomerVault/SEPABankAccounts.cs | 508 +++++++++ Paysafe/DirectDebit/ACHBankAccounts.cs | 299 +++++ Paysafe/DirectDebit/BACSBankAccounts.cs | 251 ++++ Paysafe/DirectDebit/BillingDetails.cs | 136 +++ Paysafe/DirectDebit/DateOfBirth.cs | 98 ++ Paysafe/DirectDebit/DirectDebitConstants.cs | 46 + Paysafe/DirectDebit/DirectDebitService.cs | 333 ++++++ Paysafe/DirectDebit/EFTBankAccounts.cs | 274 +++++ Paysafe/DirectDebit/Filter.cs | 52 + Paysafe/DirectDebit/Pagerator.cs | 94 ++ Paysafe/DirectDebit/Profile.cs | 175 +++ Paysafe/DirectDebit/Purchases.cs | 538 +++++++++ Paysafe/DirectDebit/SEPABankAccounts.cs | 214 ++++ Paysafe/DirectDebit/ShippingDetails.cs | 230 ++++ Paysafe/DirectDebit/StandaloneCredits.cs | 552 +++++++++ Paysafe/Environment.cs | 33 + Paysafe/Paysafe.csproj | 141 +++ Paysafe/PaysafeApiClient.cs | 292 +++++ Paysafe/Properties/AssemblyInfo.cs | 30 + Paysafe/RequestType.cs | 35 + Paysafe/ThreeDSecure/Authentications.cs | 487 ++++++++ Paysafe/ThreeDSecure/Card.cs | 308 +++++ Paysafe/ThreeDSecure/EnrollmentChecks.cs | 560 +++++++++ Paysafe/ThreeDSecure/Error.cs | 123 ++ Paysafe/ThreeDSecure/ThreeDSecureConstants.cs | 65 ++ Paysafe/ThreeDSecure/ThreeDSecureService.cs | 168 +++ Paysafe/app.config | 15 + Paysafe/packages.config | 4 + README.md | 15 +- SampleApp/3DS classification.html | 24 + SampleApp/Properties/AssemblyInfo.cs | 35 + SampleApp/SampleApp.csproj | 246 ++++ SampleApp/SampleApp.csproj.user | 27 + SampleApp/ThreeDSecure_Authentication.aspx | 138 +++ SampleApp/ThreeDSecure_Authentication.aspx.cs | 67 ++ ...reeDSecure_Authentication.aspx.designer.cs | 24 + SampleApp/ThreeDSecure_EnrollmentChecks.aspx | 105 ++ .../ThreeDSecure_EnrollmentChecks.aspx.cs | 55 + ...eDSecure_EnrollmentChecks.aspx.designer.cs | 24 + SampleApp/Web.Debug.config | 30 + SampleApp/Web.Release.config | 31 + SampleApp/Web.config | 30 + SampleApp/card-payment-simple.aspx | 162 +++ SampleApp/card-payment-simple.aspx.cs | 81 ++ .../card-payment-simple.aspx.designer.cs | 42 + SampleApp/card-payment-w-customervault.aspx | 189 +++ .../card-payment-w-customervault.aspx.cs | 96 ++ ...d-payment-w-customervault.aspx.designer.cs | 42 + .../customervault-mandate-w-BACSAccount.aspx | 49 + ...ustomervault-mandate-w-BACSAccount.aspx.cs | 78 ++ ...ult-mandate-w-BACSAccount.aspx.designer.cs | 24 + .../customervault-mandate-w-SEPAAccount.aspx | 48 + ...ustomervault-mandate-w-SEPAAccount.aspx.cs | 79 ++ ...ult-mandate-w-SEPAAccount.aspx.designer.cs | 24 + SampleApp/customervault-w-ACHAccount.aspx | 70 ++ SampleApp/customervault-w-ACHAccount.aspx.cs | 74 ++ ...ustomervault-w-ACHAccount.aspx.designer.cs | 24 + SampleApp/customervault-w-BACSAccount.aspx | 48 + SampleApp/customervault-w-BACSAccount.aspx.cs | 73 ++ ...stomervault-w-BACSAccount.aspx.designer.cs | 24 + SampleApp/customervault-w-EFTAccount.aspx | 70 ++ SampleApp/customervault-w-EFTAccount.aspx.cs | 73 ++ ...ustomervault-w-EFTAccount.aspx.designer.cs | 24 + SampleApp/customervault-w-SEPAAccount.aspx | 55 + SampleApp/customervault-w-SEPAAccount.aspx.cs | 72 ++ ...stomervault-w-SEPAAccount.aspx.designer.cs | 24 + SampleApp/customervaultclassification.html | 15 + .../direct-debit-purchase-ACHAccount.aspx | 197 ++++ .../direct-debit-purchase-ACHAccount.aspx.cs | 64 ++ ...debit-purchase-ACHAccount.aspx.designer.cs | 24 + .../direct-debit-purchase-BACSAccount.aspx | 197 ++++ .../direct-debit-purchase-BACSAccount.aspx.cs | 63 + ...ebit-purchase-BACSAccount.aspx.designer.cs | 24 + .../direct-debit-purchase-EFTAccount.aspx | 190 ++++ .../direct-debit-purchase-EFTAccount.aspx.cs | 62 + ...debit-purchase-EFTAccount.aspx.designer.cs | 24 + .../direct-debit-purchase-SEPAAccount.aspx | 152 +++ .../direct-debit-purchase-SEPAAccount.aspx.cs | 65 ++ ...ebit-purchase-SEPAAccount.aspx.designer.cs | 24 + ...t-debit-purchase-w-token-all accounts.aspx | 61 + ...ebit-purchase-w-token-all accounts.aspx.cs | 186 +++ ...hase-w-token-all accounts.aspx.designer.cs | 33 + ...ct-debit-standalonecredits-ACHAccount.aspx | 196 ++++ ...debit-standalonecredits-ACHAccount.aspx.cs | 63 + ...ndalonecredits-ACHAccount.aspx.designer.cs | 24 + ...t-debit-standalonecredits-BACSAccount.aspx | 197 ++++ ...ebit-standalonecredits-BACSAccount.aspx.cs | 63 + ...dalonecredits-BACSAccount.aspx.designer.cs | 24 + ...ct-debit-standalonecredits-EFTAccount.aspx | 190 ++++ ...debit-standalonecredits-EFTAccount.aspx.cs | 62 + ...ndalonecredits-EFTAccount.aspx.designer.cs | 24 + ...tandalonecredits-w-token-all accounts.aspx | 60 + ...dalonecredits-w-token-all accounts.aspx.cs | 187 +++ ...dits-w-token-all accounts.aspx.designer.cs | 33 + SampleApp/directdebit classification.html | 41 + SampleApp/index.html | 11 + packages/repositories.config | 6 + 153 files changed, 23617 insertions(+), 2 deletions(-) create mode 100644 Paysafe.sln create mode 100644 Paysafe/CardPayments/AccordD.cs create mode 100644 Paysafe/CardPayments/AcquireResponse.cs create mode 100644 Paysafe/CardPayments/Authorization.cs create mode 100644 Paysafe/CardPayments/AuthorizationReversal.cs create mode 100644 Paysafe/CardPayments/BillingDetails.cs create mode 100644 Paysafe/CardPayments/Card.cs create mode 100644 Paysafe/CardPayments/CardPaymentService.cs create mode 100644 Paysafe/CardPayments/CardPaymentsConstants.cs create mode 100644 Paysafe/CardPayments/Filter.cs create mode 100644 Paysafe/CardPayments/MasterPass.cs create mode 100644 Paysafe/CardPayments/MerchantDescriptor.cs create mode 100644 Paysafe/CardPayments/Pagerator.cs create mode 100644 Paysafe/CardPayments/PaysafeAuthentication.cs create mode 100644 Paysafe/CardPayments/Profile.cs create mode 100644 Paysafe/CardPayments/Refund.cs create mode 100644 Paysafe/CardPayments/Settlement.cs create mode 100644 Paysafe/CardPayments/ShippingDetails.cs create mode 100644 Paysafe/CardPayments/Verification.cs create mode 100644 Paysafe/CardPayments/VisaAdditionalAuthData.cs create mode 100644 Paysafe/Common/APIException.cs create mode 100644 Paysafe/Common/AbstractPagerator.cs create mode 100644 Paysafe/Common/AddressDetails.cs create mode 100644 Paysafe/Common/BaseJSONBuilder.cs create mode 100644 Paysafe/Common/CardExpiry.cs create mode 100644 Paysafe/Common/CommonConstants.cs create mode 100644 Paysafe/Common/Email.cs create mode 100644 Paysafe/Common/EntityNotFoundException.cs create mode 100644 Paysafe/Common/Error.cs create mode 100644 Paysafe/Common/FieldError.cs create mode 100644 Paysafe/Common/GenericJSONBuilder.cs create mode 100644 Paysafe/Common/GlobalConstants.cs create mode 100644 Paysafe/Common/InvalidCredentialsException.cs create mode 100644 Paysafe/Common/InvalidRequestException.cs create mode 100644 Paysafe/Common/JSONObject.cs create mode 100644 Paysafe/Common/JsonHelper.cs create mode 100644 Paysafe/Common/Link.cs create mode 100644 Paysafe/Common/NestedJSONBuilder.cs create mode 100644 Paysafe/Common/PaysafeException.cs create mode 100644 Paysafe/Common/PermissionException.cs create mode 100644 Paysafe/Common/RecipientDateOfBirth.cs create mode 100644 Paysafe/Common/Request.cs create mode 100644 Paysafe/Common/RequestConflictException.cs create mode 100644 Paysafe/Common/RequestDeclinedException.cs create mode 100644 Paysafe/Common/Url.cs create mode 100644 Paysafe/CustomerVault/ACHBankAccounts.cs create mode 100644 Paysafe/CustomerVault/Address.cs create mode 100644 Paysafe/CustomerVault/BACSBankAccounts.cs create mode 100644 Paysafe/CustomerVault/BillingAddress.cs create mode 100644 Paysafe/CustomerVault/Card.cs create mode 100644 Paysafe/CustomerVault/CustomerVaultConstants.cs create mode 100644 Paysafe/CustomerVault/CustomerVaultService.cs create mode 100644 Paysafe/CustomerVault/DateOfBirth.cs create mode 100644 Paysafe/CustomerVault/EFTBankAccounts.cs create mode 100644 Paysafe/CustomerVault/Mandates.cs create mode 100644 Paysafe/CustomerVault/Profile.cs create mode 100644 Paysafe/CustomerVault/SEPABankAccounts.cs create mode 100644 Paysafe/DirectDebit/ACHBankAccounts.cs create mode 100644 Paysafe/DirectDebit/BACSBankAccounts.cs create mode 100644 Paysafe/DirectDebit/BillingDetails.cs create mode 100644 Paysafe/DirectDebit/DateOfBirth.cs create mode 100644 Paysafe/DirectDebit/DirectDebitConstants.cs create mode 100644 Paysafe/DirectDebit/DirectDebitService.cs create mode 100644 Paysafe/DirectDebit/EFTBankAccounts.cs create mode 100644 Paysafe/DirectDebit/Filter.cs create mode 100644 Paysafe/DirectDebit/Pagerator.cs create mode 100644 Paysafe/DirectDebit/Profile.cs create mode 100644 Paysafe/DirectDebit/Purchases.cs create mode 100644 Paysafe/DirectDebit/SEPABankAccounts.cs create mode 100644 Paysafe/DirectDebit/ShippingDetails.cs create mode 100644 Paysafe/DirectDebit/StandaloneCredits.cs create mode 100644 Paysafe/Environment.cs create mode 100644 Paysafe/Paysafe.csproj create mode 100644 Paysafe/PaysafeApiClient.cs create mode 100644 Paysafe/Properties/AssemblyInfo.cs create mode 100644 Paysafe/RequestType.cs create mode 100644 Paysafe/ThreeDSecure/Authentications.cs create mode 100644 Paysafe/ThreeDSecure/Card.cs create mode 100644 Paysafe/ThreeDSecure/EnrollmentChecks.cs create mode 100644 Paysafe/ThreeDSecure/Error.cs create mode 100644 Paysafe/ThreeDSecure/ThreeDSecureConstants.cs create mode 100644 Paysafe/ThreeDSecure/ThreeDSecureService.cs create mode 100644 Paysafe/app.config create mode 100644 Paysafe/packages.config create mode 100644 SampleApp/3DS classification.html create mode 100644 SampleApp/Properties/AssemblyInfo.cs create mode 100644 SampleApp/SampleApp.csproj create mode 100644 SampleApp/SampleApp.csproj.user create mode 100644 SampleApp/ThreeDSecure_Authentication.aspx create mode 100644 SampleApp/ThreeDSecure_Authentication.aspx.cs create mode 100644 SampleApp/ThreeDSecure_Authentication.aspx.designer.cs create mode 100644 SampleApp/ThreeDSecure_EnrollmentChecks.aspx create mode 100644 SampleApp/ThreeDSecure_EnrollmentChecks.aspx.cs create mode 100644 SampleApp/ThreeDSecure_EnrollmentChecks.aspx.designer.cs create mode 100644 SampleApp/Web.Debug.config create mode 100644 SampleApp/Web.Release.config create mode 100644 SampleApp/Web.config create mode 100644 SampleApp/card-payment-simple.aspx create mode 100644 SampleApp/card-payment-simple.aspx.cs create mode 100644 SampleApp/card-payment-simple.aspx.designer.cs create mode 100644 SampleApp/card-payment-w-customervault.aspx create mode 100644 SampleApp/card-payment-w-customervault.aspx.cs create mode 100644 SampleApp/card-payment-w-customervault.aspx.designer.cs create mode 100644 SampleApp/customervault-mandate-w-BACSAccount.aspx create mode 100644 SampleApp/customervault-mandate-w-BACSAccount.aspx.cs create mode 100644 SampleApp/customervault-mandate-w-BACSAccount.aspx.designer.cs create mode 100644 SampleApp/customervault-mandate-w-SEPAAccount.aspx create mode 100644 SampleApp/customervault-mandate-w-SEPAAccount.aspx.cs create mode 100644 SampleApp/customervault-mandate-w-SEPAAccount.aspx.designer.cs create mode 100644 SampleApp/customervault-w-ACHAccount.aspx create mode 100644 SampleApp/customervault-w-ACHAccount.aspx.cs create mode 100644 SampleApp/customervault-w-ACHAccount.aspx.designer.cs create mode 100644 SampleApp/customervault-w-BACSAccount.aspx create mode 100644 SampleApp/customervault-w-BACSAccount.aspx.cs create mode 100644 SampleApp/customervault-w-BACSAccount.aspx.designer.cs create mode 100644 SampleApp/customervault-w-EFTAccount.aspx create mode 100644 SampleApp/customervault-w-EFTAccount.aspx.cs create mode 100644 SampleApp/customervault-w-EFTAccount.aspx.designer.cs create mode 100644 SampleApp/customervault-w-SEPAAccount.aspx create mode 100644 SampleApp/customervault-w-SEPAAccount.aspx.cs create mode 100644 SampleApp/customervault-w-SEPAAccount.aspx.designer.cs create mode 100644 SampleApp/customervaultclassification.html create mode 100644 SampleApp/direct-debit-purchase-ACHAccount.aspx create mode 100644 SampleApp/direct-debit-purchase-ACHAccount.aspx.cs create mode 100644 SampleApp/direct-debit-purchase-ACHAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-purchase-BACSAccount.aspx create mode 100644 SampleApp/direct-debit-purchase-BACSAccount.aspx.cs create mode 100644 SampleApp/direct-debit-purchase-BACSAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-purchase-EFTAccount.aspx create mode 100644 SampleApp/direct-debit-purchase-EFTAccount.aspx.cs create mode 100644 SampleApp/direct-debit-purchase-EFTAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-purchase-SEPAAccount.aspx create mode 100644 SampleApp/direct-debit-purchase-SEPAAccount.aspx.cs create mode 100644 SampleApp/direct-debit-purchase-SEPAAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-purchase-w-token-all accounts.aspx create mode 100644 SampleApp/direct-debit-purchase-w-token-all accounts.aspx.cs create mode 100644 SampleApp/direct-debit-purchase-w-token-all accounts.aspx.designer.cs create mode 100644 SampleApp/direct-debit-standalonecredits-ACHAccount.aspx create mode 100644 SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.cs create mode 100644 SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-standalonecredits-BACSAccount.aspx create mode 100644 SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.cs create mode 100644 SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-standalonecredits-EFTAccount.aspx create mode 100644 SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.cs create mode 100644 SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.designer.cs create mode 100644 SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx create mode 100644 SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.cs create mode 100644 SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.designer.cs create mode 100644 SampleApp/directdebit classification.html create mode 100644 SampleApp/index.html create mode 100644 packages/repositories.config diff --git a/Paysafe.sln b/Paysafe.sln new file mode 100644 index 0000000..4d4124f --- /dev/null +++ b/Paysafe.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paysafe", "Paysafe\Paysafe.csproj", "{1AA4F97B-967A-4420-B3CC-EF1EFBAA72F8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaysafeTests", "tests\PaysafeTests.csproj", "{5FCF0A84-E497-46AC-9058-CC79E6FEB872}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "SampleApp\SampleApp.csproj", "{A98AFF11-EA57-4475-9A27-7DB43053BA3F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1AA4F97B-967A-4420-B3CC-EF1EFBAA72F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1AA4F97B-967A-4420-B3CC-EF1EFBAA72F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1AA4F97B-967A-4420-B3CC-EF1EFBAA72F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1AA4F97B-967A-4420-B3CC-EF1EFBAA72F8}.Release|Any CPU.Build.0 = Release|Any CPU + {5FCF0A84-E497-46AC-9058-CC79E6FEB872}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FCF0A84-E497-46AC-9058-CC79E6FEB872}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FCF0A84-E497-46AC-9058-CC79E6FEB872}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FCF0A84-E497-46AC-9058-CC79E6FEB872}.Release|Any CPU.Build.0 = Release|Any CPU + {A98AFF11-EA57-4475-9A27-7DB43053BA3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A98AFF11-EA57-4475-9A27-7DB43053BA3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A98AFF11-EA57-4475-9A27-7DB43053BA3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A98AFF11-EA57-4475-9A27-7DB43053BA3F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Paysafe/CardPayments/AccordD.cs b/Paysafe/CardPayments/AccordD.cs new file mode 100644 index 0000000..4a68fa5 --- /dev/null +++ b/Paysafe/CardPayments/AccordD.cs @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class AccordD : JSONObject + { + /// + /// Initialize the AccordD object with some set of properties + /// + /// Dictionary + public AccordD(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.financingType, CardPaymentsConstants.enumFinancingType}, + {CardPaymentsConstants.plan, STRING_TYPE}, + {CardPaymentsConstants.gracePeriod, INT_TYPE}, + {CardPaymentsConstants.term, INT_TYPE} + }; + + /// + /// Get the financingType + /// + /// string + public string financingType() + { + return this.getProperty(CardPaymentsConstants.financingType); + } + + /// + /// Set the financingType + /// + /// void + public void financingType(string data) + { + this.setProperty(CardPaymentsConstants.financingType, data); + } + + /// + /// Get the plan + /// + /// string + public string plan() + { + return this.getProperty(CardPaymentsConstants.plan); + } + + /// + /// Set the plan + /// + /// void + public void plan(string data) + { + this.setProperty(CardPaymentsConstants.plan, data); + } + + /// + /// Get the gracePeriod + /// + /// int + public int gracePeriod() + { + return this.getProperty(CardPaymentsConstants.gracePeriod); + } + + /// + /// Set the gracePeriod + /// + /// void + public void gracePeriod(int data) + { + this.setProperty(CardPaymentsConstants.gracePeriod, data); + } + + /// + /// Get the term + /// + /// int + public int term() + { + return this.getProperty(CardPaymentsConstants.term); + } + + /// + /// Set the term + /// + /// void + public void term(int data) + { + this.setProperty(CardPaymentsConstants.term, data); + } + + /// + /// AccordDBuilder will allow a AccordD to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class AccordDBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the AccordD builder within the context of a parent builder + /// + /// TBLDR + public AccordDBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the financingType + /// + /// string + /// AccordDBuilder + public AccordDBuilder financingType(string data) + { + this.properties[CardPaymentsConstants.financingType] = data; + return this; + } + + /// + /// Set the plan + /// + /// string + /// AccordDBuilder + public AccordDBuilder plan(string data) + { + this.properties[CardPaymentsConstants.plan] = data; + return this; + } + + /// + /// Set the gracePeriod + /// + /// int + /// AccordDBuilder + public AccordDBuilder gracePeriod(int data) + { + this.properties[CardPaymentsConstants.gracePeriod] = data; + return this; + } + + /// + /// Set the term + /// + /// int + /// AccordDBuilder + public AccordDBuilder term(int data) + { + this.properties[CardPaymentsConstants.term] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/AcquireResponse.cs b/Paysafe/CardPayments/AcquireResponse.cs new file mode 100644 index 0000000..7388a1d --- /dev/null +++ b/Paysafe/CardPayments/AcquireResponse.cs @@ -0,0 +1,444 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + + public class AcquirerResponse : JSONObject + { + /// + /// Initialize the AcquirerResponse object with some set of properties + /// + /// Dictionary + public AcquirerResponse(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.code, STRING_TYPE}, + {CardPaymentsConstants.responseCode, STRING_TYPE}, + {CardPaymentsConstants.avsCode, STRING_TYPE}, + {CardPaymentsConstants.balanceResponse, STRING_TYPE}, + {CardPaymentsConstants.batchNumber, STRING_TYPE}, + {CardPaymentsConstants.effectiveDate, STRING_TYPE}, + {CardPaymentsConstants.financingType, STRING_TYPE}, + {CardPaymentsConstants.gracePeriod, STRING_TYPE}, + {CardPaymentsConstants.plan, STRING_TYPE}, + {CardPaymentsConstants.seqNumber, STRING_TYPE}, + {CardPaymentsConstants.term, STRING_TYPE}, + {CardPaymentsConstants.terminalId, STRING_TYPE}, + {CardPaymentsConstants.responseId, STRING_TYPE}, + {CardPaymentsConstants.requestId, STRING_TYPE}, + {CardPaymentsConstants.description, STRING_TYPE}, + {CardPaymentsConstants.authCode, STRING_TYPE}, + {CardPaymentsConstants.txnDateTime, STRING_TYPE}, + {CardPaymentsConstants.referenceNbr, STRING_TYPE}, + {CardPaymentsConstants.responseReasonCode, STRING_TYPE}, + {CardPaymentsConstants.cvv2Result, STRING_TYPE}, + {CardPaymentsConstants.mid, STRING_TYPE} + }; + + /// + /// Get the code + /// + /// string + public string code() + { + return this.getProperty(CardPaymentsConstants.code); + } + + /// + /// Set the code + /// + /// void + public void code(string data) + { + this.setProperty(CardPaymentsConstants.code, data); + } + + /// + /// Get the responseCode + /// + /// string + public string responseCode() + { + return this.getProperty(CardPaymentsConstants.responseCode); + } + + /// + /// Set the responseCode + /// + /// void + public void responseCode(string data) + { + this.setProperty(CardPaymentsConstants.responseCode, data); + } + + /// + /// Get the avsCode + /// + /// string + public string avsCode() + { + return this.getProperty(CardPaymentsConstants.avsCode); + } + + /// + /// Set the avsCode + /// + /// void + public void avsCode(string data) + { + this.setProperty(CardPaymentsConstants.avsCode, data); + } + + /// + /// Get the balanceResponse + /// + /// string + public string balanceResponse() + { + return this.getProperty(CardPaymentsConstants.balanceResponse); + } + + /// + /// Set the balanceResponse + /// + /// void + public void balanceResponse(string data) + { + this.setProperty(CardPaymentsConstants.balanceResponse, data); + } + + /// + /// Get the batchNumber + /// + /// string + public string batchNumber() + { + return this.getProperty(CardPaymentsConstants.batchNumber); + } + + /// + /// Set the batchNumber + /// + /// void + public void batchNumber(string data) + { + this.setProperty(CardPaymentsConstants.batchNumber, data); + } + + /// + /// Get the effectiveDate + /// + /// string + public string effectiveDate() + { + return this.getProperty(CardPaymentsConstants.effectiveDate); + } + + /// + /// Set the effectiveDate + /// + /// void + public void effectiveDate(string data) + { + this.setProperty(CardPaymentsConstants.effectiveDate, data); + } + + /// + /// Get the financingType + /// + /// string + public string financingType() + { + return this.getProperty(CardPaymentsConstants.financingType); + } + + /// + /// Set the financingType + /// + /// void + public void financingType(string data) + { + this.setProperty(CardPaymentsConstants.financingType, data); + } + + /// + /// Get the gracePeriod + /// + /// int + public int gracePeriod() + { + return this.getProperty(CardPaymentsConstants.gracePeriod); + } + + /// + /// Set the gracePeriod + /// + /// void + public void gracePeriod(int data) + { + this.setProperty(CardPaymentsConstants.gracePeriod, data); + } + + /// + /// Get the plan + /// + /// string + public string plan() + { + return this.getProperty(CardPaymentsConstants.plan); + } + + /// + /// Set the plan + /// + /// void + public void plan(string data) + { + this.setProperty(CardPaymentsConstants.plan, data); + } + + /// + /// Get the seqNumber + /// + /// string + public string seqNumber() + { + return this.getProperty(CardPaymentsConstants.seqNumber); + } + + /// + /// Set the seqNumber + /// + /// void + public void seqNumber(string data) + { + this.setProperty(CardPaymentsConstants.seqNumber, data); + } + + /// + /// Get the term + /// + /// string + public string term() + { + return this.getProperty(CardPaymentsConstants.term); + } + + /// + /// Set the term + /// + /// void + public void term(int data) + { + this.setProperty(CardPaymentsConstants.term, data); + } + + /// + /// Get the terminalId + /// + /// string + public string terminalId() + { + return this.getProperty(CardPaymentsConstants.terminalId); + } + + /// + /// Set the terminalId + /// + /// void + public void terminalId(int data) + { + this.setProperty(CardPaymentsConstants.terminalId, data); + } + + /// + /// Get the requestId + /// + /// string + public string requestId() + { + return this.getProperty(CardPaymentsConstants.requestId); + } + + /// + /// Set the requestId + /// + /// void + public void requestId(int data) + { + this.setProperty(CardPaymentsConstants.requestId, data); + } + + /// + /// Get the responseId + /// + /// string + public string responseId() + { + return this.getProperty(CardPaymentsConstants.responseId); + } + + /// + /// Set the responseId + /// + /// void + public void responseId(int data) + { + this.setProperty(CardPaymentsConstants.terminalId, data); + } + + /// + /// Get the description + /// + /// string + public string description() + { + return this.getProperty(CardPaymentsConstants.description); + } + + /// + /// Set the description + /// + /// void + public void description(string data) + { + this.setProperty(CardPaymentsConstants.description, data); + } + + /// + /// Get the authCode + /// + /// string + public string authCode() + { + return this.getProperty(CardPaymentsConstants.authCode); + } + + /// + /// Set the authCode + /// + /// void + public void authCode(string data) + { + this.setProperty(CardPaymentsConstants.authCode, data); + } + + /// + /// Get the txnDateTime + /// + /// string + public string txnDateTime() + { + return this.getProperty(CardPaymentsConstants.txnDateTime); + } + + /// + /// Set the txnDateTime + /// + /// void + public void txnDateTime(string data) + { + this.setProperty(CardPaymentsConstants.txnDateTime, data); + } + + /// + /// Get the referenceNbr + /// + /// string + public string referenceNbr() + { + return this.getProperty(CardPaymentsConstants.referenceNbr); + } + + /// + /// Set the referenceNbr + /// + /// void + public void referenceNbr(string data) + { + this.setProperty(CardPaymentsConstants.referenceNbr, data); + } + + /// + /// Get the responseReasonCode + /// + /// string + public string responseReasonCode() + { + return this.getProperty(CardPaymentsConstants.responseReasonCode); + } + + /// + /// Set the responseReasonCode + /// + /// void + public void responseReasonCode(string data) + { + this.setProperty(CardPaymentsConstants.responseReasonCode, data); + } + + /// + /// Get the cvv2Result + /// + /// string + public string cvv2Result() + { + return this.getProperty(CardPaymentsConstants.cvv2Result); + } + + /// + /// Set the cvv2Result + /// + /// void + public void cvv2Result(string data) + { + this.setProperty(CardPaymentsConstants.cvv2Result, data); + } + + /// + /// Get the mid + /// + /// string + public string mid() + { + return this.getProperty(CardPaymentsConstants.mid); + } + + /// + /// Set the mid + /// + /// void + public void mid(string data) + { + this.setProperty(CardPaymentsConstants.mid, data); + } + + } +} diff --git a/Paysafe/CardPayments/Authorization.cs b/Paysafe/CardPayments/Authorization.cs new file mode 100644 index 0000000..c42466e --- /dev/null +++ b/Paysafe/CardPayments/Authorization.cs @@ -0,0 +1,840 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class Authorization : JSONObject + { + + /// + /// Gets the array key to access the array of authorizations + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return "auths"; + } + + /// + /// Initialize the Authorization object with some set of properties + /// + /// Dictionary + public Authorization(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize an authorization object with an id + /// + /// + public Authorization(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// This object is used to validate any properties set within the object + /// + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.id, STRING_TYPE}, + {CardPaymentsConstants.merchantRefNum, STRING_TYPE}, + {CardPaymentsConstants.amount, INT_TYPE}, + {CardPaymentsConstants.settleWithAuth, BOOL_TYPE}, + {CardPaymentsConstants.availableToSettle, INT_TYPE}, + {CardPaymentsConstants.childAccountNum, STRING_TYPE}, + {CardPaymentsConstants.card, typeof(Card)}, + {CardPaymentsConstants.authentication, typeof(PaysafeAuthentication)}, + {CardPaymentsConstants.authCode, STRING_TYPE}, + {CardPaymentsConstants.profile, typeof(Profile)}, + {CardPaymentsConstants.billingDetails, typeof(BillingDetails)}, + {CardPaymentsConstants.shippingDetails, typeof(ShippingDetails)}, + {CardPaymentsConstants.recurring, CardPaymentsConstants.enumRecurring}, + {CardPaymentsConstants.customerIp, STRING_TYPE}, + {CardPaymentsConstants.dupCheck, BOOL_TYPE}, + {CardPaymentsConstants.keywords, typeof(List)}, + {CardPaymentsConstants.merchantDescriptor, typeof(MerchantDescriptor)}, + {CardPaymentsConstants.accordD, typeof(AccordD)}, + {CardPaymentsConstants.description, STRING_TYPE}, + {CardPaymentsConstants.masterPass, typeof(MasterPass)}, + {CardPaymentsConstants.txnTime, typeof(System.DateTime)}, + {CardPaymentsConstants.currencyCode, STRING_TYPE}, + {CardPaymentsConstants.avsResponse, CardPaymentsConstants.enumAVSResponse}, + {CardPaymentsConstants.cvvVerification, CardPaymentsConstants.enumCVVVerification}, + {CardPaymentsConstants.status, CardPaymentsConstants.enumStatus}, + {CardPaymentsConstants.riskReasonCode, typeof(List)}, + {CardPaymentsConstants.acquirerResponse, typeof(AcquirerResponse)}, + {CardPaymentsConstants.visaAdditionalAuthData, typeof(VisaAdditionalAuthData)}, + {CardPaymentsConstants.settlements, typeof(List)}, + {CardPaymentsConstants.error, typeof(OptError)}, + {CardPaymentsConstants.links, typeof(List)} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CardPaymentsConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CardPaymentsConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CardPaymentsConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CardPaymentsConstants.merchantRefNum, data); + } + + /// + /// Get the amount + /// + /// int + public int amount() + { + return this.getProperty(CardPaymentsConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(CardPaymentsConstants.amount, data); + } + + /// + /// Get the settleWithAuth + /// + /// bool + public bool settleWithAuth() + { + return this.getProperty(CardPaymentsConstants.settleWithAuth); + } + + /// + /// Set the settleWithAuth + /// + /// void + public void settleWithAuth(bool data) + { + this.setProperty(CardPaymentsConstants.settleWithAuth, data); + } + + /// + /// Get the availableToSettle + /// + /// int + public int availableToSettle() + { + return this.getProperty(CardPaymentsConstants.availableToSettle); + } + + /// + /// Set the availableToSettle + /// + /// void + public void availableToSettle(int data) + { + this.setProperty(CardPaymentsConstants.availableToSettle, data); + } + + /// + /// Get the childAccountNum + /// + /// string + public string childAccountNum() + { + return this.getProperty(CardPaymentsConstants.childAccountNum); + } + + /// + /// Set the childAccountNum + /// + /// void + public void childAccountNum(string data) + { + this.setProperty(CardPaymentsConstants.childAccountNum, data); + } + + /// + /// Get the card + /// + /// Card + public Card card() + { + return this.getProperty(CardPaymentsConstants.card); + } + + /// + /// Set the card + /// + /// void + public void card(Card data) + { + this.setProperty(CardPaymentsConstants.card, data); + } + + /// + /// Get the authentication + /// + /// Authentication + public PaysafeAuthentication authentication() + { + return this.getProperty(CardPaymentsConstants.authentication); + } + + /// + /// Set the authentication + /// + /// void + public void authentication(PaysafeAuthentication data) + { + this.setProperty(CardPaymentsConstants.authentication, data); + } + + /// + /// Get the authCode + /// + /// string + public string authCode() + { + return this.getProperty(CardPaymentsConstants.authCode); + } + + /// + /// Set the authCode + /// + /// void + public void authCode(string data) + { + this.setProperty(CardPaymentsConstants.authCode, data); + } + + /// + /// Get the profile + /// + /// Profile + public Profile profile() + { + return this.getProperty(CardPaymentsConstants.profile); + + } + + /// + /// Set the profile + /// + /// void + public void profile(Profile data) + { + this.setProperty(CardPaymentsConstants.profile, data); + } + + /// + /// Get the billing details + /// + /// BillingDetails + public BillingDetails billingDetails() + { + return this.getProperty(CardPaymentsConstants.billingDetails); + } + + /// + /// Set the billingDetails + /// + /// void + public void billingDetails(BillingDetails data) + { + this.setProperty(CardPaymentsConstants.billingDetails, data); + } + + /// + /// Get the shipping details + /// + /// ShippingDetails + public ShippingDetails shippingDetails() + { + return this.getProperty(CardPaymentsConstants.shippingDetails); + } + + /// + /// Set the shippingDetails + /// + /// void + public void shippingDetails(ShippingDetails data) + { + this.setProperty(CardPaymentsConstants.shippingDetails, data); + } + + /// + /// Get the recurring + /// + /// string + public string recurring() + { + return this.getProperty(CardPaymentsConstants.recurring); + } + + /// + /// Set the recurring + /// + /// void + public void recurring(string data) + { + this.setProperty(CardPaymentsConstants.recurring, data); + } + + /// + /// Get the customerIp + /// + /// string + public string customerIp() + { + return this.getProperty(CardPaymentsConstants.customerIp); + } + + /// + /// Set the customerIp + /// + /// void + public void customerIp(string data) + { + this.setProperty(CardPaymentsConstants.customerIp, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public bool dupCheck() + { + return this.getProperty(CardPaymentsConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(bool data) + { + this.setProperty(CardPaymentsConstants.dupCheck, data); + } + + /// + /// Get the keywords + /// + /// List + public List keywords() + { + return this.getProperty(CardPaymentsConstants.keywords); + } + + /// + /// Set the keywords + /// + /// void + public void keywords(List data) + { + this.setProperty(CardPaymentsConstants.keywords, data); + } + + /// + /// Get the merchantDescriptor + /// + /// MerchantDescriptor + public MerchantDescriptor merchantDescriptor() + { + return this.getProperty(CardPaymentsConstants.merchantDescriptor); + } + + /// + /// Set the merchantDescriptor + /// + /// void + public void merchantDescriptor(MerchantDescriptor data) + { + this.setProperty(CardPaymentsConstants.merchantDescriptor, data); + } + + /// + /// Get the accordD + /// + /// AccordD + public AccordD accordD() + { + return this.getProperty(CardPaymentsConstants.accordD); + } + + /// + /// Set the accordD + /// + /// void + public void accordD(AccordD data) + { + this.setProperty(CardPaymentsConstants.accordD, data); + } + + /// + /// Get the description + /// + /// string + public string description() + { + return this.getProperty(CardPaymentsConstants.description); + } + + /// + /// Set the description + /// + /// void + public void description(string data) + { + this.setProperty(CardPaymentsConstants.description, data); + } + + /// + /// Get the masterPass + /// + /// MasterPass + public MasterPass masterPass() + { + return this.getProperty(CardPaymentsConstants.masterPass); + } + + /// + /// Set the masterPass + /// + /// void + public void masterPass(MasterPass data) + { + this.setProperty(CardPaymentsConstants.masterPass, data); + } + + /// + /// Get the txnTime + /// + /// System.DateTime + public System.DateTime txnTime() + { + return this.getProperty(CardPaymentsConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(System.DateTime data) + { + this.setProperty(CardPaymentsConstants.txnTime, data); + } + + /// + /// Get the currencyCode + /// + /// string + public string currencyCode() + { + return this.getProperty(CardPaymentsConstants.currencyCode); + } + + /// + /// Set the currencyCode + /// + /// void + public void currencyCode(string data) + { + this.setProperty(CardPaymentsConstants.currencyCode, data); + } + + /// + /// Get the avsResponse + /// + /// string + public string avsResponse() + { + return this.getProperty(CardPaymentsConstants.avsResponse); + } + + /// + /// Set the avsResponse + /// + /// void + public void avsResponse(string data) + { + this.setProperty(CardPaymentsConstants.avsResponse, data); + } + + /// + /// Get the cvvVerification + /// + /// string + public string cvvVerification() + { + return this.getProperty(CardPaymentsConstants.cvvVerification); + } + + /// + /// Set the cvvVerification + /// + /// void + public void cvvVerification(string data) + { + this.setProperty(CardPaymentsConstants.cvvVerification, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CardPaymentsConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CardPaymentsConstants.status, data); + } + + /// + /// Get the riskReasonCode + /// + /// List + public List riskReasonCode() + { + return this.getProperty(CardPaymentsConstants.riskReasonCode); + } + + /// + /// Set the riskReasonCode + /// + /// void + public void riskReasonCode(List data) + { + this.setProperty(CardPaymentsConstants.riskReasonCode, data); + } + + /// + /// Get the acquireResponse + /// + /// AcquirerResponse + public AcquirerResponse acquireResponse() + { + return this.getProperty(CardPaymentsConstants.acquirerResponse); + } + + /// + /// Set the acquireResponse + /// + /// void + public void acquireResponse(AcquirerResponse data) + { + this.setProperty(CardPaymentsConstants.acquirerResponse, data); + } + + /// + /// Get the visaAdditionalAuthData + /// + /// VisaAdditionalAuthData + public VisaAdditionalAuthData visaAdditionalAuthData() + { + return this.getProperty(CardPaymentsConstants.visaAdditionalAuthData); + } + + /// + /// Set the visaAdditionalAuthData + /// + /// void + public void visaAdditionalAuthData(VisaAdditionalAuthData data) + { + this.setProperty(CardPaymentsConstants.visaAdditionalAuthData, data); + } + + /// + /// Get the settlements + /// + /// List + public List settlements() + { + return this.getProperty(CardPaymentsConstants.settlements); + } + + /// + /// Set the settlements + /// + /// void + public void settlements(List data) + { + this.setProperty(CardPaymentsConstants.settlements, data); + } + + /// + /// Get the error + /// + /// Error + public OptError error() + { + return this.getProperty(CardPaymentsConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CardPaymentsConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CardPaymentsConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CardPaymentsConstants.links, data); + } + + /// + /// Get a new AuthorizationBuilder + /// + /// AuthorizationBuilder + public static AuthorizationBuilder Builder() + { + return new AuthorizationBuilder(); + } + + /// + /// AuthorizationBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Authorization object + /// + public class AuthorizationBuilder : BaseJSONBuilder + { + /// + /// Set the id + /// + /// string + /// AuthorizationBuilder + public AuthorizationBuilder id(string data) + { + this.properties[CardPaymentsConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// AuthorizationBuilder + public AuthorizationBuilder merchantRefNum(string data) + { + this.properties[CardPaymentsConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount parameter + /// + /// int + /// AuthorizationBuilder + public AuthorizationBuilder amount(int data) + { + this.properties[CardPaymentsConstants.amount] = data; + return this; + } + + /// + /// Build a card within this authorization. + /// + /// Card.CardBuilder + public Card.CardBuilder card() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.card)) + { + this.properties[CardPaymentsConstants.card] = new Card.CardBuilder(this); + } + return this.properties[CardPaymentsConstants.card] as Card.CardBuilder; + } + + /// + /// Set the settleWithAuth property + /// + /// bool + /// AuthorizationBuilder + public AuthorizationBuilder settleWithAuth(bool data) + { + this.properties[CardPaymentsConstants.settleWithAuth] = data; + return this; + } + + /// + /// Set the customerIp parameter + /// + /// string + /// AuthorizationBuilder + public AuthorizationBuilder customerIp(string data) + { + this.properties[CardPaymentsConstants.customerIp] = data; + return this; + } + + /// + /// Set the dupCheck parameter + /// + /// string + /// AuthorizationBuilder + public AuthorizationBuilder dupCheck(bool data) + { + this.properties[CardPaymentsConstants.dupCheck] = data; + return this; + } + + /// + /// Set the description + /// + /// string + /// AuthorizationBuilder + public AuthorizationBuilder description(string data) + { + this.properties[CardPaymentsConstants.description] = data; + return this; + } + + /// + /// Build a authentication within this authorization. + /// + /// PaysafeAuthentication.AuthenticationBuilder + public PaysafeAuthentication.AuthenticationBuilder authentication() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.authentication)) + { + this.properties[CardPaymentsConstants.authentication] = new PaysafeAuthentication.AuthenticationBuilder(this); + } + return this.properties[CardPaymentsConstants.authentication] as PaysafeAuthentication.AuthenticationBuilder; + } + + /// + /// Build a billing details object within this authorization. + /// + /// BillingDetails.BillingDetailsBuilder + public BillingDetails.BillingDetailsBuilder billingDetails() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.billingDetails)) + { + this.properties[CardPaymentsConstants.billingDetails] = new BillingDetails.BillingDetailsBuilder(this); + } + return this.properties[CardPaymentsConstants.billingDetails] as BillingDetails.BillingDetailsBuilder; + } + + /// + /// Build a shipping details object within this authorization. + /// + /// ShippingDetails.ShippingDetailsBuilder + public ShippingDetails.ShippingDetailsBuilder shippingDetails() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.shippingDetails)) + { + this.properties[CardPaymentsConstants.shippingDetails] = new ShippingDetails.ShippingDetailsBuilder(this); + } + return this.properties[CardPaymentsConstants.shippingDetails] as ShippingDetails.ShippingDetailsBuilder; + } + + /// + /// Set the recurring parameter + /// + /// string + /// AuthorizationBuilder + public AuthorizationBuilder recurring(string data) + { + this.properties[CardPaymentsConstants.recurring] = data; + return this; + + } + + /// + /// Build a merchant descriptor object within this authorization. + /// + /// MerchantDescriptor.MerchantDescriptorBuilder + public MerchantDescriptor.MerchantDescriptorBuilder merchantDescriptor() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.merchantDescriptor)) + { + this.properties[CardPaymentsConstants.merchantDescriptor] = new MerchantDescriptor.MerchantDescriptorBuilder(this); + } + return this.properties[CardPaymentsConstants.merchantDescriptor] as MerchantDescriptor.MerchantDescriptorBuilder; + } + + /// + /// Build an accordD object within this authorization. + /// + /// AccordD.AccordDBuilder + public AccordD.AccordDBuilder accordD() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.accordD)) + { + this.properties[CardPaymentsConstants.accordD] = new AccordD.AccordDBuilder(this); + } + return this.properties[CardPaymentsConstants.accordD] as AccordD.AccordDBuilder; + } + } + } +} diff --git a/Paysafe/CardPayments/AuthorizationReversal.cs b/Paysafe/CardPayments/AuthorizationReversal.cs new file mode 100644 index 0000000..3510a0c --- /dev/null +++ b/Paysafe/CardPayments/AuthorizationReversal.cs @@ -0,0 +1,362 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class AuthorizationReversal : JSONObject + { + /// + /// Initialize the Profile object with some set of properties + /// + /// Dictionary + public AuthorizationReversal(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize an authorization reversal object with an id + /// + /// + public AuthorizationReversal(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// Gets the array key to access the array of authorization reversals + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return "voidAuths"; + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.id, STRING_TYPE}, + {CardPaymentsConstants.merchantRefNum, STRING_TYPE}, + {CardPaymentsConstants.amount, INT_TYPE}, + {CardPaymentsConstants.childAccountNum, STRING_TYPE}, + {CardPaymentsConstants.dupCheck, BOOL_TYPE}, + {CardPaymentsConstants.txnTime, typeof(System.DateTime)}, + {CardPaymentsConstants.status, CardPaymentsConstants.enumStatus}, + {CardPaymentsConstants.riskReasonCode, typeof(List)}, + {CardPaymentsConstants.acquirerResponse, typeof(AcquirerResponse)}, + {CardPaymentsConstants.error, typeof(OptError)}, + {CardPaymentsConstants.links, typeof(List)}, + {CardPaymentsConstants.authorizationId, STRING_TYPE} + }; + + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CardPaymentsConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CardPaymentsConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CardPaymentsConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CardPaymentsConstants.merchantRefNum, data); + } + /// + /// Get the amount + /// + /// int + public int amount() + { + return this.getProperty(CardPaymentsConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(CardPaymentsConstants.amount, data); + } + + /// + /// Get the childAccountNum + /// + /// string + public string childAccountNum() + { + return this.getProperty(CardPaymentsConstants.childAccountNum); + } + + /// + /// Set the childAccountNum + /// + /// void + public void childAccountNum(string data) + { + this.setProperty(CardPaymentsConstants.childAccountNum, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public int dupCheck() + { + return this.getProperty(CardPaymentsConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(bool data) + { + this.setProperty(CardPaymentsConstants.dupCheck, data); + } + + /// + /// Get the txnTime + /// + /// System.DateTime + public System.DateTime txnTime() + { + return this.getProperty(CardPaymentsConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(System.DateTime data) + { + this.setProperty(CardPaymentsConstants.txnTime, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CardPaymentsConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CardPaymentsConstants.status, data); + } + + /// + /// Get the riskReasonCode + /// + /// List + public List riskReasonCode() + { + return this.getProperty(CardPaymentsConstants.riskReasonCode); + } + + /// + /// Set the riskReasonCode + /// + /// void + public void riskReasonCode(List data) + { + this.setProperty(CardPaymentsConstants.riskReasonCode, data); + } + + /// + /// Get the acquireResponse + /// + /// AcquirerResponse + public AcquirerResponse acquireResponse() + { + return this.getProperty(CardPaymentsConstants.acquirerResponse); + } + + /// + /// Set the acquireResponse + /// + /// void + public void acquireResponse(AcquirerResponse data) + { + this.setProperty(CardPaymentsConstants.acquirerResponse, data); + } + + /// + /// Get the error + /// + /// Error + public OptError error() + { + return this.getProperty(CardPaymentsConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CardPaymentsConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CardPaymentsConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CardPaymentsConstants.links, data); + } + + /// + /// Get the authorizationId + /// + /// string + public string authorizationId() + { + return this.getProperty(CardPaymentsConstants.authorizationId); + } + + /// + /// Set the authorizationId + /// + /// void + public void authorizationId(string data) + { + this.setProperty(CardPaymentsConstants.authorizationId, data); + } + + /// + /// Get a new AuthorizationBuilder + /// + /// AuthorizationReversalBuilder + public static AuthorizationReversalBuilder Builder() + { + return new AuthorizationReversalBuilder(); + } + + /// + /// AuthorizationReversalBuilder will allow an AuthorizationReversal to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Authorization object + /// + public class AuthorizationReversalBuilder : BaseJSONBuilder + { + /// + /// Set the id + /// + /// string + /// AuthorizationReversalBuilder + public AuthorizationReversalBuilder id(string data) + { + this.properties[CardPaymentsConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum + /// + /// string + /// AuthorizationReversalBuilder + public AuthorizationReversalBuilder merchantRefNum(string data) + { + this.properties[CardPaymentsConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount + /// + /// int + /// AuthorizationReversalBuilder + public AuthorizationReversalBuilder amount(int data) + { + this.properties[CardPaymentsConstants.amount] = data; + return this; + } + + /// + /// Set the dupCheck + /// + /// bool + /// AuthorizationReversalBuilder + public AuthorizationReversalBuilder dupCheck(bool data) + { + this.properties[CardPaymentsConstants.dupCheck] = data; + return this; + } + + /// + /// Set the authorizationId + /// + /// string + /// AuthorizationReversalBuilder + public AuthorizationReversalBuilder authorizationId(string data) + { + this.properties[CardPaymentsConstants.authorizationId] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/BillingDetails.cs b/Paysafe/CardPayments/BillingDetails.cs new file mode 100644 index 0000000..193bb0e --- /dev/null +++ b/Paysafe/CardPayments/BillingDetails.cs @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class BillingDetails : AddressDetails + { + + private static new Dictionary fieldTypes = new Dictionary(addressFieldTypes); + + public BillingDetails(Dictionary properties) + : base(fieldTypes, properties) + { + } + + + /// + /// BillingDetailsBuilder will allow a BillingDetails to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class BillingDetailsBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the BillingDetails builder within the context of a parent builder + /// + /// TBLDR + public BillingDetailsBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the street + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder street(string data) + { + this.properties[CardPaymentsConstants.street] = data; + return this; + } + + /// + /// Set the street2 + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder street2(string data) + { + this.properties[CardPaymentsConstants.street2] = data; + return this; + } + + /// + /// Set the city + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder city(string data) + { + this.properties[CardPaymentsConstants.city] = data; + return this; + } + + /// + /// Set the state + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder state(string data) + { + this.properties[CardPaymentsConstants.state] = data; + return this; + } + + /// + /// Set the country + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder country(string data) + { + this.properties[CardPaymentsConstants.country] = data; + return this; + } + + /// + /// Set the zip + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder zip(string data) + { + this.properties[CardPaymentsConstants.zip] = data; + return this; + } + + /// + /// Set the phone + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder phone(string data) + { + this.properties[CardPaymentsConstants.phone] = data; + return this; + } + } + } +} \ No newline at end of file diff --git a/Paysafe/CardPayments/Card.cs b/Paysafe/CardPayments/Card.cs new file mode 100644 index 0000000..871ee0a --- /dev/null +++ b/Paysafe/CardPayments/Card.cs @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class Card : JSONObject + { + + /// + /// Initialize the Card object with some set of properties + /// + /// Dictionary + public Card(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// This object is used to validate any properties set within the object + /// + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.paymentToken, STRING_TYPE}, + {CardPaymentsConstants.cardNum, STRING_TYPE}, + {CardPaymentsConstants.type, STRING_TYPE}, + {CardPaymentsConstants.lastDigits, STRING_TYPE}, + {CardPaymentsConstants.cardExpiry, typeof(CardExpiry)}, + {CardPaymentsConstants.cvv, STRING_TYPE}, + {CardPaymentsConstants.track1, STRING_TYPE}, + {CardPaymentsConstants.track2, STRING_TYPE}, + }; + + /// + /// Get the payment token + /// + /// string + public string paymentToken() + { + return this.getProperty(CardPaymentsConstants.paymentToken); + } + + /// + /// Set the payment token + /// + /// string + public void paymentToken(string data) + { + this.setProperty(CardPaymentsConstants.paymentToken, data); + } + + /// + /// Get the card number + /// + /// string + public string cardNum() + { + return this.getProperty(CardPaymentsConstants.cardNum); + } + + /// + /// Set the card number + /// + /// string + public void cardNum(string data) + { + this.setProperty(CardPaymentsConstants.cardNum, data); + } + + /// + /// Get the card's type + /// + /// string + public string type() + { + return this.getProperty(CardPaymentsConstants.type); + } + + /// + /// Set the card's type + /// + /// string + public void type(string data) + { + this.setProperty(CardPaymentsConstants.type, data); + } + + /// + /// Get the card's last digits + /// + /// string + public string lastDigits() + { + return this.getProperty(CardPaymentsConstants.lastDigits); + } + + /// + /// Set the card's last digits + /// + /// string + public void lastDigits(string data) + { + this.setProperty(CardPaymentsConstants.lastDigits, data); + } + + /// + /// Get the card expiry + /// + /// CardExpiry + public CardExpiry cardExpiry() + { + return this.getProperty(CardPaymentsConstants.cardExpiry); + } + + /// + /// Set the card expiry + /// + /// CardExpiry + public void cardExpiry(CardExpiry data) + { + this.setProperty(CardPaymentsConstants.cardExpiry, data); + } + + /// + /// Get the card cvv + /// + /// string + public string cvv() + { + return this.getProperty(CardPaymentsConstants.cvv); + } + + /// + /// Set the card cvv + /// + /// string + public void cvv(string data) + { + this.setProperty(CardPaymentsConstants.cvv, data); + } + + /// + /// Get the track1 data + /// + /// string + public string track1() + { + return this.getProperty(CardPaymentsConstants.track1); + } + + /// + /// Set the track1 data + /// + /// string + public void track1(string data) + { + this.setProperty(CardPaymentsConstants.track1, data); + } + + /// + /// Get the track2 data + /// + /// string + public string track2() + { + return this.getProperty(CardPaymentsConstants.track1); + } + + /// + /// Set the track2 data + /// + /// string + public void track2(string data) + { + this.setProperty(CardPaymentsConstants.track2, data); + } + + /// + /// CardBuilder will allow an card to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back tot he parent builder + /// + public class CardBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Card builder within the context of a parent builder + /// + /// TBLDR + public CardBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the payment token + /// + /// string + /// CardBuilder + public CardBuilder paymentToken(string data) + { + this.properties[CardPaymentsConstants.paymentToken] = data; + return this; + } + + /// + /// Set the card number + /// + /// string + /// CardBuilder + public CardBuilder cardNum(string data) + { + this.properties[CardPaymentsConstants.cardNum] = data; + return this; + } + + /// + /// Set the card's type + /// + /// string + /// CardBuilder + public CardBuilder type(string data) + { + this.properties[CardPaymentsConstants.type] = data; + return this; + } + + /// + /// Set the card's last digits + /// + /// string + /// CardBuilder + public CardBuilder lastDigits(string data) + { + this.properties[CardPaymentsConstants.lastDigits] = data; + return this; + } + + /// + /// Build a card expiry within this card. + /// + /// CardExpiry.CardExpiryBuilder> + public CardExpiry.CardExpiryBuilder> cardExpiry() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.cardExpiry)) + { + this.properties[CardPaymentsConstants.cardExpiry] = new CardExpiry.CardExpiryBuilder>(this); + } + return this.properties[CardPaymentsConstants.cardExpiry] as CardExpiry.CardExpiryBuilder>; + } + + /// + /// Set the card cvv + /// + /// string + /// CardBuilder + public CardBuilder cvv(string data) + { + this.properties[CardPaymentsConstants.cvv] = data; + return this; + } + + /// + /// Set the track1 data + /// + /// string + /// CardBuilder + public CardBuilder track1(string data) + { + this.properties[CardPaymentsConstants.track1] = data; + return this; + } + + /// + /// Set the track2 data + /// + /// string + /// CardBuilder + public CardBuilder track2(string data) + { + this.properties[CardPaymentsConstants.track2] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/CardPaymentService.cs b/Paysafe/CardPayments/CardPaymentService.cs new file mode 100644 index 0000000..53364f9 --- /dev/null +++ b/Paysafe/CardPayments/CardPaymentService.cs @@ -0,0 +1,631 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; +using PaysafeApiClient = Paysafe.PaysafeApiClient; + +namespace Paysafe.CardPayments +{ + public class CardPaymentService + { + + /// + /// The api client, performs all http requests + /// + private PaysafeApiClient client; + + /// + /// The card payments api base uri + /// + private string uri = "cardpayments/v1"; + + /// + /// Initialize the card payments service with an client object + /// + /// PaysafeApiClient + public CardPaymentService(PaysafeApiClient client) + { + this.client = client; + } + + /// + /// Check if the service is available + /// + /// true if successful + public Boolean monitor() { + Request request = new Request(uri:"cardpayments/monitor"); + dynamic response = this.client.processRequest(request); + + return ("READY".Equals((string)(response[CardPaymentsConstants.status]))); + } + + /// + /// Authorize + /// + /// Authorization + /// Authorization + public Authorization authorize(Authorization auth) + { + auth.setRequiredFields(new List { + CardPaymentsConstants.merchantRefNum, + CardPaymentsConstants.amount, + CardPaymentsConstants.card + }); + auth.setOptionalFields(new List { + CardPaymentsConstants.settleWithAuth, + CardPaymentsConstants.customerIp, + CardPaymentsConstants.dupCheck, + CardPaymentsConstants.description, + CardPaymentsConstants.authentication, + CardPaymentsConstants.billingDetails, + CardPaymentsConstants.shippingDetails, + CardPaymentsConstants.recurring, + CardPaymentsConstants.merchantDescriptor, + CardPaymentsConstants.accordD + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/auths"), + body: auth + ); + dynamic response = this.client.processRequest(request); + + return new Authorization(response); + } + + /// + /// Cancel the Authorization + /// + /// Authorization + /// Authorization + public Authorization cancelHeldAuth(Authorization auth) + { + auth.setRequiredFields(new List {CardPaymentsConstants.id}); + auth.checkRequiredFields(); + + Authorization tmpAuth = new Authorization(); + tmpAuth.status("CANCELLED"); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/auths/" + auth.id()), + body: tmpAuth + ); + + dynamic response = this.client.processRequest(request); + + return new Authorization(response); + } + + /// + /// Approve + /// + /// Authorization + /// Authorization + public Authorization approveHeldAuth(Authorization auth) + { + auth.setRequiredFields(new List {CardPaymentsConstants.id}); + + auth.checkRequiredFields(); + + Authorization tmpAuth = new Authorization(); + tmpAuth.status("COMPLETED"); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/auths/" + auth.id()), + body: tmpAuth + ); + + dynamic response = this.client.processRequest(request); + + return new Authorization(response); + } + + /// + /// Reverse + /// + /// AuthorizationReversal + /// AuthorizationReversal + public AuthorizationReversal reverseAuth(AuthorizationReversal authReversal) + { + authReversal.setRequiredFields(new List {CardPaymentsConstants.authorizationId}); + authReversal.checkRequiredFields(); + authReversal.setRequiredFields(new List {CardPaymentsConstants.merchantRefNum}); + authReversal.setOptionalFields(new List { + CardPaymentsConstants.amount, + CardPaymentsConstants.dupCheck + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/auths/" + authReversal.authorizationId() + "/voidauths"), + body: authReversal + ); + + dynamic response = this.client.processRequest(request); + + return new AuthorizationReversal(response); + } + + /// + /// Settlement + /// + /// Settlement + /// Settlement + public Settlement settlement(Settlement settle) + { + settle.setRequiredFields(new List { CardPaymentsConstants.authorizationId }); + settle.checkRequiredFields(); + settle.setRequiredFields(new List { CardPaymentsConstants.merchantRefNum }); + settle.setOptionalFields(new List { + CardPaymentsConstants.amount, + CardPaymentsConstants.dupCheck + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/auths/" + settle.authorizationId() + "/settlements"), + body: settle + ); + + dynamic response = this.client.processRequest(request); + + return new Settlement(response); + } + + /// + /// Cancel Settlement + /// + /// Settlement + /// Settlement + public Settlement cancelSettlement(Settlement settle) + { + settle.setRequiredFields(new List { CardPaymentsConstants.id }); + settle.checkRequiredFields(); + + Settlement tmpSettlement = new Settlement(); + tmpSettlement.status("CANCELLED"); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/settlements/" + settle.id()), + body: tmpSettlement + ); + + dynamic response = this.client.processRequest(request); + + return new Settlement(response); + } + + /// + /// Refund + /// + /// Refund + /// Refund + public Refund refund(Refund newRefund) + { + newRefund.setRequiredFields(new List { CardPaymentsConstants.settlementId }); + newRefund.checkRequiredFields(); + newRefund.setRequiredFields(new List { CardPaymentsConstants.merchantRefNum }); + newRefund.setOptionalFields(new List { + CardPaymentsConstants.amount, + CardPaymentsConstants.dupCheck + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/settlements/" + newRefund.settlementId() + "/refunds"), + body: newRefund + ); + + dynamic response = this.client.processRequest(request); + + return new Refund(response); + } + + /// + /// Cancel Refund + /// + /// Refund + /// Refund + public Refund cancelRefund(Refund refund) + { + refund.setRequiredFields(new List { CardPaymentsConstants.id }); + refund.checkRequiredFields(); + + Refund tmpRefund = new Refund(); + tmpRefund.status("CANCELLED"); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/refunds/" + refund.id()), + body: tmpRefund + ); + + dynamic response = this.client.processRequest(request); + + return new Refund(response); + } + + /// + /// Verify + /// + /// Verification + /// Verificationd + public Verification verify(Verification verification) + { + verification.setRequiredFields(new List { + CardPaymentsConstants.merchantRefNum, + CardPaymentsConstants.card + }); + + verification.setOptionalFields(new List { + CardPaymentsConstants.profile, + CardPaymentsConstants.customerIp, + CardPaymentsConstants.dupCheck, + CardPaymentsConstants.description, + CardPaymentsConstants.billingDetails + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/verifications"), + body: verification + ); + + dynamic response = this.client.processRequest(request); + + return new Verification(response); + } + + /// + /// Get the authorization + /// + /// Authorization + /// Authorization + public Authorization get(Authorization auth) + { + auth.setRequiredFields(new List { CardPaymentsConstants.id }); + auth.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/auths/" + auth.id()) + ); + + dynamic response = this.client.processRequest(request); + + return new Authorization(response); + } + + /// + /// Get the AuthorizationReversal + /// + /// AuthorizationReversal + /// AuthorizationReversal + public AuthorizationReversal get(AuthorizationReversal authReversal) + { + authReversal.setRequiredFields(new List { CardPaymentsConstants.id }); + authReversal.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/voidauths/" + authReversal.id()) + ); + + dynamic response = this.client.processRequest(request); + + return new AuthorizationReversal(response); + } + + /// + /// Get the Settlement + /// + /// Settlement + /// Settlement + public Settlement get(Settlement settlement) + { + settlement.setRequiredFields(new List { CardPaymentsConstants.id }); + settlement.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/settlements/" + settlement.id()) + ); + + dynamic response = this.client.processRequest(request); + + return new Settlement(response); + } + + /// + /// Get the Refund + /// + /// Refund + /// Refund + public Refund get(Refund refund) + { + refund.setRequiredFields(new List { CardPaymentsConstants.id }); + refund.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/refunds/" + refund.id()) + ); + + dynamic response = this.client.processRequest(request); + + return new Refund(response); + } + + /// + /// Get the verification + /// + /// Verification + /// Verification + public Verification get(Verification verify) + { + verify.setRequiredFields(new List { CardPaymentsConstants.id }); + verify.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/verifications/" + verify.id()) + ); + + dynamic response = this.client.processRequest(request); + + return new Verification(response); + } + + /// + /// Get matching authorizations + /// + /// + /// + /// + public Pagerator getAuths(Authorization auth = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (auth != null && !String.IsNullOrWhiteSpace(auth.merchantRefNum())) { + queryStr.Add("merchantRefNum", auth.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/auths"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(Authorization), response); + } + + /// + /// Get matching authorization reversals + /// + /// + /// + /// + public Pagerator getAuthReversals(AuthorizationReversal authReversal = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (authReversal != null && !String.IsNullOrWhiteSpace(authReversal.merchantRefNum())) + { + queryStr.Add("merchantRefNum", authReversal.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/voidauths"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(AuthorizationReversal), response); + } + + /// + /// Get matching settlements + /// + /// + /// + /// + public Pagerator getSettlements(Settlement settlement = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (settlement != null && !String.IsNullOrWhiteSpace(settlement.merchantRefNum())) + { + queryStr.Add("merchantRefNum", settlement.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/settlements"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(Settlement), response); + } + + /// + /// Get matching refunds + /// + /// + /// + /// + public Pagerator getRefunds(Refund refund = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (refund != null && !String.IsNullOrWhiteSpace(refund.merchantRefNum())) + { + queryStr.Add("merchantRefNum", refund.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/refunds"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(Refund), response); + } + + /// + /// Get matching verifications + /// + /// + /// + /// + public Pagerator getVerifications(Verification verify = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (verify != null && !String.IsNullOrWhiteSpace(verify.merchantRefNum())) + { + queryStr.Add("merchantRefNum", verify.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/verifications"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(Verification), response); + } + + private string prepareURI(string path) + { + if (String.IsNullOrWhiteSpace(this.client.account())) + { + throw new PaysafeException("Missing or invalid account"); + } + return this.uri + "/accounts/" + this.client.account() + path; + } + } +} diff --git a/Paysafe/CardPayments/CardPaymentsConstants.cs b/Paysafe/CardPayments/CardPaymentsConstants.cs new file mode 100644 index 0000000..2ec7a5d --- /dev/null +++ b/Paysafe/CardPayments/CardPaymentsConstants.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.CardPayments +{ + /** + * This class can be used to override any of the string literals from the global strings class + */ + class CardPaymentsConstants : Paysafe.Common.GlobalConstants + { + public static readonly List enumAVSResponse = new List() { + validationMatch, + validationMatchAddressOnly, + validationMatchZipOnly, + validationNoMatch, + validationNotProcessed, + validationUnknown + }; + public static readonly List enumCVVVerification = new List() { + validationMatch, + validationNoMatch, + validationNotProcessed, + validationUnknown + + }; + public static readonly List enumFinancingType = new List() { + financingDeferredPayment, + financingEqualPayment + }; + public static readonly List enumRecurring = new List() { + recurringInitial, + recurringRecurring + }; + public static readonly List enumStatus = new List() { + statusReceived, + statusPending, + statusProcessing, + statusCompleted, + statusFailed, + statusCancelled + }; + } +} diff --git a/Paysafe/CardPayments/Filter.cs b/Paysafe/CardPayments/Filter.cs new file mode 100644 index 0000000..b1c914a --- /dev/null +++ b/Paysafe/CardPayments/Filter.cs @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.CardPayments +{ + public class Filter + { + + /// + /// number of results per page + /// + + public int? limit = null; + + /// + /// The offset to start the request + /// + public int? offset = null; + + /// + /// The earliest date to match + /// + public String startDate = null; + + /// + /// The latest date to match + /// + public String endDate = null; + } +} diff --git a/Paysafe/CardPayments/MasterPass.cs b/Paysafe/CardPayments/MasterPass.cs new file mode 100644 index 0000000..a702487 --- /dev/null +++ b/Paysafe/CardPayments/MasterPass.cs @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + + public class MasterPass : JSONObject + { + /// + /// Initialize the MasterPass object with some set of properties + /// + /// Dictionary + public MasterPass(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.payPassWalletIndicator, STRING_TYPE}, + {CardPaymentsConstants.authenticationMethod, STRING_TYPE}, + {CardPaymentsConstants.cardEnrollementMethod, STRING_TYPE}, + {CardPaymentsConstants.masterCardAssignedId, STRING_TYPE} + }; + + /// + /// Get the payPassWalletIndicator + /// + /// string + public string payPassWalletIndicator() + { + return this.getProperty(CardPaymentsConstants.payPassWalletIndicator); + } + + /// + /// Set the payPassWalletIndicator + /// + /// void + public void payPassWalletIndicator(string data) + { + this.setProperty(CardPaymentsConstants.payPassWalletIndicator, data); + } + + /// + /// Get the authenticationMethod + /// + /// string + public string authenticationMethod() + { + return this.getProperty(CardPaymentsConstants.authenticationMethod); + } + + /// + /// Set the authenticationMethod + /// + /// void + public void authenticationMethod(string data) + { + this.setProperty(CardPaymentsConstants.authenticationMethod, data); + } + + /// + /// Get the cardEnrollementMethod + /// + /// string + public string cardEnrollementMethod() + { + return this.getProperty(CardPaymentsConstants.cardEnrollementMethod); + } + + /// + /// Set the cardEnrollementMethod + /// + /// void + public void cardEnrollementMethod(string data) + { + this.setProperty(CardPaymentsConstants.cardEnrollementMethod, data); + } + + /// + /// Get the masterCardAssignedId + /// + /// string + public string masterCardAssignedIdr() + { + return this.getProperty(CardPaymentsConstants.masterCardAssignedId); + } + + /// + /// Set the masterCardAssignedId + /// + /// void + public void masterCardAssignedId(string data) + { + this.setProperty(CardPaymentsConstants.masterCardAssignedId, data); + } + + } +} diff --git a/Paysafe/CardPayments/MerchantDescriptor.cs b/Paysafe/CardPayments/MerchantDescriptor.cs new file mode 100644 index 0000000..e88bc31 --- /dev/null +++ b/Paysafe/CardPayments/MerchantDescriptor.cs @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + + public class MerchantDescriptor : JSONObject + { + /// + /// Initialize the MerchantDescriptor object with some set of properties + /// + /// Dictionary + public MerchantDescriptor(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.dynamicDescriptor, STRING_TYPE}, + {CardPaymentsConstants.phone, STRING_TYPE} + }; + + /// + /// Get the dynamicDescriptor + /// + /// string + public string dynamicDescriptor() + { + return this.getProperty(CardPaymentsConstants.dynamicDescriptor); + } + + /// + /// Set the dynamicDescriptor + /// + /// void + public void dynamicDescriptor(string data) + { + this.setProperty(CardPaymentsConstants.dynamicDescriptor, data); + } + + /// + /// Get the street + /// + /// string + public string street() + { + return this.getProperty(CardPaymentsConstants.phone); + } + + /// + /// Set the zip + /// + /// void + public void zip(string data) + { + this.setProperty(CardPaymentsConstants.phone, data); + } + + /// + /// MerchantDescriptorBuilder will allow a MerchantDescriptor to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class MerchantDescriptorBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the MerchantDescriptor builder within the context of a parent builder + /// + /// TBLDR + public MerchantDescriptorBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the dynamicDescriptor + /// + /// string + /// MerchantDescriptorBuilder + public MerchantDescriptorBuilder dynamicDescriptor(string data) + { + this.properties[CardPaymentsConstants.dynamicDescriptor] = data; + return this; + } + + + /// + /// Set the phone + /// + /// string + /// MerchantDescriptorBuilder + public MerchantDescriptorBuilder phone(string data) + { + this.properties[CardPaymentsConstants.phone] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/Pagerator.cs b/Paysafe/CardPayments/Pagerator.cs new file mode 100644 index 0000000..95a348a --- /dev/null +++ b/Paysafe/CardPayments/Pagerator.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class Pagerator : AbstractPagerator + { + public Pagerator(PaysafeApiClient apiClient, Type pagingClassType, Dictionary data) + : base(apiClient, pagingClassType) + { + this.parseResponse(data); + } + + override protected sealed void parseResponse(Dictionary data) + { + if (!data.ContainsKey(this.arrayKey) || !(data[this.arrayKey] is List)) + { + throw new PaysafeException("Missing array key from results"); + } + foreach(dynamic obj in data[this.arrayKey] as List) { + Object[] args = { obj }; + dynamic result = Activator.CreateInstance(this.classType, args); + this.results.Add(result); + } + this.nextPage = null; + + if (data.ContainsKey("links") + && data["links"] is List) + { + foreach (dynamic obj in (List)data["links"]) + { + Link tmpLink = new Link(obj); + if (tmpLink.rel().Equals("next")) + { + this.nextPage = tmpLink.href(); + break; + } + } + } + } + } +} diff --git a/Paysafe/CardPayments/PaysafeAuthentication.cs b/Paysafe/CardPayments/PaysafeAuthentication.cs new file mode 100644 index 0000000..60903a8 --- /dev/null +++ b/Paysafe/CardPayments/PaysafeAuthentication.cs @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + + +namespace Paysafe.CardPayments +{ + public class PaysafeAuthentication : JSONObject + { + + /// + /// Initialize the BillingDetails object with some set of properties + /// + /// Dictionary + public PaysafeAuthentication(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.eci, INT_TYPE}, + {CardPaymentsConstants.cavv, STRING_TYPE}, + {CardPaymentsConstants.xid, STRING_TYPE}, + {CardPaymentsConstants.threeDEnrollment, STRING_TYPE}, + {CardPaymentsConstants.threeDResult, STRING_TYPE}, + {CardPaymentsConstants.signatureStatus, STRING_TYPE} + }; + + /// + /// Get the eci + /// + /// int + public int eci() + { + return this.getProperty(CardPaymentsConstants.eci); + } + + /// + /// Set the eci + /// + /// void + public void eci(int data) + { + this.setProperty(CardPaymentsConstants.eci, data); + } + + /// + /// Get the cavv + /// + /// string + public string cavv() + { + return this.getProperty(CardPaymentsConstants.cavv); + } + + /// + /// Set the cavv + /// + /// void + public void cavv(string data) + { + this.setProperty(CardPaymentsConstants.cavv, data); + } + + /// + /// Get the xid + /// + /// string + public string xid() + { + return this.getProperty(CardPaymentsConstants.xid); + } + + /// + /// Set the xid + /// + /// void + public void xid(string data) + { + this.setProperty(CardPaymentsConstants.xid, data); + } + + /// + /// Get the threeDEnrollment + /// + /// string + public string threeDEnrollment() + { + return this.getProperty(CardPaymentsConstants.threeDEnrollment); + } + + /// + /// Set the threeDEnrollment + /// + /// void + public void threeDEnrollment(string data) + { + this.setProperty(CardPaymentsConstants.threeDEnrollment, data); + } + + /// + /// Get the threeDResult + /// + /// string + public string threeDResult() + { + return this.getProperty(CardPaymentsConstants.threeDResult); + } + + /// + /// Set the threeDResult + /// + /// void + public void threeDResult(string data) + { + this.setProperty(CardPaymentsConstants.threeDResult, data); + } + + /// + /// Get the signatureStatus + /// + /// string + public string signatureStatus() + { + return this.getProperty(CardPaymentsConstants.signatureStatus); + } + + /// + /// Set the signatureStatus + /// + /// void + public void signatureStatus(string data) + { + this.setProperty(CardPaymentsConstants.signatureStatus, data); + } + + + /// + /// AuthenticationBuilder will allow a Authentication to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class AuthenticationBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Authentication builder within the context of a parent builder + /// + /// TBLDR + public AuthenticationBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + + /// + /// Set the eci + /// + /// int + /// AuthenticationBuilder + public AuthenticationBuilder eci(int data) + { + this.properties[CardPaymentsConstants.eci] = data; + return this; + } + + /// + /// Set the cavv + /// + /// string + /// AuthenticationBuilder + public AuthenticationBuilder cavv(string data) + { + this.properties[CardPaymentsConstants.cavv] = data; + return this; + } + + /// + /// Set the xid + /// + /// string + /// AuthenticationBuilder + public AuthenticationBuilder xid(string data) + { + this.properties[CardPaymentsConstants.xid] = data; + return this; + } + + /// + /// Set the threeDEnrollment + /// + /// string + /// AuthenticationBuilder + public AuthenticationBuilder threeDEnrollment(string data) + { + this.properties[CardPaymentsConstants.threeDEnrollment] = data; + return this; + } + + /// + /// Set the threeDResult + /// + /// string + /// AuthenticationBuilder + public AuthenticationBuilder threeDResult(string data) + { + this.properties[CardPaymentsConstants.threeDResult] = data; + return this; + } + + /// + /// Set the signatureStatus + /// + /// string + /// AuthenticationBuilder + public AuthenticationBuilder signatureStatus(string data) + { + this.properties[CardPaymentsConstants.signatureStatus] = data; + return this; + } + + } + } +} diff --git a/Paysafe/CardPayments/Profile.cs b/Paysafe/CardPayments/Profile.cs new file mode 100644 index 0000000..f048a2b --- /dev/null +++ b/Paysafe/CardPayments/Profile.cs @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class Profile : JSONObject + { + /// + /// Initialize the Profile object with some set of properties + /// + /// Dictionary + public Profile(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.firstName, STRING_TYPE}, + {CardPaymentsConstants.lastName, STRING_TYPE}, + {CardPaymentsConstants.email, EMAIL_TYPE} + }; + + + /// + /// Get the firstName + /// + /// string + public string firstName() + { + return this.getProperty(CardPaymentsConstants.firstName); + } + + /// + /// Set the firstName + /// + /// void + public void firstName(string data) + { + this.setProperty(CardPaymentsConstants.firstName, data); + } + + /// + /// Get the lastName + /// + /// string + public string lastName() + { + return this.getProperty(CardPaymentsConstants.lastName); + } + + /// + /// Set the lastName + /// + /// void + public void lastName(string data) + { + this.setProperty(CardPaymentsConstants.lastName, data); + } + + /// + /// Get the email + /// + /// string + public string email() + { + return this.getProperty(CardPaymentsConstants.email); + } + + /// + /// Set the email + /// + /// void + public void email(string data) + { + this.setProperty(CardPaymentsConstants.email, data); + } + + + /// + /// ProfileBuilder will allow a Profile to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class ProfileBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Profile builder within the context of a parent builder + /// + /// TBLDR + public ProfileBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the firstname + /// + /// string + /// ProfileBuilder + public ProfileBuilder firstName(string data) + { + this.properties[CardPaymentsConstants.firstName] = data; + return this; + } + + /// + /// Set the lastname + /// + /// string + /// ProfileBuilder + public ProfileBuilder lastName(string data) + { + this.properties[CardPaymentsConstants.lastName] = data; + return this; + } + + /// + /// Set the email + /// + /// string + /// ProfileBuilder + public ProfileBuilder email(string data) + { + this.properties[CardPaymentsConstants.email] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/Refund.cs b/Paysafe/CardPayments/Refund.cs new file mode 100644 index 0000000..43c5549 --- /dev/null +++ b/Paysafe/CardPayments/Refund.cs @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + + public class Refund : JSONObject + { + /// + /// Initialize the Refund object with some set of properties + /// + /// Dictionary + public Refund(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize a refund object with an id + /// + /// + public Refund(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// Gets the array key to access the array of refunds + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return "refunds"; + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.id, STRING_TYPE}, + {CardPaymentsConstants.merchantRefNum, STRING_TYPE}, + {CardPaymentsConstants.amount, INT_TYPE}, + {CardPaymentsConstants.childAccountNum, STRING_TYPE}, + {CardPaymentsConstants.dupCheck, BOOL_TYPE}, + {CardPaymentsConstants.txnTime, typeof(System.DateTime)}, + {CardPaymentsConstants.status, CardPaymentsConstants.enumStatus}, + {CardPaymentsConstants.riskReasonCode, typeof(List)}, + {CardPaymentsConstants.acquirerResponse, typeof(AcquirerResponse)}, + {CardPaymentsConstants.error, typeof(OptError)}, + {CardPaymentsConstants.links, typeof(List)}, + {CardPaymentsConstants.settlementId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CardPaymentsConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CardPaymentsConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CardPaymentsConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CardPaymentsConstants.merchantRefNum, data); + } + + /// + /// Get the amount + /// + /// int + public int amount() + { + return this.getProperty(CardPaymentsConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(CardPaymentsConstants.amount, data); + } + + /// + /// Get the childAccountNum + /// + /// string + public string childAccountNum() + { + return this.getProperty(CardPaymentsConstants.childAccountNum); + } + + /// + /// Set the childAccountNum + /// + /// void + public void childAccountNum(string data) + { + this.setProperty(CardPaymentsConstants.childAccountNum, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public bool dupCheck() + { + return this.getProperty(CardPaymentsConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(bool data) + { + this.setProperty(CardPaymentsConstants.dupCheck, data); + } + + /// + /// Get the txnTime + /// + /// System.DateTime + public System.DateTime txnTime() + { + return this.getProperty(CardPaymentsConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(System.DateTime data) + { + this.setProperty(CardPaymentsConstants.txnTime, data); + } + + /// + /// Get the status + /// + /// String + public string status() + { + return this.getProperty(CardPaymentsConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CardPaymentsConstants.status, data); + } + + /// + /// Get the riskReasonCode + /// + /// List + public List riskReasonCode() + { + return this.getProperty(CardPaymentsConstants.riskReasonCode); + } + + /// + /// Set the riskReasonCode + /// + /// void + public void riskReasonCode(List data) + { + this.setProperty(CardPaymentsConstants.riskReasonCode, data); + } + + /// + /// Get the acquireResponse + /// + /// AcquirerResponse + public AcquirerResponse acquireResponse() + { + return this.getProperty(CardPaymentsConstants.acquirerResponse); + } + + /// + /// Set the acquireResponse + /// + /// void + public void acquireResponse(AcquirerResponse data) + { + this.setProperty(CardPaymentsConstants.acquirerResponse, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(CardPaymentsConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CardPaymentsConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CardPaymentsConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CardPaymentsConstants.links, data); + } + + /// + /// Get the settlementId + /// + /// string + public string settlementId() + { + return this.getProperty(CardPaymentsConstants.settlementId); + } + + /// + /// Set the settlementId + /// + /// void + public void settlementId(string data) + { + this.setProperty(CardPaymentsConstants.settlementId, data); + } + + /// + /// Get a new RefundBuilder + /// + /// RefundBuilder + public static RefundBuilder Builder() + { + return new RefundBuilder(); + } + + /// + /// RefundBuilder will allow an Refund to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Authorization object + /// + public class RefundBuilder : BaseJSONBuilder + { + /// + /// Set the id + /// + /// string + /// RefundBuilder + public RefundBuilder id(string data) + { + this.properties[CardPaymentsConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum + /// + /// string + /// RefundBuilder + public RefundBuilder merchantRefNum(string data) + { + this.properties[CardPaymentsConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount + /// + /// int + /// RefundBuilder + public RefundBuilder amount(int data) + { + this.properties[CardPaymentsConstants.amount] = data; + return this; + } + + /// + /// Set the dupCheck + /// + /// bool + /// RefundBuilder + public RefundBuilder dupCheck(bool data) + { + this.properties[CardPaymentsConstants.dupCheck] = data; + return this; + } + + /// + /// Set the settlementId + /// + /// bool + /// RefundBuilder + public RefundBuilder settlementId(String data) + { + this.properties[CardPaymentsConstants.settlementId] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/Settlement.cs b/Paysafe/CardPayments/Settlement.cs new file mode 100644 index 0000000..59efa62 --- /dev/null +++ b/Paysafe/CardPayments/Settlement.cs @@ -0,0 +1,382 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class Settlement : JSONObject + { + /// + /// Initialize the Settlement object with some set of properties + /// + /// Dictionary + public Settlement(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize a settlement object with an id + /// + /// + public Settlement(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// Gets the array key to access the array of settlements + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return CardPaymentsConstants.settlements; + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.id, STRING_TYPE}, + {CardPaymentsConstants.merchantRefNum, STRING_TYPE}, + {CardPaymentsConstants.amount, INT_TYPE}, + {CardPaymentsConstants.availableToRefund, INT_TYPE}, + {CardPaymentsConstants.childAccountNum, STRING_TYPE}, + {CardPaymentsConstants.txnTime, typeof(System.DateTime)}, + {CardPaymentsConstants.dupCheck, BOOL_TYPE}, + {CardPaymentsConstants.status, CardPaymentsConstants.enumStatus}, + {CardPaymentsConstants.riskReasonCode, typeof(List)}, + {CardPaymentsConstants.acquirerResponse, typeof(AcquirerResponse)}, + {CardPaymentsConstants.error, typeof(OptError)}, + {CardPaymentsConstants.links, typeof(List)}, + {CardPaymentsConstants.authorizationId, STRING_TYPE} + }; + + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CardPaymentsConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CardPaymentsConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CardPaymentsConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CardPaymentsConstants.merchantRefNum, data); + } + + /// + /// Get the amount + /// + /// int + public int amount() + { + return this.getProperty(CardPaymentsConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(CardPaymentsConstants.amount, data); + } + + /// + /// Get the availableToRefund + /// + /// int + public int availableToRefund() + { + return this.getProperty(CardPaymentsConstants.availableToRefund); + } + + /// + /// Set the availableToRefund + /// + /// void + public void availableToRefund(int data) + { + this.setProperty(CardPaymentsConstants.availableToRefund, data); + } + + /// + /// Get the childAccountNum + /// + /// string + public string childAccountNum() + { + return this.getProperty(CardPaymentsConstants.childAccountNum); + } + + /// + /// Set the childAccountNum + /// + /// void + public void childAccountNum(string data) + { + this.setProperty(CardPaymentsConstants.childAccountNum, data); + } + + /// + /// Get the txnTime + /// + /// System.DateTime + public System.DateTime txnTime() + { + return this.getProperty(CardPaymentsConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(System.DateTime data) + { + this.setProperty(CardPaymentsConstants.txnTime, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public bool dupCheck() + { + return this.getProperty(CardPaymentsConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(bool data) + { + this.setProperty(CardPaymentsConstants.dupCheck, data); + } + + /// + /// Get the status + /// + /// List + public string status() + { + return this.getProperty(CardPaymentsConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CardPaymentsConstants.status, data); + } + + /// + /// Get the riskReasonCode + /// + /// List + public List riskReasonCode() + { + return this.getProperty(CardPaymentsConstants.riskReasonCode); + } + + /// + /// Set the riskReasonCode + /// + /// void + public void riskReasonCode(List data) + { + this.setProperty(CardPaymentsConstants.riskReasonCode, data); + } + + /// + /// Get the acquireResponse + /// + /// AcquirerResponse + public AcquirerResponse acquireResponse() + { + return this.getProperty(CardPaymentsConstants.acquirerResponse); + } + + /// + /// Set the acquireResponse + /// + /// void + public void acquireResponse(AcquirerResponse data) + { + this.setProperty(CardPaymentsConstants.acquirerResponse, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(CardPaymentsConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CardPaymentsConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CardPaymentsConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CardPaymentsConstants.links, data); + } + + /// + /// Get the authorizationId + /// + /// string + public string authorizationId() + { + return this.getProperty(CardPaymentsConstants.authorizationId); + } + + /// + /// Set the authorizationId + /// + /// void + public void authorizationId(string data) + { + this.setProperty(CardPaymentsConstants.authorizationId, data); + } + + /// + /// Get a new SettlementBuilder + /// + /// SettlementBuilder + public static SettlementBuilder Builder() + { + return new SettlementBuilder(); + } + + /// + /// SettlementBuilder will allow an Settlement to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Authorization object + /// + public class SettlementBuilder : BaseJSONBuilder + { + /// + /// Set the id + /// + /// string + /// SettlementBuilder + public SettlementBuilder id(string data) + { + this.properties[CardPaymentsConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum + /// + /// string + /// SettlementBuilder + public SettlementBuilder merchantRefNum(string data) + { + this.properties[CardPaymentsConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount + /// + /// int + /// SettlementBuilder + public SettlementBuilder amount(int data) + { + this.properties[CardPaymentsConstants.amount] = data; + return this; + } + + /// + /// Set the dupCheck + /// + /// bool + /// SettlementBuilder + public SettlementBuilder dupCheck(bool data) + { + this.properties[CardPaymentsConstants.dupCheck] = data; + return this; + } + + /// + /// Set the authorizationId + /// + /// string + /// SettlementBuilder + public SettlementBuilder authorizationId(string data) + { + this.properties[CardPaymentsConstants.authorizationId] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/ShippingDetails.cs b/Paysafe/CardPayments/ShippingDetails.cs new file mode 100644 index 0000000..3b2576b --- /dev/null +++ b/Paysafe/CardPayments/ShippingDetails.cs @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class ShippingDetails : AddressDetails + { + /// + /// Initialize the ShippingDetails object with some set of properties + /// + /// Dictionary + public ShippingDetails(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary(addressFieldTypes) + { + {CardPaymentsConstants.recipientName, STRING_TYPE}, + {CardPaymentsConstants.carrier, CardPaymentsConstants.enumCarrier}, + {CardPaymentsConstants.shipMethod, CardPaymentsConstants.enumShipMethod} + }; + + /// + /// Get the recipientName + /// + /// string + public string recipientName() + { + return this.getProperty(CardPaymentsConstants.recipientName); + } + + /// + /// Set the recipientName + /// + /// void + public void recipientName(string data) + { + this.setProperty(CardPaymentsConstants.recipientName, data); + } + + /// + /// Get the carrier + /// + /// List + public List carrier() + { + return this.getProperty(CardPaymentsConstants.carrier); + } + + /// + /// Set the carrier + /// + /// void + public void carrier(string data) + { + this.setProperty(CardPaymentsConstants.carrier, data); + } + + /// + /// Get the shipMethod + /// + /// string + public string shipMethod() + { + return this.getProperty(CardPaymentsConstants.shipMethod); + } + + /// + /// Set the shipMethod + /// + /// void + public void shipMethod(string data) + { + this.setProperty(CardPaymentsConstants.shipMethod, data); + } + + /// + /// ShippingDetailsBuilder will allow a ShippingDetails to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class ShippingDetailsBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the ShippingDetails builder within the context of a parent builder + /// + /// TBLDR + public ShippingDetailsBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the recipientName + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder recipientName(string data) + { + this.properties[CardPaymentsConstants.recipientName] = data; + return this; + } + + /// + /// Set the street + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder street(string data) + { + this.properties[CardPaymentsConstants.street] = data; + return this; + } + + /// + /// Set the street2 + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder street2(string data) + { + this.properties[CardPaymentsConstants.street2] = data; + return this; + } + + /// + /// Set the city + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder city(string data) + { + this.properties[CardPaymentsConstants.city] = data; + return this; + } + + /// + /// Set the state + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder state(string data) + { + this.properties[CardPaymentsConstants.state] = data; + return this; + } + + /// + /// Set the country + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder country(string data) + { + this.properties[CardPaymentsConstants.country] = data; + return this; + } + + /// + /// Set the zip + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder zip(string data) + { + this.properties[CardPaymentsConstants.zip] = data; + return this; + } + + /// + /// Set the phone + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder phone(string data) + { + this.properties[CardPaymentsConstants.phone] = data; + return this; + } + + /// + /// Set the carrier + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder carrier(string data) + { + this.properties[CardPaymentsConstants.carrier] = data; + return this; + } + + /// + /// Set the shipMethod + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder shipMethod(string data) + { + this.properties[CardPaymentsConstants.shipMethod] = data; + return this; + } + } + } +} diff --git a/Paysafe/CardPayments/Verification.cs b/Paysafe/CardPayments/Verification.cs new file mode 100644 index 0000000..4c630e8 --- /dev/null +++ b/Paysafe/CardPayments/Verification.cs @@ -0,0 +1,571 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class Verification : JSONObject + { + /// + /// Initialize the Verification object with some set of properties + /// + /// Dictionary + public Verification(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize a verification object with an id + /// + /// + public Verification(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// Gets the array key to access the array of verifications + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return "verifications"; + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.id, STRING_TYPE}, + {CardPaymentsConstants.merchantRefNum, STRING_TYPE}, + {CardPaymentsConstants.childAccountNum, STRING_TYPE}, + {CardPaymentsConstants.card, typeof(Card)}, + {CardPaymentsConstants.authCode, STRING_TYPE}, + {CardPaymentsConstants.profile, typeof(Profile)}, + {CardPaymentsConstants.billingDetails, typeof(BillingDetails)}, + {CardPaymentsConstants.customerIp, STRING_TYPE}, + {CardPaymentsConstants.dupCheck, BOOL_TYPE}, + {CardPaymentsConstants.merchantDescriptor, typeof(MerchantDescriptor)}, + {CardPaymentsConstants.description, STRING_TYPE}, + {CardPaymentsConstants.txnTime, typeof(System.DateTime)}, + {CardPaymentsConstants.currencyCode, STRING_TYPE}, + {CardPaymentsConstants.avsResponse, CardPaymentsConstants.enumAVSResponse}, + {CardPaymentsConstants.cvvVerification, CardPaymentsConstants.enumCVVVerification}, + {CardPaymentsConstants.status, CardPaymentsConstants.enumStatus}, + {CardPaymentsConstants.riskReasonCode, typeof(List)}, + {CardPaymentsConstants.acquirerResponse, typeof(AcquirerResponse)}, + {CardPaymentsConstants.error, typeof(OptError)}, + {CardPaymentsConstants.links, typeof(List)} + }; + + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CardPaymentsConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CardPaymentsConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CardPaymentsConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CardPaymentsConstants.merchantRefNum, data); + } + + + /// + /// Get the childAccountNum + /// + /// string + public string childAccountNum() + { + return this.getProperty(CardPaymentsConstants.childAccountNum); + } + + /// + /// Set the childAccountNum + /// + /// void + public void childAccountNum(string data) + { + this.setProperty(CardPaymentsConstants.childAccountNum, data); + } + + /// + /// Get the card + /// + /// Card + public Card card() + { + return this.getProperty(CardPaymentsConstants.card); + } + + /// + /// Set the card + /// + /// void + public void card(Card data) + { + this.setProperty(CardPaymentsConstants.card, data); + } + + + /// + /// Get the authCode + /// + /// string + public string authCode() + { + return this.getProperty(CardPaymentsConstants.authCode); + } + + /// + /// Set the authCode + /// + /// void + public void authCode(string data) + { + this.setProperty(CardPaymentsConstants.authCode, data); + } + + /// + /// Get the profile + /// + /// Profile + public Profile profile() + { + return this.getProperty(CardPaymentsConstants.profile); + + } + + /// + /// Set the profile + /// + /// void + public void profile(Profile data) + { + this.setProperty(CardPaymentsConstants.profile, data); + } + + /// + /// Get the billing details + /// + /// BillingDetails + public BillingDetails billingDetails() + { + return this.getProperty(CardPaymentsConstants.billingDetails); + } + + /// + /// Set the billingDetails + /// + /// void + public void billingDetails(BillingDetails data) + { + this.setProperty(CardPaymentsConstants.billingDetails, data); + } + + /// + /// Get the customerIp + /// + /// string + public string customerIp() + { + return this.getProperty(CardPaymentsConstants.customerIp); + } + + /// + /// Set the customerIp + /// + /// void + public void customerIp(string data) + { + this.setProperty(CardPaymentsConstants.customerIp, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public bool dupCheck() + { + return this.getProperty(CardPaymentsConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(bool data) + { + this.setProperty(CardPaymentsConstants.dupCheck, data); + } + + /// + /// Get the merchantDescriptor + /// + /// MerchantDescriptor + public MerchantDescriptor merchantDescriptor() + { + return this.getProperty(CardPaymentsConstants.merchantDescriptor); + } + + /// + /// Set the merchantDescriptor + /// + /// void + public void merchantDescriptor(MerchantDescriptor data) + { + this.setProperty(CardPaymentsConstants.merchantDescriptor, data); + } + + /// + /// Get the description + /// + /// string + public string description() + { + return this.getProperty(CardPaymentsConstants.description); + } + + /// + /// Set the description + /// + /// void + public void description(string data) + { + this.setProperty(CardPaymentsConstants.description, data); + } + + /// + /// Get the txnTime + /// + /// System.DateTime + public System.DateTime txnTime() + { + return this.getProperty(CardPaymentsConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(System.DateTime data) + { + this.setProperty(CardPaymentsConstants.txnTime, data); + } + + /// + /// Get the currencyCode + /// + /// string + public string currencyCode() + { + return this.getProperty(CardPaymentsConstants.currencyCode); + } + + /// + /// Set the currencyCode + /// + /// void + public void currencyCode(string data) + { + this.setProperty(CardPaymentsConstants.currencyCode, data); + } + + /// + /// Get the avsResponse + /// + /// string + public string avsResponse() + { + return this.getProperty(CardPaymentsConstants.avsResponse); + } + + /// + /// Set the avsResponse + /// + /// void + public void avsResponse(string data) + { + this.setProperty(CardPaymentsConstants.avsResponse, data); + } + + /// + /// Get the cvvVerification + /// + /// string + public string cvvVerification() + { + return this.getProperty(CardPaymentsConstants.cvvVerification); + } + + /// + /// Set the cvvVerification + /// + /// void + public void cvvVerification(string data) + { + this.setProperty(CardPaymentsConstants.cvvVerification, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CardPaymentsConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CardPaymentsConstants.status, data); + } + + /// + /// Get the riskReasonCode + /// + /// List + public List riskReasonCode() + { + return this.getProperty(CardPaymentsConstants.riskReasonCode); + } + + /// + /// Set the riskReasonCode + /// + /// void + public void riskReasonCode(List data) + { + this.setProperty(CardPaymentsConstants.riskReasonCode, data); + } + + /// + /// Get the acquireResponse + /// + /// AcquirerResponse + public AcquirerResponse acquireResponse() + { + return this.getProperty(CardPaymentsConstants.acquirerResponse); + } + + /// + /// Set the acquireResponse + /// + /// void + public void acquireResponse(AcquirerResponse data) + { + this.setProperty(CardPaymentsConstants.acquirerResponse, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(CardPaymentsConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CardPaymentsConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CardPaymentsConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CardPaymentsConstants.links, data); + } + + /// + /// Get a new VerificationBuilder + /// + /// VerificationBuilder + public static VerificationBuilder Builder() + { + return new VerificationBuilder(); + } + + /// + /// VerificationBuilder will allow an Verification to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Verification object + /// + public class VerificationBuilder : BaseJSONBuilder + { + /// + /// Set the id + /// + /// string + /// VerificationBuilder + public VerificationBuilder id(string data) + { + this.properties[CardPaymentsConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum + /// + /// string + /// VerificationBuilder + public VerificationBuilder merchantRefNum(string data) + { + this.properties[CardPaymentsConstants.merchantRefNum] = data; + return this; + } + + /// + /// Build a card object within this Verification. + /// + /// Profile.profileBuilder + public Card.CardBuilder card() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.card)) + { + this.properties[CardPaymentsConstants.card] = new Card.CardBuilder(this); + } + return this.properties[CardPaymentsConstants.card] as Card.CardBuilder; + } + + /// + /// Set the dupCheck + /// + /// bool + /// VerificationBuilder + public VerificationBuilder dupCheck(bool data) + { + this.properties[CardPaymentsConstants.dupCheck] = data; + return this; + } + + /// + /// Build a profile object within this Verification. + /// + /// Profile.profileBuilder + public Profile.ProfileBuilder profile() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.profile)) + { + this.properties[CardPaymentsConstants.profile] = new Profile.ProfileBuilder(this); + } + return this.properties[CardPaymentsConstants.profile] as Profile.ProfileBuilder; + } + + /// + /// Build a billing details object within this Verification. + /// + /// BillingDetails.BillingDetailsBuilder + public BillingDetails.BillingDetailsBuilder billingDetails() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.billingDetails)) + { + this.properties[CardPaymentsConstants.billingDetails] = new BillingDetails.BillingDetailsBuilder(this); + } + return this.properties[CardPaymentsConstants.billingDetails] as BillingDetails.BillingDetailsBuilder; + } + + /// + /// Set the customerIp + /// + /// string + /// VerificationBuilder + public VerificationBuilder customerIp(string data) + { + this.properties[CardPaymentsConstants.customerIp] = data; + return this; + } + + /// + /// Build a merchant descriptor object within this Verification. + /// + /// MerchantDescriptor.MerchantDescriptorBuilder + public MerchantDescriptor.MerchantDescriptorBuilder merchantDescriptor() + { + if (!this.properties.ContainsKey(CardPaymentsConstants.merchantDescriptor)) + { + this.properties[CardPaymentsConstants.merchantDescriptor] = new MerchantDescriptor.MerchantDescriptorBuilder(this); + } + return this.properties[CardPaymentsConstants.merchantDescriptor] as MerchantDescriptor.MerchantDescriptorBuilder; + } + + /// + /// Set the description + /// + /// string + /// VerificationBuilder + public VerificationBuilder description(string data) + { + this.properties[CardPaymentsConstants.description] = data; + return this; + } + + } + } +} diff --git a/Paysafe/CardPayments/VisaAdditionalAuthData.cs b/Paysafe/CardPayments/VisaAdditionalAuthData.cs new file mode 100644 index 0000000..dc3a4db --- /dev/null +++ b/Paysafe/CardPayments/VisaAdditionalAuthData.cs @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CardPayments +{ + public class VisaAdditionalAuthData : JSONObject + { + /// + /// Initialize the VisaAdditionalAuthData object with some set of properties + /// + /// Dictionary + public VisaAdditionalAuthData(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CardPaymentsConstants.recipientDateOfBirth, typeof(RecipientDateOfBirth)}, + {CardPaymentsConstants.recipientZip, STRING_TYPE}, + {CardPaymentsConstants.recipientLastName, STRING_TYPE}, + {CardPaymentsConstants.recipientAccountNumber, STRING_TYPE} + }; + + /// + /// Get the recipientDateOfBirth + /// + /// string + public string recipientDateOfBirth() + { + return this.getProperty(CardPaymentsConstants.recipientDateOfBirth); + } + + /// + /// Set the recipientDateOfBirth + /// + /// void + public void recipientDateOfBirth(string data) + { + this.setProperty(CardPaymentsConstants.recipientDateOfBirth, data); + } + + /// + /// Get the recipientZip + /// + /// string + public string recipientZip() + { + return this.getProperty(CardPaymentsConstants.recipientZip); + } + + /// + /// Set the recipientZip + /// + /// void + public void recipientZip(string data) + { + this.setProperty(CardPaymentsConstants.recipientZip, data); + } + + /// + /// Get the recipientLastName + /// + /// string + public string recipientLastName() + { + return this.getProperty(CardPaymentsConstants.recipientLastName); + } + + /// + /// Set the recipientLastName + /// + /// void + public void recipientLastName(string data) + { + this.setProperty(CardPaymentsConstants.recipientLastName, data); + } + + /// + /// Get the recipientAccountNumber + /// + /// string + public string recipientAccountNumbere() + { + return this.getProperty(CardPaymentsConstants.recipientAccountNumber); + } + + /// + /// Set the recipientAccountNumber + /// + /// void + public void recipientAccountNumber(string data) + { + this.setProperty(CardPaymentsConstants.recipientAccountNumber, data); + } + } +} diff --git a/Paysafe/Common/APIException.cs b/Paysafe/Common/APIException.cs new file mode 100644 index 0000000..6753e96 --- /dev/null +++ b/Paysafe/Common/APIException.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class APIException : PaysafeException + { + public APIException() + : base() + { + + } + + public APIException(string message) + : base(message) + { + + } + + public APIException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/AbstractPagerator.cs b/Paysafe/Common/AbstractPagerator.cs new file mode 100644 index 0000000..14f5b77 --- /dev/null +++ b/Paysafe/Common/AbstractPagerator.cs @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +//Modified by Manjiri.Bankar on 02.08.2016. This is Pagerator class. +namespace Paysafe.Common +{ + public abstract class AbstractPagerator : IEnumerable + { + + /// + /// The result set so far retrieved + /// + protected List results = new List(); + + /// + /// The key in the returned array to be added to the resutl set + /// + protected string arrayKey = null; + + /// + /// The type to instantiate + /// + protected Type classType; + + /// + /// The url to the next page, if we haven't yet retrieved all results + /// + protected String nextPage = null; + + /// + /// The url to the self page + /// + protected String selfPage = null; + + /// + /// The url to the previous page + /// + protected String previousPage = null; + + /// + /// The client + /// + protected PaysafeApiClient client = null; + + + public AbstractPagerator(PaysafeApiClient apiClient, Type pagingClassType) + { + this.arrayKey = pagingClassType.GetMethod("getPageableArrayKey").Invoke(null, null) as string; + + this.client = apiClient; + this.classType = pagingClassType; + } + + /// + /// Get the current set of elements + /// + /// List + public List getResults() + { + return this.results; + } + + /// + /// Used by PageratorEnumerator to get result + /// + /// + /// + protected T get(int index) + { + return this.results.ElementAt(index); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Implemented to extended IEnumerable + /// + /// + public IEnumerator GetEnumerator() + { + return new PageratorEnumerator(this.classType, this); + } + + + protected abstract void parseResponse(Dictionary data); + + public class PageratorEnumerator : IEnumerator + { + AbstractPagerator parent = null; + + private int position = -1; + + public PageratorEnumerator(Type classType, AbstractPagerator parent) + { + this.parent = parent; + } + + public bool MoveNext() + { + this.position++; + if (this.parent.results.Count >= this.position && !String.IsNullOrWhiteSpace(this.parent.nextPage)) + { + Request request = new Request(url: this.parent.nextPage); + this.parent.parseResponse(this.parent.client.processRequest(request)); + } + return this.position < this.parent.results.Count; + } + + public void Reset() + { + position = -1; + } + + object IEnumerator.Current + { + get + { + return Current; + } + } + + public T Current + { + get + { + return this.parent.get(position); + } + } + } + } +} diff --git a/Paysafe/Common/AddressDetails.cs b/Paysafe/Common/AddressDetails.cs new file mode 100644 index 0000000..18a6152 --- /dev/null +++ b/Paysafe/Common/AddressDetails.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public abstract class AddressDetails: JSONObject + { + /// + /// Initialize the BillingDetails object with some set of properties + /// + /// Dictionary + public AddressDetails(Dictionary fieldTypes , Dictionary properties = null) + : base(fieldTypes, properties) + { + + } + + /// + /// This object is used to validate any properties set within the object + /// + protected static Dictionary addressFieldTypes = new Dictionary + { + {CommonConstants.street, STRING_TYPE}, + {CommonConstants.street2, STRING_TYPE}, + {CommonConstants.city, STRING_TYPE}, + {CommonConstants.state, STRING_TYPE}, + {CommonConstants.country, STRING_TYPE}, + {CommonConstants.zip, STRING_TYPE}, + {CommonConstants.phone, STRING_TYPE} + }; + + /// + /// Get the street + /// + /// string + public string street() + { + return this.getProperty(CommonConstants.street); + } + + /// + /// Set the street + /// + /// void + public void street(string data) + { + this.setProperty(CommonConstants.street, data); + } + + /// + /// Get the street2 + /// + /// string + public string street2() + { + return this.getProperty(CommonConstants.street2); + } + + /// + /// Set the street2 + /// + /// void + public void street2(string data) + { + this.setProperty(CommonConstants.street2, data); + } + + /// + /// Get the city + /// + /// string + public string city() + { + return this.getProperty(CommonConstants.city); + } + + /// + /// Set the city + /// + /// void + public void city(string data) + { + this.setProperty(CommonConstants.city, data); + } + + /// + /// Get the state + /// + /// string + public string state() + { + return this.getProperty(CommonConstants.state); + } + + /// + /// Set the state + /// + /// void + public void state(string data) + { + this.setProperty(CommonConstants.state, data); + } + + /// + /// Get the country + /// + /// string + public string country() + { + return this.getProperty(CommonConstants.country); + } + + /// + /// Set the country + /// + /// void + public void country(string data) + { + this.setProperty(CommonConstants.country, data); + } + + /// + /// Get the zip + /// + /// string + public string zip() + { + return this.getProperty(CommonConstants.zip); + } + + /// + /// Set the zip + /// + /// void + public void zip(string data) + { + this.setProperty(CommonConstants.zip, data); + } + + /// + /// Get the phone + /// + /// string + public string phone() + { + return this.getProperty(CommonConstants.phone); + } + + /// + /// Set the phone + /// + /// void + public void phone(string data) + { + this.setProperty(CommonConstants.phone, data); + } + } +} diff --git a/Paysafe/Common/BaseJSONBuilder.cs b/Paysafe/Common/BaseJSONBuilder.cs new file mode 100644 index 0000000..ddb16e4 --- /dev/null +++ b/Paysafe/Common/BaseJSONBuilder.cs @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public abstract class BaseJSONBuilder : GenericJSONBuilder + where TRTN : JSONObject + { + /// + /// Build the final object of type RTN + /// + /// RTN + public TRTN Build() + { + Object[] args = { this.properties }; + return Activator.CreateInstance(typeof(TRTN), args) as TRTN; + } + } +} diff --git a/Paysafe/Common/CardExpiry.cs b/Paysafe/Common/CardExpiry.cs new file mode 100644 index 0000000..eaed203 --- /dev/null +++ b/Paysafe/Common/CardExpiry.cs @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class CardExpiry : Paysafe.Common.JSONObject + { + /// + /// Initialize the CardExpiry object with some set of properties + /// + /// Dictionary + public CardExpiry(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CommonConstants.month, INT_TYPE}, + {CommonConstants.year, INT_TYPE} + }; + + /// + /// Get the month + /// + /// int + public int month() + { + return this.getProperty(CommonConstants.month); + } + + /// + /// Set the month + /// + /// void + public void month(int data) + { + this.setProperty(CommonConstants.month, data); + } + + /// + /// Get the year + /// + /// int + public int year() + { + return this.getProperty(CommonConstants.year); + } + + /// + /// Set the year + /// + /// void + public void year(int data) + { + this.setProperty(CommonConstants.year, data); + } + + /// + /// CardExpiryBuilder will allow a CardExpiry to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class CardExpiryBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the CardExpiry builder within the context of a parent builder + /// + /// TBLDR + public CardExpiryBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the month + /// + /// int + /// CardExpiryBuilder + public CardExpiryBuilder month(int data) + { + this.properties[CommonConstants.month] = data; + return this; + } + + /// + /// Set the year + /// + /// int + /// CardExpiryBuilder + public CardExpiryBuilder year(int data) + { + this.properties[CommonConstants.year] = data; + return this; + } + } + } +} diff --git a/Paysafe/Common/CommonConstants.cs b/Paysafe/Common/CommonConstants.cs new file mode 100644 index 0000000..14a6e24 --- /dev/null +++ b/Paysafe/Common/CommonConstants.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + /** + * This class can be used to override any of the string literals from the global strings class + */ + public class CommonConstants : GlobalConstants + { + } +} diff --git a/Paysafe/Common/Email.cs b/Paysafe/Common/Email.cs new file mode 100644 index 0000000..14c8b36 --- /dev/null +++ b/Paysafe/Common/Email.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + /// + /// Email will be used by JsonObject for validation + /// + public sealed class Email + { + } +} diff --git a/Paysafe/Common/EntityNotFoundException.cs b/Paysafe/Common/EntityNotFoundException.cs new file mode 100644 index 0000000..e13f23d --- /dev/null +++ b/Paysafe/Common/EntityNotFoundException.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class EntityNotFoundException : PaysafeException + { + public EntityNotFoundException() + : base() + { + + } + + public EntityNotFoundException(String message) + : base(message) + { + + } + + public EntityNotFoundException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/Error.cs b/Paysafe/Common/Error.cs new file mode 100644 index 0000000..730c9dd --- /dev/null +++ b/Paysafe/Common/Error.cs @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class OptError: JSONObject + { + /// + /// Initialize the Error object with some set of properties + /// + /// Dictionary + public OptError(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CommonConstants.code, STRING_TYPE}, + {CommonConstants.message, STRING_TYPE}, + {CommonConstants.details, typeof(List)}, + {CommonConstants.fieldErrors, typeof(List)}, + {CommonConstants.links, typeof(List)} + }; + + /// + /// Get the code + /// + /// string + public string code() + { + return this.getProperty(CommonConstants.code); + } + + /// + /// Set the code + /// + /// void + public void code(string data) + { + this.setProperty(CommonConstants.code, data); + } + + /// + /// Get the message + /// + /// string + public string message() + { + return this.getProperty(CommonConstants.message); + } + + /// + /// Set the message + /// + /// void + public void message(string data) + { + this.setProperty(CommonConstants.message, data); + } + + /// + /// Get the details + /// + /// Array + public List details() + { + return this.getProperty(CommonConstants.details); + } + + /// + /// Set the details + /// + /// Array of strings + public void details(List data) + { + this.setProperty(CommonConstants.details, data); + } + + /// + /// Get the fieldErrors + /// + /// array of strings + public List fieldErrors() + { + return this.getProperty(CommonConstants.fieldErrors); + } + + /// + /// Set the fieldErrors + /// + /// void + public void fieldErrors(Array data) + { + this.setProperty(CommonConstants.fieldErrors, data); + } + + /// + /// Get the links + /// + /// Array of Paysafe.Common.Link + public List links() + { + return this.getProperty(CommonConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CommonConstants.links, data); + } + } +} diff --git a/Paysafe/Common/FieldError.cs b/Paysafe/Common/FieldError.cs new file mode 100644 index 0000000..8af4df6 --- /dev/null +++ b/Paysafe/Common/FieldError.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class FieldError: JSONObject + { + /// + /// Initialize the FieldError object with some set of properties + /// + /// Dictionary + public FieldError(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CommonConstants.field, STRING_TYPE}, + {CommonConstants.error, STRING_TYPE} + }; + + /// + /// Get the field + /// + /// string + public string field() + { + return this.getProperty(CommonConstants.field); + } + + /// + /// Set the expiry field + /// + /// string + /// void + public void field(string data) + { + this.setProperty(CommonConstants.field, data); + } + + /// + /// Get the expiry error + /// + /// string + public string error() + { + return this.getProperty(CommonConstants.error); + } + + /// + /// Set the expiry error + /// + /// string + /// void + public void error(string data) + { + this.setProperty(CommonConstants.error, data); + } + } +} diff --git a/Paysafe/Common/GenericJSONBuilder.cs b/Paysafe/Common/GenericJSONBuilder.cs new file mode 100644 index 0000000..86699d2 --- /dev/null +++ b/Paysafe/Common/GenericJSONBuilder.cs @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + /// + /// A non generic object to help JSONBuilder easily identify builder objects + /// + public abstract class GenericJSONBuilder + { + protected Dictionary properties = new Dictionary(); + } +} diff --git a/Paysafe/Common/GlobalConstants.cs b/Paysafe/Common/GlobalConstants.cs new file mode 100644 index 0000000..afc8389 --- /dev/null +++ b/Paysafe/Common/GlobalConstants.cs @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + /** + * GlobalConstants class contains all strings that are sent and returned from the netbanx api + */ + public class GlobalConstants + { + //////////// REQUEST PARAMETER STRINGS //////////// + public static readonly string accordD = "accordD"; + public static readonly string acquirerResponse = "acquirerResponse"; + public static readonly string addendumData = "addendumData"; + public static readonly string addresses = "addresses"; + public static readonly string amount = "amount"; + public static readonly string ancillaryFees = "ancillaryFees"; + public static readonly string associatedTransactions = "associatedTransactions"; + public static readonly string authCode = "authCode"; + public static readonly string authentication = "authentication"; + public static readonly string authenticationMethod = "authenticationMethod"; + public static readonly string authorizationId = "authorizationId"; + public static readonly string authType = "authType"; + public static readonly string availableToRefund = "availableToRefund"; + public static readonly string availableToSettle = "availableToSettle"; + public static readonly string avsCode = "avsCode"; + public static readonly string avsResponse = "avsResponse"; + public static readonly string balanceResponse = "balanceResponse"; + public static readonly string batchNumber = "batchNumber"; + public static readonly string billingAddressId = "billingAddressId"; + public static readonly string billingDetails = "billingDetails"; + public static readonly string brand = "brand"; + public static readonly string callback = "callback"; + public static readonly string card = "card"; + public static readonly string cardBin = "cardBin"; + public static readonly string cardEnrollementMethod = "cardEnrollementMethod"; + public static readonly string cardExpiry = "cardExpiry"; + public static readonly string cardNum = "cardNum"; + public static readonly string cards = "cards"; + public static readonly string cardType = "cardType"; + public static readonly string carrier = "carrier"; + public static readonly string cavv = "cavv"; + public static readonly string cellPhone = "cellPhone"; + public static readonly string childAccountNum = "childAccountNum"; + public static readonly string city = "city"; + public static readonly string code = "code"; + public static readonly string confirmationNumber = "confirmationNumber"; + public static readonly string country = "country"; + public static readonly string currencyCode = "currencyCode"; + public static readonly string customerIp = "customerIp"; + public static readonly string customerNotificationEmail = "customerNotificationEmail"; + public static readonly string cvdVerification = "cvdVerification"; + public static readonly string cvv = "cvv"; + public static readonly string cvv2Result = "cvv2Result"; + public static readonly string cvvVerification = "cvvVerification"; + public static readonly string dateOfBirth = "dateOfBirth"; + public static readonly string dateTime = "dateTime"; + public static readonly string day = "day"; + public static readonly string defaultCardIndicator = "defaultCardIndicator"; + public static readonly string defaultShippingAddressIndicator = "defaultShippingAddressIndicator"; + public static readonly string delimiter = "delimiter"; + public static readonly string description = "description"; + public static readonly string details = "details"; + public static readonly string dueDate = "dueDate"; + public static readonly string dupCheck = "dupCheck"; + public static readonly string dynamicDescriptor = "dynamicDescriptor"; + public static readonly string eci = "eci"; + public static readonly string effectiveDate = "effectiveDate"; + public static readonly string email = "email"; + public static readonly string error = "error"; + public static readonly string errorCode = "errorCode"; + public static readonly string errorMessage = "errorMessage"; + public static readonly string expiry = "expiry"; + public static readonly string extendedOptions = "extendedOptions"; + public static readonly string field = "field"; + public static readonly string fieldErrors = "fieldErrors"; + public static readonly string financingType = "financingType"; + public static readonly string firstName = "firstName"; + public static readonly string format = "format"; + public static readonly string gender = "gender"; + public static readonly string gracePeriod = "gracePeriod"; + public static readonly string holderName = "holderName"; + public static readonly string houseNumberVerification = "houseNumberVerification"; + public static readonly string href = "href"; + public static readonly string id = "id"; + public static readonly string ip = "ip"; + public static readonly string key = "key"; + public static readonly string keywords = "keywords"; + public static readonly string lastDigits = "lastDigits"; + public static readonly string lastName = "lastName"; + public static readonly string lastUpdate = "lastUpdate"; + public static readonly string link = "link"; + public static readonly string links = "links"; + public static readonly string locale = "locale"; + public static readonly string masterCardAssignedId = "masterCardAssignedId"; + public static readonly string masterPass = "masterPass"; + public static readonly string merchantCustomerId = "merchantCustomerId"; + public static readonly string merchantDescriptor = "merchantDescriptor"; + public static readonly string merchantNotificationEmail = "merchantNotificationEmail"; + public static readonly string merchantRefNum = "merchantRefNum"; + public static readonly string message = "message"; + public static readonly string mid = "mid"; + public static readonly string middleName = "middleName"; + public static readonly string mode = "mode"; + public static readonly string month = "month"; + public static readonly string nationality = "nationality"; + public static readonly string nickName = "nickName"; + public static readonly string orderId = "orderId"; + public static readonly string originalMerchantRefNum = "originalMerchantRefNum"; + public static readonly string paymentMethod = "paymentMethod"; + public static readonly string paymentToken = "paymentToken"; + public static readonly string paymentType = "paymentType"; + public static readonly string payPassWalletIndicator = "payPassWalletIndicator"; + public static readonly string phone = "phone"; + public static readonly string plan = "plan"; + public static readonly string profile = "profile"; + public static readonly string profileId = "profileId"; + public static readonly string quantity = "quantity"; + public static readonly string recipientAccountNumber = "recipientAccountNumber"; + public static readonly string recipientDateOfBirth = "recipientDateOfBirth"; + public static readonly string recipientLastName = "recipientLastName"; + public static readonly string recipientName = "recipientName"; + public static readonly string recipientZip = "recipientZip"; + public static readonly string recurring = "recurring"; + public static readonly string redirect = "redirect"; + public static readonly string reference = "reference"; + public static readonly string referenceNbr = "referenceNbr"; + public static readonly string refunded = "refunded"; + public static readonly string rel = "rel"; + public static readonly string requestId = "requestId"; + public static readonly string responseCode = "responseCode"; + public static readonly string responseId = "responseId"; + public static readonly string responseReasonCode = "responseReasonCode"; + public static readonly string retries = "retries"; + public static readonly string returnKeys = "returnKeys"; + public static readonly string reversed = "reversed"; + public static readonly string riskReasonCode = "riskReasonCode"; + public static readonly string seqNumber = "seqNumber"; + public static readonly string settled = "settled"; + public static readonly string settlementId = "settlementId"; + public static readonly string settlements = "settlements"; + public static readonly string settleWithAuth = "settleWithAuth"; + public static readonly string shipMethod = "shipMethod"; + public static readonly string shippingDetails = "shippingDetails"; + public static readonly string shoppingCart = "shoppingCart"; + public static readonly string signatureStatus = "signatureStatus"; + public static readonly string sku = "sku"; + public static readonly string state = "state"; + public static readonly string status = "status"; + public static readonly string street = "street"; + public static readonly string street2 = "street2"; + public static readonly string synchronous = "synchronous"; + public static readonly string term = "term"; + public static readonly string terminalId = "terminalId"; + public static readonly string threeDEnrollment = "threeDEnrollment"; + public static readonly string threeDEnrolment = "threeDEnrolment"; + public static readonly string threeDResult = "threeDResult"; + public static readonly string totalAmount = "totalAmount"; + public static readonly string track1 = "track1"; + public static readonly string track2 = "track2"; + public static readonly string transaction = "transaction"; + public static readonly string txnDateTime = "txnDateTime"; + public static readonly string txnTime = "txnTime"; + public static readonly string type = "type"; + public static readonly string uri = "uri"; + public static readonly string useAsShippingAddress = "useAsShippingAddress"; + public static readonly string value = "value"; + public static readonly string visaAdditionalAuthData = "visaAdditionalAuthData"; + public static readonly string xid = "xid"; + public static readonly string year = "year"; + public static readonly string zip = "zip"; + public static readonly string zipVerification = "zipVerification"; + public static readonly string accountNumber = "accountNumber"; + public static readonly string accountHolderName = "accountHolderName"; + public static readonly string routingNumber = "routingNumber"; + public static readonly string accountType = "accountType"; + public static readonly string sortCode = "sortCode"; + public static readonly string mandates = "mandates"; + public static readonly string mandateReference = "mandateReference"; + public static readonly string ach = "ach"; + public static readonly string sepa = "sepa"; + public static readonly string bacs = "bacs"; + public static readonly string eft = "eft"; + public static readonly string payMethod = "payMethod"; + public static readonly string WEB = "WEB"; + public static readonly string TEL = "TEL"; + public static readonly string PPD = "PPD"; + public static readonly string CCD = "CCD"; + public static readonly string paymentDescriptor = "paymentDescriptor"; + public static readonly string iban = "iban"; + public static readonly string bic = "bic"; + public static readonly string transitNumber = "transitNumber"; + public static readonly string institutionId = "institutionId"; + public static readonly string bankAccountId = "bankAccountId"; + public static readonly string accountTypeChecking = "CHECKING"; + public static readonly string accountTypeLoan = "LOAN"; + public static readonly string accountTypeSavings = "SAVINGS"; + + /// + + public static readonly string achBankAccounts = "achBankAccounts"; + public static readonly string bacsBankAccounts = "bacsBankAccounts"; + public static readonly string sepaBankAccounts = "sepaBankAccounts"; + public static readonly string eftBankAccounts = "eftBankAccounts"; + public static readonly string billingAddress = "billingAddress"; + public static readonly string enrollmentchecks = "enrollmentchecks"; + + //////////// RESPONSE VALIDATON STRINGS //////////// + public static readonly string authTypeAuth = "auth"; + public static readonly string authTypePurchase = "purchase"; + public static readonly string authTypeRefund = "refund"; + public static readonly string authTypeSettlement = "settlement"; + public static readonly string carrierAnpost = "APS"; + public static readonly string carrierAPC = "APC"; + public static readonly string carrierCanadaPost = "CAD"; + public static readonly string carrierCityLink = "CLK"; + public static readonly string carrierDHL = "DHL"; + public static readonly string carrierEMS = "EMS"; + public static readonly string carrierFedEx = "FEX"; + public static readonly string carrierNexWorldWide = "NEX"; + public static readonly string carrierOther = "OTHER"; + public static readonly string carrierRoyalMail = "RML"; + public static readonly string carrierUPS = "UPS"; + public static readonly string carrierUSPS = "USPS"; + public static readonly string financingDeferredPayment = "DEFERRED_PAYMENT"; + public static readonly string financingEqualPayment = "EQUAL_PAYMENT"; + public static readonly string formatFORM = "form-urlencoded"; + public static readonly string formatGET = "get"; + public static readonly string formatJSON = "json"; + public static readonly string formatXML = "xml"; + public static readonly string genderFemale = "F"; + public static readonly string genderMale = "M"; + public static readonly string localeEnGb = "en_GB"; + public static readonly string localeEnUs = "en_US"; + public static readonly string localeFrCa = "fr_CA"; + public static readonly string relCancelUrl = "cancel_url"; + public static readonly string relOnDecline = "on_decline"; + public static readonly string relOnError = "on_error"; + public static readonly string relOnHold = "on_hold"; + public static readonly string relOnSuccess = "on_success"; + public static readonly string relOnTimeout = "on_timeout"; + public static readonly string relResendCallback = "resend_callback"; + public static readonly string relReturnUrl = "return_url"; + public static readonly string relSelf = "self"; + public static readonly string shipMethodLowestCost = "C"; + public static readonly string shipMethodNextDay = "N"; + public static readonly string shipMethodOther = "O"; + public static readonly string shipMethodTwoDay = "T"; + public static readonly string statusActive = "ACTIVE"; + public static readonly string statusInvalid = "INVALID"; + public static readonly string statusInactive = "INACTIVE"; + public static readonly string statusDeclined = "DECLINED"; + public static readonly string statusBatched = "BATCHED"; + public static readonly string statusRejected = "REJECTED"; + public static readonly string statusDisputed = "DISPUTED"; + public static readonly string statusReason = "REASON"; + public static readonly string statusChangeDate = "statusChangeDate"; + public static readonly string statusReasonCode = "statusReasonCode"; + public static readonly string statusCancelled = "CANCELLED"; + public static readonly string statusCompleted = "COMPLETED"; + public static readonly string statusFailed = "FAILED"; + public static readonly string statusInitial = "INITIAL"; + public static readonly string statusPending = "PENDING"; + public static readonly string statusProcessing = "PROCESSING"; + public static readonly string statusReceived = "RECEIVED"; + public static readonly string recurringInitial = "INITIAL"; + public static readonly string recurringRecurring = "RECURRING"; + public static readonly string validationHeld = "HELD"; + public static readonly string validationMatch = "MATCH"; + public static readonly string validationMatchAddressOnly = "MATCH_ADDRESS_ONLY"; + public static readonly string validationMatchZipOnly = "MATCH_ZIP_ONLY"; + public static readonly string validationNoMatch = "NO_MATCH"; + public static readonly string validationNotProcessed = "NOT_PROCESSED"; + public static readonly string validationUnknown = "UNKNOWN"; + public static readonly string singleUseToken = "singleUseToken"; + public static readonly string currency = "currency"; + public static readonly string userAgent = "userAgent"; + public static readonly string acceptHeader = "acceptHeader"; + public static readonly string merchantUrl = "merchantUrl"; + public static readonly string acsURL = "acsURL"; + public static readonly string paReq = "paReq"; + public static readonly string threeDEnrolled = "Y"; + public static readonly string threeDNotEnrolled = "N"; + public static readonly string threeDEnrollmentUnavailable = "U"; + public static readonly string paResp = "paRes"; + public static readonly string authenticated = "Y"; + public static readonly string authenticationAttempted = "A"; + public static readonly string authenticationFailed = "N"; + public static readonly string authenticationUnavailable = "U"; + public static readonly string authenticationError = "E"; + public static readonly string signatureSatisfied = "Y"; + public static readonly string signatureNotSatisfied = "N"; + public static readonly string enrollmentId = "enrollmentId"; + + public static readonly string AM = "AM"; + public static readonly string DC = "DC"; + public static readonly string DI = "DI"; + public static readonly string JC = "JC"; + public static readonly string MC = "MC"; + public static readonly string MD = "MD"; + public static readonly string SF = "SF"; + public static readonly string SO = "SO"; + public static readonly string VI = "VI"; + public static readonly string VD = "VD"; + public static readonly string VE = "VE"; + + public static readonly List enumCarrier = new List{ + carrierAPC, + carrierAnpost, + carrierCanadaPost, + carrierDHL, + carrierFedEx, + carrierRoyalMail, + carrierUPS, + carrierUSPS, + carrierCityLink, + carrierEMS, + carrierNexWorldWide, + carrierOther + }; + public static readonly List enumGender = new List() { + genderMale, + genderFemale + }; + public static readonly List enumLocale = new List() { + localeEnUs, + localeFrCa, + localeEnGb + }; + public static readonly List enumShipMethod = new List() { + shipMethodNextDay, + shipMethodTwoDay, + shipMethodLowestCost, + shipMethodOther + }; + } +} diff --git a/Paysafe/Common/InvalidCredentialsException.cs b/Paysafe/Common/InvalidCredentialsException.cs new file mode 100644 index 0000000..2c247f2 --- /dev/null +++ b/Paysafe/Common/InvalidCredentialsException.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class InvalidCredentialsException :PaysafeException + { + public InvalidCredentialsException() + : base() + { + + } + + public InvalidCredentialsException(String message) + : base(message) + { + + } + + public InvalidCredentialsException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/InvalidRequestException.cs b/Paysafe/Common/InvalidRequestException.cs new file mode 100644 index 0000000..66774e4 --- /dev/null +++ b/Paysafe/Common/InvalidRequestException.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class InvalidRequestException : PaysafeException + { + public InvalidRequestException() + : base() + { + + } + + public InvalidRequestException(String message) + : base(message) + { + + } + + public InvalidRequestException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/JSONObject.cs b/Paysafe/Common/JSONObject.cs new file mode 100644 index 0000000..c27cbea --- /dev/null +++ b/Paysafe/Common/JSONObject.cs @@ -0,0 +1,471 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; + +using Newtonsoft.Json; + +namespace Paysafe.Common +{ + /// + /// This is the base class for all objects within the sdk. + /// It is used to allow generic assignment of fields and properties. + /// + public abstract class JSONObject + { + /// + /// fieldTypes must be passed into the constructor in order to allow generic validation + /// + protected Dictionary fieldTypes; + + /// + /// this dictionary will store all set properties within the final object + /// + private Dictionary properties = new Dictionary(); + + /// + /// optionalFields will be used by the api client to determine which of the set fields + /// should be sent to the api + /// + private List optionalFields; + + /// + /// requiredFields will be used by the api client to determine which of the fields must + /// be set before sending a request to the api + /// + private List requiredFields; + + protected static Type STRING_TYPE = typeof(string); + protected static Type INT_TYPE = typeof(int); + protected static Type BOOL_TYPE = typeof(bool); + protected static Type URL_TYPE = typeof(Url); + protected static Type EMAIL_TYPE = typeof(Email); + protected static Type FLOAT_TYPE = typeof(float); + + /// + /// The object will be json serialized using only the optional and required properties + /// + /// string + public override string ToString() + { + return JsonConvert.SerializeObject(this.jsonSerialize()); + } + + /// + /// This method will serialize only the required or optional properties within this + /// and any nested JSONObjects. or if no required/optional properties are set, then + /// all properties will be returned + /// + /// + private Dictionary jsonSerialize() + { + this.checkRequiredFields(); + Dictionary toJSON; + if ((null == this.optionalFields || 0 == this.optionalFields.Count) && + (null == this.requiredFields || 0 == this.requiredFields.Count)) + { + toJSON = this.properties; + } + else + { + toJSON = new Dictionary(); + if (requiredFields != null) + { + foreach (string key in requiredFields) + { + if (properties.ContainsKey(key)) + { + toJSON.Add(key, properties[key]); + } + } + } + if (optionalFields != null) + { + foreach (string key in optionalFields) + { + if (properties.ContainsKey(key)) + { + toJSON.Add(key, properties[key]); + } + } + } + } + return this.filterJSON(toJSON) as Dictionary; + } + + /// + /// Throws an exception if any required fields have not been set + /// + public void checkRequiredFields() + { + if (requiredFields != null) + { + List missingFields = new List(); + foreach (string key in requiredFields) + { + if (!properties.ContainsKey(key)) + { + missingFields.Add(key); + } + } + if (missingFields.Count > 0) + { + throw new PaysafeException("Missing required properties: " + string.Join(", ", missingFields)); + } + } + } + + /// + /// This method is used by jsonSerialize, and will filter all non required/optional + /// from any nested objects + /// + /// Dictioanry + /// Dictionary + private dynamic filterJSON(dynamic result) + { + if (result is Dictionary) + { + Dictionary @return = new Dictionary(); + foreach (string key in ((Dictionary)result).Keys) + { + @return[key] = this.filterJSON(result[key]); + } + return @return; + } + else if (((object)result).GetType().IsGenericType + && ((object)result).GetType().GetGenericTypeDefinition() == typeof(List<>)) + { + return this.filterList(result); + } + else if (result is JSONObject) + { + return ((JSONObject)result).jsonSerialize(); + } + return result; + } + + private List filterList(List list) + { + List @return = new List(); + foreach (T item in list) + { + @return.Add(this.filterJSON(item)); + } + return @return; ; + } + + /// + /// Set the optional fields to be consumed by the api client + /// + /// List + public void setOptionalFields(List fields) + { + List invalidKeys = new List(); + foreach (string key in fields) + { + if (!this.fieldTypes.ContainsKey(key)) + { + invalidKeys.Add(key); + } + } + if (invalidKeys.Count > 0) + { + throw new PaysafeException("Invalid optional fields. Unknown fields: " + string.Join(", ", invalidKeys)); + } + this.optionalFields = fields; + } + + /// + /// Set the required fields to be consumed by the api client + /// + /// + public void setRequiredFields(List fields) + { + List invalidKeys = new List(); + foreach (string key in fields) + { + if (!this.fieldTypes.ContainsKey(key)) + { + invalidKeys.Add(key); + } + } + if (invalidKeys.Count > 0) + { + throw new PaysafeException("Invalid required fields. Unknown fields: " + string.Join(", ", invalidKeys)); + } + this.requiredFields = fields; + } + + /// + /// Initialize the Object, setting the internetal properties from parameters based on the types + /// + /// Dictioanry + /// Dictionary + public JSONObject(Dictionary types, Dictionary parameters = null) + { + this.fieldTypes = types; + if (!Object.ReferenceEquals(parameters, null)) + { + foreach (string key in parameters.Keys) + { + var tmp = getFieldInfo(key); + if (!Object.ReferenceEquals(tmp, null)) + { + KeyValuePair info = (KeyValuePair)tmp; + this.setProperty(info.Key, parameters[key]); + } + } + } + } + + /// + /// Set the property name with value cast based on the fieldTypes dictionary + /// + /// string + /// dynamic + protected void setProperty(string name, dynamic value) { + var tmp = getFieldInfo(name); + if (Object.ReferenceEquals(tmp, null)) + { + throw new PaysafeException("Invalid property " + name + " for class " + this.GetType().ToString()); + } + KeyValuePair info = (KeyValuePair)tmp; + + if (Object.ReferenceEquals(value, null)) + { + this.properties.Remove(info.Key); + } + else + { + this.properties[info.Key] = this.cast(info.Key, value, info.Value); + } + + } + + /// + /// Get the pproperty name fromt he properties dictionary + /// + /// string + /// + protected dynamic getProperty(string name) + { + var tmp = getFieldInfo(name); + if (Object.ReferenceEquals(tmp, null)) + { + throw new PaysafeException("Invalid property " + name + " for class " + this.GetType().ToString()); + } + KeyValuePair info = (KeyValuePair)tmp; + if (this.properties.ContainsKey(info.Key)) + { + return this.properties[info.Key]; + } + return null; + } + + /// + /// Checks if a specfic property has been set + /// + /// string + /// + public bool hasProperty(string name) + { + var tmp = getFieldInfo(name); + if (null == tmp) + { + return false; + } + KeyValuePair info = (KeyValuePair)tmp; + return this.properties.ContainsKey(info.Key); + } + + /// + /// Get the validation rules for a given field + /// + /// string + /// KeyValuePair or null + private dynamic getFieldInfo(string name) + { + if (null == this.fieldTypes) + { + throw new PaysafeException("field types must be initialized"); + } + if (this.fieldTypes.ContainsKey(name)) + { + return new KeyValuePair(name, this.fieldTypes[name]); + } + name = name.ToLower(); + foreach (string key in this.fieldTypes.Keys) + { + if (key.ToLower() == name) + { + return new KeyValuePair(key, this.fieldTypes[key]); + } + } + return null; + } + + /// + /// Casts property value to type validation + /// + /// string + /// dynamic + /// string + /// + public dynamic cast(string name, dynamic value, dynamic validation) + { + string valueString = null; + if (value is string) + { + valueString = (string)value; + } + if (validation is List) + { + List validationList = (List)validation; + if (null == valueString || !validationList.Contains(valueString)) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". Expected one of: " + string.Join(", ", validationList) + "."); + } + return value; + } + else if (validation is Type) + { + Type validationType = validation as Type; + if (validationType.Equals(STRING_TYPE)) + { + if (null == valueString) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". String expected."); + } + return value; + } + else if (validationType.Equals(EMAIL_TYPE)) + { + if (null == valueString|| valueString.IndexOf("@", StringComparison.CurrentCulture) <= 0) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". Email expected."); + } + return value; + } + else if (validationType.Equals(URL_TYPE)) + { + System.Uri uriResult; + if (null == valueString || (Uri.TryCreate(valueString, UriKind.Absolute, out uriResult) && null == uriResult)) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". URL expected."); + } + return value; + } + else if (validationType.Equals(INT_TYPE)) + { + try + { + return Convert.ToInt32(value); + } + catch (Exception) + { + //format exception or overflow exception + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". Integer expected."); + } + } + else if (validationType.Equals(FLOAT_TYPE)) + { + decimal decVal; + if (value is decimal) + { + decVal = ((decimal)value); + } + else if (valueString != null || !decimal.TryParse(((string)value), out decVal)) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". Decimal expected."); + } + return decVal; + } + else if (validationType.Equals(BOOL_TYPE)) + { + bool boolVal; + if (value is bool) + { + boolVal = ((bool)value); + } + else if (null == valueString || !bool.TryParse(valueString, out boolVal)) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". Boolean expected."); + } + return boolVal; + } + else if (validationType.IsGenericType && + validationType.GetGenericTypeDefinition() == typeof(List<>)) + { + Type subType = validationType.GetGenericArguments()[0]; + if (!(value is System.Collections.IList)) + { + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString() + ". List expected."); + } + Type T = null; + for (int i = 0; i < ((System.Collections.IList)value).Count; i++) + { + value[i] = this.cast(name, value[i], subType); + T = ((object)((System.Collections.IList)value)[i]).GetType(); + } + if (T != null && value is List) + { + //convert list of subtype object to a list of the required subtype + dynamic newList = typeof(List<>) + .MakeGenericType(T) + .GetConstructor(new Type[] { }) + .Invoke(new object[] { }); + for (int i = 0; i < ((List)value).Count; i++) + { + newList.Add(value[i]); + } + return newList; + } + return value; + } + else + { + Type valueType = value.GetType(); + if ((value is Dictionary)) + { + Object[] args = { value }; + return Activator.CreateInstance(validationType, args); + } + else if (valueType == validationType) + { + return value; + } + else if (valueType.GetMethod("Build") != null && valueType.IsSubclassOf(typeof(GenericJSONBuilder))) + { + dynamic returnValue = value.Build(); + if (returnValue.GetType() as Type == validationType) + { + return returnValue; + } + } + throw new PaysafeException("Invalid value for property " + name + " for class " + this.GetType().ToString()); + } + } + throw new PaysafeException("Invalid validation rule for property " + name + " for class " + this.GetType().ToString()); + } + } +} diff --git a/Paysafe/Common/JsonHelper.cs b/Paysafe/Common/JsonHelper.cs new file mode 100644 index 0000000..77381f0 --- /dev/null +++ b/Paysafe/Common/JsonHelper.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json.Linq; + +namespace Paysafe.Common +{ + public static class JsonHelper + { + public static Dictionary Deserialize(string json) + { + return ToObject(JToken.Parse(json)) as Dictionary; + } + + private static dynamic ToObject(JToken token) + { + if (JTokenType.Object == token.Type) + { + Dictionary dict = new Dictionary(); + foreach (JProperty prop in token) + { + dict.Add(prop.Name, ToObject(prop.Value)); + } + return dict; + } + else if (JTokenType.Array == token.Type) + { + List list = new List(); + foreach (JToken value in token) + { + list.Add(ToObject(value)); + } + return list; + } + var tokenValue = ((JValue)token).Value; + if (tokenValue != null + && (tokenValue is int || tokenValue is bool || tokenValue is long)) + { + return tokenValue.ToString(); + } + else + { + return tokenValue; + } + } + } +} \ No newline at end of file diff --git a/Paysafe/Common/Link.cs b/Paysafe/Common/Link.cs new file mode 100644 index 0000000..cac9201 --- /dev/null +++ b/Paysafe/Common/Link.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class Link: JSONObject + { + /// + /// Initialize the Link object with some set of properties + /// + /// Dictionary + public Link(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CommonConstants.rel, STRING_TYPE}, + {CommonConstants.href, URL_TYPE} + }; + + + /// + /// Get the rel + /// + /// string + public string rel() + { + return this.getProperty(CommonConstants.rel); + } + + /// + /// Set the rel + /// + /// void + public void rel(string data) + { + this.setProperty(CommonConstants.rel, data); + } + + /// + /// Get the href + /// + /// string + public string href() + { + return this.getProperty(CommonConstants.href); + } + + /// + /// Set the href + /// + /// void + public void href(string data) + { + this.setProperty(CommonConstants.href, data); + } + + } +} diff --git a/Paysafe/Common/NestedJSONBuilder.cs b/Paysafe/Common/NestedJSONBuilder.cs new file mode 100644 index 0000000..815a89d --- /dev/null +++ b/Paysafe/Common/NestedJSONBuilder.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class NestedJSONBuilder : BaseJSONBuilder + where TBLDR : GenericJSONBuilder + where TRTN : JSONObject + { + /// + /// A reference to the builder object which instantiated this builder + /// + protected TBLDR parent; + + /// + /// Return the parent builder + /// + /// TBLDR + public TBLDR Done() + { + return parent; + } + + /// + /// Initialize this builder with a reference to the parent builder + /// + /// + public NestedJSONBuilder(TBLDR parent) + { + this.parent = parent; + } + } +} diff --git a/Paysafe/Common/PaysafeException.cs b/Paysafe/Common/PaysafeException.cs new file mode 100644 index 0000000..3e4161d --- /dev/null +++ b/Paysafe/Common/PaysafeException.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014 Paysafe Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class PaysafeException : Exception + { + public PaysafeException() + : base() + { + + } + + public PaysafeException(String message) + : base(message) + { + + } + + public PaysafeException(string message, Exception innerException) + : base(message, innerException) + { + + } + + private Dictionary _rawResponse = new Dictionary(); + + private int _code = -1; + + public void rawResponse(Dictionary data) + { + this._rawResponse = data; + } + + public Dictionary rawResponse() + { + return this._rawResponse; + } + + public void code(int data) + { + this._code = data; + } + + public int cpde() + { + return this._code; + } + } +} diff --git a/Paysafe/Common/PermissionException.cs b/Paysafe/Common/PermissionException.cs new file mode 100644 index 0000000..a366380 --- /dev/null +++ b/Paysafe/Common/PermissionException.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace optimal.common +{ + public class PermissionException : NetbanxException + { + public PermissionException() + : base() + { + + } + + public PermissionException(String message) + : base(message) + { + + } + + public PermissionException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/RecipientDateOfBirth.cs b/Paysafe/Common/RecipientDateOfBirth.cs new file mode 100644 index 0000000..9cf57c5 --- /dev/null +++ b/Paysafe/Common/RecipientDateOfBirth.cs @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + + public class RecipientDateOfBirth : JSONObject + { + /// + /// Initialize the DateOfBirth object with some set of properties + /// + /// Dictionary + public RecipientDateOfBirth(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CommonConstants.day, INT_TYPE}, + {CommonConstants.month, INT_TYPE}, + {CommonConstants.year, INT_TYPE} + }; + + /// + /// Get the day + /// + /// int + public int day() + { + return this.getProperty(CommonConstants.day); + } + + /// + /// Set the day + /// + /// void + public void day(int data) + { + this.setProperty(CommonConstants.day, data); + } + + /// + /// Get the month + /// + /// int + public int month() + { + return this.getProperty(CommonConstants.month); + } + + /// + /// Set the month + /// + /// void + public void month(int data) + { + this.setProperty(CommonConstants.month, data); + } + + /// + /// Get the year + /// + /// int + public int year() + { + return this.getProperty(CommonConstants.year); + } + + /// + /// Set the year + /// + /// void + public void year(int data) + { + this.setProperty(CommonConstants.year, data); + } + } +} diff --git a/Paysafe/Common/Request.cs b/Paysafe/Common/Request.cs new file mode 100644 index 0000000..8de0c50 --- /dev/null +++ b/Paysafe/Common/Request.cs @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RequestType=Paysafe.RequestType; + +namespace Paysafe.Common +{ + public class Request + { + /// + /// The uri to be accessed for this request + /// + private String uri; + + /// + /// The type of request to be perfomed (GET/POST/DELETE/PUT) + /// + private RequestType requestMethod; + + /// + /// The JSONObject to send as the request body + /// + private JSONObject requestBody; + + /// + /// Any additional query string parameters to be sent + /// + private Dictionary queryString; + + /// + /// Allow the full url to be specified rather than the uri + /// + private String url; + + public Request(String uri = "", Dictionary queryString = null, RequestType method = RequestType.GET, JSONObject body = null, String url = null) + { + this.uri = uri; + this.requestMethod = method; + this.requestBody = body; + this.queryString = queryString; + this.url = url; + } + + /// + /// Build url for the Paysafe api client + /// + /// string + /// string + public String buildUrl(String apiEndPoint) + { + if(null == this.url) { + return apiEndPoint + '/' + this.uri + this.buildQueryString(); + } + if (this.url.IndexOf(apiEndPoint, StringComparison.CurrentCulture) != 0) + { + throw new PaysafeException("Unexpected endpoint in url: " + this.url + " expected: " + apiEndPoint); + } + return this.url; + } + + /// + /// Builds the query string if applicable + /// + /// string + private String buildQueryString() + { + String response = ""; + if(this.queryString != null && this.queryString.Count > 0) { + if (this.uri != null && this.uri.IndexOf("?", StringComparison.CurrentCulture) >= 0) + { + response += "&"; + } else { + response += "?"; + } + foreach (KeyValuePair entry in this.queryString) + { + if (response.Length > 1) + { + response += '&'; + } + response += entry.Key + '=' + System.Uri.EscapeDataString(entry.Value); + } + + } + return response; + } + + /// + /// Get the type fo request to be performed + /// + /// + public string method() + { + return this.requestMethod.ToString(); + } + + /// + /// returns the JSON encoded body object + /// + /// + public string body() + { + return this.requestBody.ToString(); + } + } +} diff --git a/Paysafe/Common/RequestConflictException.cs b/Paysafe/Common/RequestConflictException.cs new file mode 100644 index 0000000..c658090 --- /dev/null +++ b/Paysafe/Common/RequestConflictException.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class RequestConflictException : PaysafeException + { + public RequestConflictException() + : base() + { + + } + + public RequestConflictException(String message) + : base(message) + { + + } + + public RequestConflictException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/RequestDeclinedException.cs b/Paysafe/Common/RequestDeclinedException.cs new file mode 100644 index 0000000..21a8bdc --- /dev/null +++ b/Paysafe/Common/RequestDeclinedException.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + public class RequestDeclinedException : PaysafeException + { + public RequestDeclinedException() + : base() + { + + } + + public RequestDeclinedException(String message) + : base(message) + { + + } + + public RequestDeclinedException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/Paysafe/Common/Url.cs b/Paysafe/Common/Url.cs new file mode 100644 index 0000000..b3640b4 --- /dev/null +++ b/Paysafe/Common/Url.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.Common +{ + /// + /// Url will be used by JsonObject for validation + /// + public sealed class Url + { + } +} diff --git a/Paysafe/CustomerVault/ACHBankAccounts.cs b/Paysafe/CustomerVault/ACHBankAccounts.cs new file mode 100644 index 0000000..7e99704 --- /dev/null +++ b/Paysafe/CustomerVault/ACHBankAccounts.cs @@ -0,0 +1,449 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + //Created by Manjiri.Bankar on 03.05.2016. This is ACHBankAccounts class. + public class ACHBankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the ACHBankAccounts object with some set of properties + /// + /// Dictionary + public ACHBankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id,STRING_TYPE}, + {CustomerVaultConstants.nickName, STRING_TYPE}, + {CustomerVaultConstants.merchantRefNum, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.statusReason, STRING_TYPE}, + {CustomerVaultConstants.accountNumber, STRING_TYPE}, + {CustomerVaultConstants.accountHolderName, STRING_TYPE}, + {CustomerVaultConstants.routingNumber, STRING_TYPE}, + {CustomerVaultConstants.accountType, CustomerVaultConstants.enumAccountType}, + {CustomerVaultConstants.lastDigits, STRING_TYPE}, + {CustomerVaultConstants.billingAddressId, STRING_TYPE}, + {CustomerVaultConstants.paymentToken,STRING_TYPE}, + {CustomerVaultConstants.profileId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the nickName + /// + /// string + public string nickName() + { + return this.getProperty(CustomerVaultConstants.nickName); + } + + /// + /// Set the nickName + /// + /// void + public void nickName(string data) + { + this.setProperty(CustomerVaultConstants.nickName, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CustomerVaultConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CustomerVaultConstants.merchantRefNum, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the statusReason + /// + /// string + public string statusReason() + { + return this.getProperty(CustomerVaultConstants.statusReason); + } + + /// + /// Set the statusReason + /// + /// void + public void statusReason(string data) + { + this.setProperty(CustomerVaultConstants.statusReason, data); + } + + /// + /// Get the accountNumber + /// + /// string + public string accountNumber() + { + return this.getProperty(CustomerVaultConstants.accountNumber); + } + + /// + /// Set the accountNumber + /// + /// void + public void accountNumber(string data) + { + this.setProperty(CustomerVaultConstants.accountNumber, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(CustomerVaultConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(CustomerVaultConstants.accountHolderName, data); + } + + /// + /// Get the routingNumber + /// + /// string + public string routingNumber() + { + return this.getProperty(CustomerVaultConstants.routingNumber); + } + + /// + /// Set the routingNumber + /// + /// void + public void routingNumber(string data) + { + this.setProperty(CustomerVaultConstants.routingNumber, data); + } + + /// + /// Get the accountType + /// + /// string + public string accountType() + { + return this.getProperty(CustomerVaultConstants.accountType); + } + + /// + /// Set the accountType + /// + /// void + public void accountType(string data) + { + this.setProperty(CustomerVaultConstants.accountType, data); + } + + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(CustomerVaultConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(CustomerVaultConstants.lastDigits, data); + } + + /// + /// Get the billingAddressId + /// + /// string + public string billingAddressId() + { + return this.getProperty(CustomerVaultConstants.billingAddressId); + } + + /// + /// Set the billingAddressId + /// + /// void + public void billingAddressId(string data) + { + this.setProperty(CustomerVaultConstants.billingAddressId, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the profileId + /// + /// String + public String profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(String data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + public static ACHAccountBuilder Builder() + { + return new ACHAccountBuilder(); + } + + /// + /// ACHAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated ACHAccount object + /// + public class ACHAccountBuilder : BaseJSONBuilder + { + + /// + /// Set the id parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the nickName parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder merchantRefNum(string data) + { + this.properties[CustomerVaultConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder status(string data) + { + this.properties[CustomerVaultConstants.status] = data; + return this; + } + + /// + /// Set the statusReason parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder statusReason(string data) + { + this.properties[CustomerVaultConstants.statusReason] = data; + return this; + } + + /// + /// Set the accountNumber parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder accountNumber(string data) + { + this.properties[CustomerVaultConstants.accountNumber] = data; + return this; + } + + /// + /// Set the accountHolderName parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder accountHolderName(string data) + { + this.properties[CustomerVaultConstants.accountHolderName] = data; + return this; + } + + /// + /// Set the routingNumber parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder routingNumber(string data) + { + this.properties[CustomerVaultConstants.routingNumber] = data; + return this; + } + + /// + /// Set the accountType parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder accountType(string data) + { + this.properties[CustomerVaultConstants.accountType] = data; + return this; + } + + /// + /// Set the lastDigits parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder lastDigits(string data) + { + this.properties[CustomerVaultConstants.lastDigits] = data; + return this; + } + + /// + /// Set the billingAddressId parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder billingAddressId(string data) + { + this.properties[CustomerVaultConstants.billingAddressId] = data; + return this; + } + + /// + /// Set the paymentToken parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder paymentToken(string data) + { + this.properties[CustomerVaultConstants.paymentToken] = data; + return this; + } + + /// + /// Set the profileId parameter + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + } + + } +} diff --git a/Paysafe/CustomerVault/Address.cs b/Paysafe/CustomerVault/Address.cs new file mode 100644 index 0000000..f45544d --- /dev/null +++ b/Paysafe/CustomerVault/Address.cs @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + public class Address : AddressDetails + { + /// + /// Initialize the Address object with some set of properties + /// + /// Dictionary + public Address(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary(addressFieldTypes) + { + {CustomerVaultConstants.id, STRING_TYPE}, + {CustomerVaultConstants.nickName, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.recipientName, STRING_TYPE}, + {CustomerVaultConstants.defaultShippingAddressIndicator, BOOL_TYPE}, + {CustomerVaultConstants.error, typeof(OptError)}, + {CustomerVaultConstants.links, typeof(List)}, + {CustomerVaultConstants.profileId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the nickName + /// + /// string + public string nickName() + { + return this.getProperty(CustomerVaultConstants.nickName); + } + + /// + /// Set the nickName + /// + /// void + public void nickName(string data) + { + this.setProperty(CustomerVaultConstants.nickName, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the recipientName + /// + /// string + public string recipientName() + { + return this.getProperty(CustomerVaultConstants.recipientName); + } + + /// + /// Set the recipientName + /// + /// void + public void recipientName(string data) + { + this.setProperty(CustomerVaultConstants.recipientName, data); + } + + /// + /// Get the defaultShippingAddressIndicator + /// + /// bool + public string defaultShippingAddressIndicator() + { + return this.getProperty(CustomerVaultConstants.defaultShippingAddressIndicator); + } + + /// + /// Set the defaultShippingAddressIndicator + /// + /// bool + public void defaultShippingAddressIndicator(bool data) + { + this.setProperty(CustomerVaultConstants.defaultShippingAddressIndicator, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(CustomerVaultConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CustomerVaultConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CustomerVaultConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CustomerVaultConstants.links, data); + } + + /// + /// Get the profileId + /// + /// string + public string profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(string data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + public static AddressBuilder Builder() + { + return new AddressBuilder(); + } + + /// + /// AddressBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Address object + /// + public class AddressBuilder : BaseJSONBuilder
+ { + /// + /// Set the profileId parameter + /// + /// string + /// AddressBuilder + public AddressBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the profileId parameter + /// + /// string + /// AddressBuilder + public AddressBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + + /// + /// Set the country parameter + /// + /// string + /// AddressBuilder + public AddressBuilder country(string data) + { + this.properties[CustomerVaultConstants.country] = data; + return this; + } + + /// + /// Set the nickName parameter + /// + /// string + /// AddressBuilder + public AddressBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the street parameter + /// + /// string + /// AddressBuilder + public AddressBuilder street(string data) + { + this.properties[CustomerVaultConstants.street] = data; + return this; + } + + /// + /// Set the street2 parameter + /// + /// string + /// AddressBuilder + public AddressBuilder street2(string data) + { + this.properties[CustomerVaultConstants.street2] = data; + return this; + } + + /// + /// Set the city parameter + /// + /// string + /// AddressBuilder + public AddressBuilder city(string data) + { + this.properties[CustomerVaultConstants.city] = data; + return this; + } + + /// + /// Set the state parameter + /// + /// string + /// AddressBuilder + public AddressBuilder state(string data) + { + this.properties[CustomerVaultConstants.state] = data; + return this; + } + + /// + /// Set the zip parameter + /// + /// string + /// AddressBuilder + public AddressBuilder zip(string data) + { + this.properties[CustomerVaultConstants.zip] = data; + return this; + } + + /// + /// Set the recipientName parameter + /// + /// string + /// AddressBuilder + public AddressBuilder recipientName(string data) + { + this.properties[CustomerVaultConstants.recipientName] = data; + return this; + } + + /// + /// Set the phone parameter + /// + /// string + /// AddressBuilder + public AddressBuilder phone(string data) + { + this.properties[CustomerVaultConstants.phone] = data; + return this; + } + } + } +} diff --git a/Paysafe/CustomerVault/BACSBankAccounts.cs b/Paysafe/CustomerVault/BACSBankAccounts.cs new file mode 100644 index 0000000..66a28bb --- /dev/null +++ b/Paysafe/CustomerVault/BACSBankAccounts.cs @@ -0,0 +1,450 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + //Created by Manjiri.Bankar on 03.05.2016. This is BACSBankAccounts class. + public class BACSBankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the BACSBankAccounts object with some set of properties + /// + /// Dictionary + public BACSBankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id,STRING_TYPE}, + {CustomerVaultConstants.nickName, STRING_TYPE}, + {CustomerVaultConstants.merchantRefNum, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.statusReason, STRING_TYPE}, + {CustomerVaultConstants.accountNumber, STRING_TYPE}, + {CustomerVaultConstants.accountHolderName, STRING_TYPE}, + {CustomerVaultConstants.sortCode, STRING_TYPE}, + {CustomerVaultConstants.lastDigits, STRING_TYPE}, + {CustomerVaultConstants.billingAddressId, STRING_TYPE}, + {CustomerVaultConstants.paymentToken,STRING_TYPE}, + {CustomerVaultConstants.mandates,typeof(List)}, + {CustomerVaultConstants.profileId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the nickName + /// + /// string + public string nickName() + { + return this.getProperty(CustomerVaultConstants.nickName); + } + + /// + /// Set the nickName + /// + /// void + public void nickName(string data) + { + this.setProperty(CustomerVaultConstants.nickName, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CustomerVaultConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CustomerVaultConstants.merchantRefNum, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the statusReason + /// + /// string + public string statusReason() + { + return this.getProperty(CustomerVaultConstants.statusReason); + } + + /// + /// Set the statusReason + /// + /// void + public void statusReason(string data) + { + this.setProperty(CustomerVaultConstants.statusReason, data); + } + + /// + /// Get the accountNumber + /// + /// string + public string accountNumber() + { + return this.getProperty(CustomerVaultConstants.accountNumber); + } + + /// + /// Set the accountNumber + /// + /// void + public void accountNumber(string data) + { + this.setProperty(CustomerVaultConstants.accountNumber, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(CustomerVaultConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(CustomerVaultConstants.accountHolderName, data); + } + + /// + /// Get the sortCode + /// + /// string + public string sortCode() + { + return this.getProperty(CustomerVaultConstants.sortCode); + } + + /// + /// Set the sortCode + /// + /// void + public void sortCode(string data) + { + this.setProperty(CustomerVaultConstants.sortCode, data); + } + + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(CustomerVaultConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(CustomerVaultConstants.lastDigits, data); + } + + /// + /// Get the billingAddressId + /// + /// string + public string billingAddressId() + { + return this.getProperty(CustomerVaultConstants.billingAddressId); + } + + /// + /// Set the billingAddressId + /// + /// void + public void billingAddressId(string data) + { + this.setProperty(CustomerVaultConstants.billingAddressId, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the mandates + /// + /// List + public List mandates() + { + return this.getProperty(CustomerVaultConstants.mandates); + } + + /// + /// Set the mandates + /// + /// void + public void mandates(List data) + { + this.setProperty(CustomerVaultConstants.mandates, data); + } + + /// + /// Get the profileId + /// + /// String + public string profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(String data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + public static BACSAccountBuilder Builder() + { + return new BACSAccountBuilder(); + } + + /// + /// BACSAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated BACSAccount object + /// + public class BACSAccountBuilder : BaseJSONBuilder + { + + /// + /// Set the id parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the nickName parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder merchantRefNum(string data) + { + this.properties[CustomerVaultConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder status(string data) + { + this.properties[CustomerVaultConstants.status] = data; + return this; + } + + /// + /// Set the statusReason parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder statusReason(string data) + { + this.properties[CustomerVaultConstants.statusReason] = data; + return this; + } + + /// + /// Set the accountNumber parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder accountNumber(string data) + { + this.properties[CustomerVaultConstants.accountNumber] = data; + return this; + } + + /// + /// Set the accountHolderName parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder accountHolderName(string data) + { + this.properties[CustomerVaultConstants.accountHolderName] = data; + return this; + } + + /// + /// Set the sortCode parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder sortCode(string data) + { + this.properties[CustomerVaultConstants.sortCode] = data; + return this; + } + + /// + /// Set the lastDigits parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder lastDigits(string data) + { + this.properties[CustomerVaultConstants.lastDigits] = data; + return this; + } + + /// + /// Set the billingAddressId parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder billingAddressId(string data) + { + this.properties[CustomerVaultConstants.billingAddressId] = data; + return this; + } + + /// + /// Set the paymentToken parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder paymentToken(string data) + { + this.properties[CustomerVaultConstants.paymentToken] = data; + return this; + } + + + /// + /// Set the profileId parameter + /// + /// string + /// BACSAccountBuilder + public BACSAccountBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + + /// + /// Set the mandates parameter + /// + /// List + /// BACSAccountBuilder + public BACSAccountBuilder mandates(List data) + { + this.properties[CustomerVaultConstants.mandates] = data; + return this; + } + } + + } +} diff --git a/Paysafe/CustomerVault/BillingAddress.cs b/Paysafe/CustomerVault/BillingAddress.cs new file mode 100644 index 0000000..1c10f5e --- /dev/null +++ b/Paysafe/CustomerVault/BillingAddress.cs @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2014 Optimal Payments +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +* associated documentation files (the "Software"), to deal in the Software without restriction, +* including without limitation the rights to use, copy, modify, merge, publish, distribute, +* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; +namespace Paysafe.CustomerVault +{ + public class BillingAddress : AddressDetails + { + + private static new Dictionary fieldTypes = new Dictionary(addressFieldTypes); + + public BillingAddress(Dictionary properties) + : base(fieldTypes, properties) + { + } + + + /// + /// BillingAddressBuilder will allow a BillingAddress to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class BillingAddressBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the BillingDetails builder within the context of a parent builder + /// + /// TBLDR + public BillingAddressBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the nickName + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the street + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder street(string data) + { + this.properties[CustomerVaultConstants.street] = data; + return this; + } + + /// + /// Set the street2 + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder street2(string data) + { + this.properties[CustomerVaultConstants.street2] = data; + return this; + } + + /// + /// Set the city + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder city(string data) + { + this.properties[CustomerVaultConstants.city] = data; + return this; + } + + /// + /// Set the state + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder state(string data) + { + this.properties[CustomerVaultConstants.state] = data; + return this; + } + + /// + /// Set the country + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder country(string data) + { + this.properties[CustomerVaultConstants.country] = data; + return this; + } + + /// + /// Set the zip + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder zip(string data) + { + this.properties[CustomerVaultConstants.zip] = data; + return this; + } + + /// + /// Set the phone + /// + /// string + /// BillingAddressBuilder + public BillingAddressBuilder phone(string data) + { + this.properties[CustomerVaultConstants.phone] = data; + return this; + } + } + } +} diff --git a/Paysafe/CustomerVault/Card.cs b/Paysafe/CustomerVault/Card.cs new file mode 100644 index 0000000..01cf26f --- /dev/null +++ b/Paysafe/CustomerVault/Card.cs @@ -0,0 +1,744 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + public class Card : Paysafe.Common.JSONObject + { + /// + /// Initialize the Card object with some set of properties + /// + /// Dictionary + public Card(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id, STRING_TYPE}, + {CustomerVaultConstants.nickName, STRING_TYPE}, + {CustomerVaultConstants.singleUseToken, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.merchantRefNum, STRING_TYPE}, + {CustomerVaultConstants.holderName, STRING_TYPE}, + {CustomerVaultConstants.cardNum, STRING_TYPE}, + {CustomerVaultConstants.cardBin, STRING_TYPE}, + {CustomerVaultConstants.lastDigits, STRING_TYPE}, + {CustomerVaultConstants.cardExpiry, typeof(CardExpiry)}, + {CustomerVaultConstants.cardType, STRING_TYPE}, + {CustomerVaultConstants.billingAddressId, STRING_TYPE}, + {CustomerVaultConstants.defaultCardIndicator, BOOL_TYPE}, + {CustomerVaultConstants.paymentToken, STRING_TYPE}, + {CustomerVaultConstants.error, typeof(OptError)}, + {CustomerVaultConstants.links, typeof(List)}, + {CustomerVaultConstants.profileId, STRING_TYPE}, + {CustomerVaultConstants.billingAddress, typeof(BillingAddress)} + + }; + + /// + /// Get the id + /// + /// String + public String id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(String data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the singleUseToken + /// + /// String + public String singleUseToken() + { + return this.getProperty(CustomerVaultConstants.singleUseToken); + } + + /// + /// Set the singleUseToken + /// + /// void + public void singleUseToken(String data) + { + this.setProperty(CustomerVaultConstants.singleUseToken, data); + } + + /// + /// Get the nickName + /// + /// String + public String nickName() + { + return this.getProperty(CustomerVaultConstants.nickName); + } + + /// + /// Set the nickName + /// + /// void + public void nickName(String data) + { + this.setProperty(CustomerVaultConstants.nickName, data); + } + + /// + /// Get the status + /// + /// String + public String status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(String data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the merchantRefNum + /// + /// String + public String merchantRefNum() + { + return this.getProperty(CustomerVaultConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(String data) + { + this.setProperty(CustomerVaultConstants.merchantRefNum, data); + } + + /// + /// Get the holderName + /// + /// String + public String holderName() + { + return this.getProperty(CustomerVaultConstants.holderName); + } + + /// + /// Set the holderName + /// + /// void + public void holderName(String data) + { + this.setProperty(CustomerVaultConstants.holderName, data); + } + + /// + /// Get the cardNum + /// + /// String + public String cardNum() + { + return this.getProperty(CustomerVaultConstants.cardNum); + } + + /// + /// Set the cardNum + /// + /// void + public void cardNum(String data) + { + this.setProperty(CustomerVaultConstants.cardNum, data); + } + + /// + /// Get the cardBin + /// + /// String + public String cardBin() + { + return this.getProperty(CustomerVaultConstants.cardBin); + } + + /// + /// Set the cardBin + /// + /// void + public void cardBin(String data) + { + this.setProperty(CustomerVaultConstants.cardBin, data); + } + + /// + /// Get the lastDigits + /// + /// String + public String lastDigits() + { + return this.getProperty(CustomerVaultConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(String data) + { + this.setProperty(CustomerVaultConstants.lastDigits, data); + } + + /// + /// Get the cardExpiry + /// + /// CardExpiry + public CardExpiry cardExpiry() + { + return this.getProperty(CustomerVaultConstants.cardExpiry); + } + + /// + /// Set the cardExpiry + /// + /// void + public void cardExpiry(CardExpiry data) + { + this.setProperty(CustomerVaultConstants.cardExpiry, data); + } + + /// + /// Get the cardType + /// + /// String + public String cardType() + { + return this.getProperty(CustomerVaultConstants.cardType); + } + + /// + /// Set the cardType + /// + /// void + public void cardType(String data) + { + this.setProperty(CustomerVaultConstants.cardType, data); + } + + /// + /// Get the billingAddressId + /// + /// String + public String billingAddressId() + { + return this.getProperty(CustomerVaultConstants.billingAddressId); + } + + /// + /// Set the billingAddressId + /// + /// void + public void billingAddressId(String data) + { + this.setProperty(CustomerVaultConstants.billingAddressId, data); + } + + /// + /// Get the defaultCardIndicator + /// + /// bool + public bool defaultCardIndicator() + { + return this.getProperty(CustomerVaultConstants.defaultCardIndicator); + } + + /// + /// Set the defaultCardIndicator + /// + /// void + public void defaultCardIndicator(bool data) + { + this.setProperty(CustomerVaultConstants.defaultCardIndicator, data); + } + + /// + /// Get the paymentToken + /// + /// String + public String paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(String data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(CustomerVaultConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CustomerVaultConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CustomerVaultConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CustomerVaultConstants.links, data); + } + + /// + /// Get the profileId + /// + /// String + public String profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(String data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + /// + /// Get the billingAddress + /// + /// List + public BillingAddress billingAddress() + { + return this.getProperty(CustomerVaultConstants.billingAddress); + } + + /// + /// Set the billingAddress + /// + /// void + public void billingAddress(BillingAddress data) + { + this.setProperty(CustomerVaultConstants.billingAddress, data); + } + + public static CardBuilder Builder() + { + return new CardBuilder(); + } + + /// + /// CardBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Card object + /// + public class CardBuilder : BaseJSONBuilder + { + /// + /// Set the id parameter + /// + /// string + /// CardBuilder + public CardBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the profileId parameter + /// + /// string + /// CardBuilder + public CardBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + + /// + /// Set the cardNum parameter + /// + /// string + /// CardBuilder + public CardBuilder cardNum(string data) + { + this.properties[CustomerVaultConstants.cardNum] = data; + return this; + } + + /// + /// Build an cardExpiry object within this authorization. + /// + /// CardExpiry.CardExpiryBuilder + public CardExpiry.CardExpiryBuilder cardExpiry() + { + if (!this.properties.ContainsKey(CustomerVaultConstants.cardExpiry)) + { + this.properties[CustomerVaultConstants.cardExpiry] = new CardExpiry.CardExpiryBuilder(this); + } + return this.properties[CustomerVaultConstants.cardExpiry] as CardExpiry.CardExpiryBuilder; + } + + /// + /// Set the nickName parameter + /// + /// string + /// CardBuilder + public CardBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// CardBuilder + public CardBuilder merchantRefNum(string data) + { + this.properties[CustomerVaultConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the holderName parameter + /// + /// string + /// CardBuilder + public CardBuilder holderName(string data) + { + this.properties[CustomerVaultConstants.holderName] = data; + return this; + } + + /// + /// Set the billingAddressId parameter + /// + /// string + /// CardBuilder + public CardBuilder billingAddressId(string data) + { + this.properties[CustomerVaultConstants.billingAddressId] = data; + return this; + } + + /// + /// Build an cardExpiry object within this authorization. + /// + /// CardExpiry.CardExpiryBuilder + public BillingAddress.BillingAddressBuilder billingAddress() + { + if (!this.properties.ContainsKey(CustomerVaultConstants.billingAddress)) + { + this.properties[CustomerVaultConstants.billingAddress] = new BillingAddress.BillingAddressBuilder(this); + } + return this.properties[CustomerVaultConstants.billingAddress] as BillingAddress.BillingAddressBuilder; + } + } + + + /// + /// CardBuilder will allow an card to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back tot he parent builder + /// + public class CardBuilderSingelUse : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Card builder within the context of a parent builder + /// + /// TBLDR + public CardBuilderSingelUse(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the singelUseToken + /// + /// string + /// CardBuilder + + public CardBuilderSingelUse singleUseToken(String data) + { + this.properties[CustomerVaultConstants.singleUseToken] = data; + return this; + } + + /// + /// Set the id parameter + /// + /// string + /// CardBuilder + public CardBuilderSingelUse id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + + /// + /// Set the cardNum parameter + /// + /// string + /// CardBuilder + public CardBuilderSingelUse cardNum(string data) + { + this.properties[CustomerVaultConstants.cardNum] = data; + return this; + } + + /// + /// Build an cardExpiry object within this authorization. + /// + /// CardExpiry.CardExpiryBuilder + public CardExpiry.CardExpiryBuilder> cardExpiry() + { + if (!this.properties.ContainsKey(CustomerVaultConstants.cardExpiry)) + { + this.properties[CustomerVaultConstants.cardExpiry] = new CardExpiry.CardExpiryBuilder>(this); + } + return this.properties[CustomerVaultConstants.cardExpiry] as CardExpiry.CardExpiryBuilder>; + } + + /// + /// Set the nickName parameter + /// + /// string + /// CardBuilder + public CardBuilderSingelUse nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// CardBuilder + public CardBuilderSingelUse merchantRefNum(string data) + { + this.properties[CustomerVaultConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the holderName parameter + /// + /// string + /// CardBuilder + public CardBuilderSingelUse holderName(string data) + { + this.properties[CustomerVaultConstants.holderName] = data; + return this; + } + + /// + /// Set the billingAddressId parameter + /// + /// string + /// CardBuilder + public CardBuilderSingelUse billingAddressId(string data) + { + this.properties[CustomerVaultConstants.billingAddressId] = data; + return this; + } + + /// + /// Build an cardExpiry object within this authorization. + /// + /// CardExpiry.CardExpiryBuilder + public BillingAddress.BillingAddressBuilder> billingAddress() + { + if (!this.properties.ContainsKey(CustomerVaultConstants.billingAddress)) + { + this.properties[CustomerVaultConstants.billingAddress] = new BillingAddress.BillingAddressBuilder>(this); + } + return this.properties[CustomerVaultConstants.billingAddress] as BillingAddress.BillingAddressBuilder>; + } + + } + + + ///// + ///// CardBuilder will allow an card to be initialized + ///// within another builder. Set properties and subpropeties, then trigger .Done() to + ///// get back tot he parent builder + ///// + //public class CardBuilder1 : NestedJSONBuilder + // where TBLDR : GenericJSONBuilder + //{ + // /// + // /// Initialize the Card builder within the context of a parent builder + // /// + // /// TBLDR + // public CardBuilder1(TBLDR parent) + // : base(parent) + // { + // this.parent = parent; + // } + + + // /// + // /// Set the id parameter + // /// + // /// string + // /// CardBuilder + // public CardBuilder1 id(string data) + // { + // this.properties[CustomerVaultConstants.id] = data; + // return this; + // } + + + // /// + // /// Set the cardNum parameter + // /// + // /// string + // /// CardBuilder + // public CardBuilder1 cardNum(string data) + // { + // this.properties[CustomerVaultConstants.cardNum] = data; + // return this; + // } + + // /// + // /// Build an cardExpiry object within this authorization. + // /// + // /// CardExpiry.CardExpiryBuilder + // public CardExpiry.CardExpiryBuilder> cardExpiry() + // { + // if (!this.properties.ContainsKey(CustomerVaultConstants.cardExpiry)) + // { + // this.properties[CustomerVaultConstants.cardExpiry] = new CardExpiry.CardExpiryBuilder>(this); + // } + // return this.properties[CustomerVaultConstants.cardExpiry] as CardExpiry.CardExpiryBuilder>; + // } + + // /// + // /// Set the nickName parameter + // /// + // /// string + // /// CardBuilder + // public CardBuilder1 nickName(string data) + // { + // this.properties[CustomerVaultConstants.nickName] = data; + // return this; + // } + + // /// + // /// Set the merchantRefNum parameter + // /// + // /// string + // /// CardBuilder + // public CardBuilder1 merchantRefNum(string data) + // { + // this.properties[CustomerVaultConstants.merchantRefNum] = data; + // return this; + // } + + // /// + // /// Set the holderName parameter + // /// + // /// string + // /// CardBuilder + // public CardBuilder1 holderName(string data) + // { + // this.properties[CustomerVaultConstants.holderName] = data; + // return this; + // } + + // /// + // /// Set the billingAddressId parameter + // /// + // /// string + // /// CardBuilder + // public CardBuilder1 billingAddressId(string data) + // { + // this.properties[CustomerVaultConstants.billingAddressId] = data; + // return this; + // } + + // /// + // /// Build an cardExpiry object within this authorization. + // /// + // /// CardExpiry.CardExpiryBuilder + // public BillingAddress.BillingAddressBuilder> billingAddress() + // { + // if (!this.properties.ContainsKey(CustomerVaultConstants.billingAddress)) + // { + // this.properties[CustomerVaultConstants.billingAddress] = new BillingAddress.BillingAddressBuilder>(this); + // } + // return this.properties[CustomerVaultConstants.billingAddress] as BillingAddress.BillingAddressBuilder>; + // } + //} + + + } +} diff --git a/Paysafe/CustomerVault/CustomerVaultConstants.cs b/Paysafe/CustomerVault/CustomerVaultConstants.cs new file mode 100644 index 0000000..e206180 --- /dev/null +++ b/Paysafe/CustomerVault/CustomerVaultConstants.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.CustomerVault +{ + public class CustomerVaultConstants : Paysafe.Common.GlobalConstants + { + public static readonly List enumStatus = new List() { + statusInitial, + statusActive, + statusInvalid, + statusInactive, + statusPending, + statusDeclined, + statusBatched, + statusCancelled, + statusRejected, + statusDisputed + }; + + public static readonly List enumAccountType = new List + { + accountTypeChecking, + accountTypeLoan, + accountTypeSavings + }; + } +} diff --git a/Paysafe/CustomerVault/CustomerVaultService.cs b/Paysafe/CustomerVault/CustomerVaultService.cs new file mode 100644 index 0000000..a78b678 --- /dev/null +++ b/Paysafe/CustomerVault/CustomerVaultService.cs @@ -0,0 +1,1013 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; +using PaysafeApiClient = Paysafe.PaysafeApiClient; + +namespace Paysafe.CustomerVault +{ + public class CustomerVaultService + { + + /// + /// The api client, performs all http requests + /// + private PaysafeApiClient client; + + /// + /// The card payments api base uri + /// + private string uri = "customervault/v1"; + + /// + /// Initialize the card payments service with an client object + /// + /// PaysafeApiClient + public CustomerVaultService(PaysafeApiClient client) + { + this.client = client; + } + + /// + /// Check if the service is available + /// + /// true if successful + public Boolean monitor() + { + Request request = new Request(uri: "customervault/monitor"); + dynamic response = this.client.processRequest(request); + + return ("READY".Equals((string)(response[CustomerVaultConstants.status]))); + } + + /// + /// Create profile + /// + /// Profile + /// Profile + public Profile create(Profile profile) + { + profile.setRequiredFields(new List { + CustomerVaultConstants.merchantCustomerId, + CustomerVaultConstants.locale + }); + profile.setOptionalFields(new List { + CustomerVaultConstants.firstName, + CustomerVaultConstants.middleName, + CustomerVaultConstants.lastName, + CustomerVaultConstants.dateOfBirth, + CustomerVaultConstants.ip, + CustomerVaultConstants.gender, + CustomerVaultConstants.nationality, + CustomerVaultConstants.email, + CustomerVaultConstants.phone, + CustomerVaultConstants.cellPhone, + CustomerVaultConstants.card + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles"), + body: profile + ); + dynamic response = this.client.processRequest(request); + + return new Profile(response); + } + + /// + /// create address + /// + /// Address + /// Address + public Address create(Address address) + { + address.setRequiredFields(new List { CustomerVaultConstants.profileId }); + address.checkRequiredFields(); + address.setRequiredFields(new List { CustomerVaultConstants.country }); + address.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.street, + CustomerVaultConstants.street2, + CustomerVaultConstants.city, + CustomerVaultConstants.state, + CustomerVaultConstants.zip, + CustomerVaultConstants.recipientName, + CustomerVaultConstants.phone + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + address.profileId() + "/addresses"), + body: address + ); + + dynamic response = this.client.processRequest(request); + + Address returnVal = new Address(response); + returnVal.profileId(address.profileId()); + return returnVal; + } + + /// + /// Create card + /// + /// Card + /// Card + public Card create(Card card) + { + card.setRequiredFields(new List { CustomerVaultConstants.profileId }); + card.checkRequiredFields(); + card.setRequiredFields(new List { + CustomerVaultConstants.cardNum, + CustomerVaultConstants.cardExpiry + }); + card.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.holderName, + CustomerVaultConstants.billingAddressId + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + card.profileId() + "/cards"), + body: card + ); + + dynamic response = this.client.processRequest(request); + + Card returnVal = new Card(response); + returnVal.profileId(card.profileId()); + return returnVal; + } + + /// + /// Create ACHBankAccount + /// + /// ACHBankAccount + /// ACHBankAccount + public ACHBankAccounts create(ACHBankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setRequiredFields(new List { + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.accountNumber, + CustomerVaultConstants.routingNumber, + CustomerVaultConstants.billingAddressId, + CustomerVaultConstants.accountType, + }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + account.profileId() + "/achbankaccounts"), + body: account + ); + dynamic response = this.client.processRequest(request); + + ACHBankAccounts returnVal = new ACHBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Create BACSBankAccount + /// + /// BACSBankAccount + /// BACSBankAccount + public BACSBankAccounts create(BACSBankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setRequiredFields(new List { + CustomerVaultConstants.accountNumber, + CustomerVaultConstants.sortCode, + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.billingAddressId, + }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.mandates, + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + account.profileId() + "/bacsbankaccounts"), + body: account + ); + dynamic response = this.client.processRequest(request); + + BACSBankAccounts returnVal = new BACSBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Create EFTBankAccount + /// + /// EFTBankAccount + /// EFTBankAccount + public EFTBankAccounts create(EFTBankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setRequiredFields(new List { + CustomerVaultConstants.accountNumber, + CustomerVaultConstants.transitNumber, + CustomerVaultConstants.institutionId, + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.billingAddressId, + }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + account.profileId() + "/eftbankaccounts"), + body: account + ); + dynamic response = this.client.processRequest(request); + + EFTBankAccounts returnVal = new EFTBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + + /// + /// Create SEPABankAccount + /// + /// SEPABankAccount + /// SEPABankAccount + public SEPABankAccounts create(SEPABankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setRequiredFields(new List { + CustomerVaultConstants.iban, + CustomerVaultConstants.bic, + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.billingAddressId, + }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.mandates + }); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + account.profileId() + "/sepabankaccounts"), + body: account + ); + dynamic response = this.client.processRequest(request); + + SEPABankAccounts returnVal = new SEPABankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Create Mandates + /// + /// Mandates + /// Mandates + public Mandates create(Mandates account, string accountName) + { + account.setRequiredFields(new List { + CustomerVaultConstants.reference, + CustomerVaultConstants.profileId, + CustomerVaultConstants.bankAccountId + }); + + account.checkRequiredFields(); + + if (accountName.Equals("SEPA")) + accountName = "/sepabankaccounts/"; + else + accountName = "/bacsbankaccounts/"; + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/profiles/" + account.profileId() + accountName + account.bankAccountId() + "/mandates"), + body: account + ); + dynamic response = this.client.processRequest(request); + + Mandates returnVal = new Mandates(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// update Profile + /// + /// Profile + /// Profile + public Profile update(Profile profile) + { + profile.setRequiredFields(new List { CustomerVaultConstants.id }); + profile.checkRequiredFields(); + profile.setRequiredFields(new List { + CustomerVaultConstants.merchantCustomerId, + CustomerVaultConstants.locale + }); + profile.setOptionalFields(new List { + CustomerVaultConstants.firstName, + CustomerVaultConstants.middleName, + CustomerVaultConstants.lastName, + CustomerVaultConstants.dateOfBirth, + CustomerVaultConstants.ip, + CustomerVaultConstants.gender, + CustomerVaultConstants.nationality, + CustomerVaultConstants.email, + CustomerVaultConstants.phone, + CustomerVaultConstants.cellPhone + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + profile.id()), + body: profile + ); + + dynamic response = this.client.processRequest(request); + + return new Profile(response); + } + + /// + /// Update address + /// + /// Address + /// Address + public Address update(Address address) + { + address.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + address.checkRequiredFields(); + address.setRequiredFields(new List { CustomerVaultConstants.country }); + address.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.street, + CustomerVaultConstants.street2, + CustomerVaultConstants.city, + CustomerVaultConstants.state, + CustomerVaultConstants.zip, + CustomerVaultConstants.recipientName, + CustomerVaultConstants.phone + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + address.profileId() + "/addresses/" + address.id()), + body: address + ); + + dynamic response = this.client.processRequest(request); + + Address returnVal = new Address(response); + returnVal.profileId(address.profileId()); + return returnVal; + } + + /// + /// Update card + /// + /// Card + /// Card + public Card update(Card card) + { + card.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + card.checkRequiredFields(); + card.setRequiredFields(new List {}); + card.setOptionalFields(new List { + CustomerVaultConstants.cardExpiry, + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.holderName, + CustomerVaultConstants.billingAddressId + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + card.profileId() + "/cards/" + card.id()), + body: card + ); + + dynamic response = this.client.processRequest(request); + + Card returnVal = new Card(response); + returnVal.profileId(card.profileId()); + return returnVal; + } + + /// + /// update ACHBankAccount + /// + /// ACHBankAccount + /// ACHBankAccount + public ACHBankAccounts update(ACHBankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setRequiredFields(new List { + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.routingNumber, + CustomerVaultConstants.billingAddressId, + CustomerVaultConstants.accountType, + }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.accountNumber + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + account.profileId() + "/achbankaccounts/" + account.id()), + body: account + ); + dynamic response = this.client.processRequest(request); + + ACHBankAccounts returnVal = new ACHBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// update BACSBankAccount + /// + /// BACSBankAccount + /// BACSBankAccount + public BACSBankAccounts update(BACSBankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.accountNumber, + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.sortCode, + CustomerVaultConstants.billingAddressId, + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + account.profileId() + "/bacsbankaccounts/" + account.id()), + body: account + ); + dynamic response = this.client.processRequest(request); + + BACSBankAccounts returnVal = new BACSBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// update EFTBankAccount + /// + /// EFTBankAccount + /// EFTBankAccount + public EFTBankAccounts update(EFTBankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setRequiredFields(new List { + CustomerVaultConstants.transitNumber, + CustomerVaultConstants.institutionId, + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.billingAddressId + }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.accountNumber + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + account.profileId() + "/eftbankaccounts/" + account.id()), + body: account + ); + dynamic response = this.client.processRequest(request); + + EFTBankAccounts returnVal = new EFTBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// update SEPABankAccount + /// + /// SEPABankAccount + /// SEPABankAccount + public SEPABankAccounts update(SEPABankAccounts account) + { + account.setRequiredFields(new List { CustomerVaultConstants.profileId }); + account.checkRequiredFields(); + account.setOptionalFields(new List { + CustomerVaultConstants.nickName, + CustomerVaultConstants.merchantRefNum, + CustomerVaultConstants.accountHolderName, + CustomerVaultConstants.iban, + CustomerVaultConstants.bic, + CustomerVaultConstants.billingAddressId, + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + account.profileId() + "/sepabankaccounts/" + account.id()), + body: account + ); + dynamic response = this.client.processRequest(request); + + SEPABankAccounts returnVal = new SEPABankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// update Mandates + /// + /// Mandates + /// Mandates + public Mandates update(Mandates account) + { + account.setRequiredFields(new List { CustomerVaultConstants.status }); + account.checkRequiredFields(); + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI("/profiles/" + account.profileId() + "/mandates/" + account.id()), + body: account + ); + dynamic response = this.client.processRequest(request); + + Mandates returnVal = new Mandates(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// delete profile + /// + /// Profile + /// bool + public bool delete(Profile profile) + { + profile.setRequiredFields(new List { CustomerVaultConstants.id }); + profile.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + profile.id()) + ); + + this.client.processRequest(request); + + return true; + } + + /// + ///Delete address + /// + /// Address + /// bool + public bool delete(Address address) + { + address.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + address.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + address.profileId() + "/addresses/" + address.id()) + ); + + this.client.processRequest(request); + return true; + } + + /// + /// Delete card + /// + /// Card + /// bool + public bool delete(Card card) + { + card.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + card.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + card.profileId() + "/cards/" + card.id()), + body: card + ); + + this.client.processRequest(request); + + return true; + } + + /// + ///Delete ACHBankAccount + /// + /// ACHBankAccount + /// bool + public bool delete(ACHBankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + account.profileId() + "/achbankaccounts/" + account.id()) + ); + + this.client.processRequest(request); + return true; + } + + /// + ///Delete BACSBankAccount + /// + /// BACSBankAccount + /// bool + public bool delete(BACSBankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + account.profileId() + "/bacsbankaccounts/" + account.id()) + ); + + this.client.processRequest(request); + return true; + } + + /// + ///Delete EFTBankAccount + /// + /// EFTBankAccount + /// bool + public bool delete(EFTBankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + account.profileId() + "/eftbankaccounts/" + account.id()) + ); + + this.client.processRequest(request); + return true; + } + + + /// + ///Delete SEPABankAccount + /// + /// SEPABankAccount + /// bool + public bool delete(SEPABankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + account.profileId() + "/sepabankaccounts/" + account.id()) + ); + + this.client.processRequest(request); + return true; + } + + /// + ///Delete Mandates + /// + /// Mandates + /// bool + public bool delete(Mandates account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id, + CustomerVaultConstants.bankAccountId + }); + Request request = new Request( + method: RequestType.DELETE, + uri: this.prepareURI("/profiles/" + account.profileId() + "/mandates/" + account.id()) + ); + + this.client.processRequest(request); + return true; + } + + /// + /// get profile with subcomponents + /// + /// Profile + /// Profile + public Profile get(Profile profile, bool includeAddresses = false, bool includeCards = false, bool includeACHBankAccounts = false, + bool includeBACSBankAccounts = false, bool includeEFTBankAccounts = false, bool includeSEPABankAccounts = false) + { + profile.setRequiredFields(new List { CustomerVaultConstants.id }); + profile.checkRequiredFields(); + + Dictionary queryStr = new Dictionary(); + StringBuilder toInclude = new StringBuilder(); + if (includeAddresses) + { + toInclude.Append("addresses"); + } + if (includeCards) + { + if (toInclude.Length > 0) + { + toInclude.Append(","); + } + toInclude.Append("cards"); + } + if (includeACHBankAccounts) + { + if (toInclude.Length > 0) + { + toInclude.Append(","); + } + toInclude.Append("achbankaccounts"); + } + if (includeBACSBankAccounts) + { + if (toInclude.Length > 0) + { + toInclude.Append(","); + } + toInclude.Append("bacsbankaccounts"); + } + if (includeEFTBankAccounts) + { + if (toInclude.Length > 0) + { + toInclude.Append(","); + } + toInclude.Append("eftbankaccounts"); + } + if (includeSEPABankAccounts) + { + if (toInclude.Length > 0) + { + toInclude.Append(","); + } + toInclude.Append("sepabankaccounts"); + } + + queryStr.Add("fields", toInclude.ToString()); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + profile.id()), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Profile(response); + } + + /// + /// Get address + /// + /// Address + /// Address + public Address get(Address address) + { + address.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + address.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + address.profileId() + "/addresses/" + address.id()), + body: address + ); + + dynamic response = this.client.processRequest(request); + + Address returnVal = new Address(response); + returnVal.profileId(address.profileId()); + return returnVal; + } + + /// + /// Get card + /// + /// Card + /// Card + public Card get(Card card) + { + card.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + card.checkRequiredFields(); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + card.profileId() + "/cards/" + card.id()) + ); + + dynamic response = this.client.processRequest(request); + + Card returnVal = new Card(response); + returnVal.profileId(card.profileId()); + return returnVal; + } + + /// + /// Get ACHBankAccount + /// + /// ACHBankAccount + /// ACHBankAccount + public ACHBankAccounts get(ACHBankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + account.profileId() + "/achbankaccounts/" + account.id()) + ); + + dynamic response = this.client.processRequest(request); + + ACHBankAccounts returnVal = new ACHBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Get BACSBankAccount + /// + /// BACSBankAccount + /// BACSBankAccount + public BACSBankAccounts get(BACSBankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.profileId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + account.profileId() + "/bacsbankaccounts/" + account.id()) + ); + + dynamic response = this.client.processRequest(request); + + BACSBankAccounts returnVal = new BACSBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Get EFTBankAccount + /// + /// EFTBankAccount + /// EFTBankAccount + public EFTBankAccounts get(EFTBankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.billingAddressId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + account.profileId() + "/eftbankaccounts/" + account.id()) + ); + + dynamic response = this.client.processRequest(request); + + EFTBankAccounts returnVal = new EFTBankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Get SEPABankAccount + /// + /// SEPABankAccount + /// SEPABankAccount + public SEPABankAccounts get(SEPABankAccounts account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.billingAddressId, + CustomerVaultConstants.id + }); + account.checkRequiredFields(); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + account.profileId() + "/sepabankaccounts/" + account.id()) + ); + + dynamic response = this.client.processRequest(request); + + SEPABankAccounts returnVal = new SEPABankAccounts(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + /// + /// Get Mandates + /// + /// Mandates + /// Mandates + public Mandates get(Mandates account) + { + account.setRequiredFields(new List { + CustomerVaultConstants.id, + CustomerVaultConstants.profileId + }); + account.checkRequiredFields(); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI("/profiles/" + account.profileId() + "/mandates/" + account.id()) + ); + + dynamic response = this.client.processRequest(request); + + Mandates returnVal = new Mandates(response); + returnVal.profileId(account.profileId()); + return returnVal; + } + + private string prepareURI(string path) + { + return this.uri + path; + } + } +} diff --git a/Paysafe/CustomerVault/DateOfBirth.cs b/Paysafe/CustomerVault/DateOfBirth.cs new file mode 100644 index 0000000..98700f6 --- /dev/null +++ b/Paysafe/CustomerVault/DateOfBirth.cs @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json.Linq; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + public class DateOfBirth : RecipientDateOfBirth + { + /// + /// Initialize the Address object with some set of properties + /// + /// Dictionary + public DateOfBirth(Dictionary properties = null) + : base(properties) + { + } + + public DateOfBirth() + :base() + { + } + + /// + /// DateOfBirthBuilder will allow a DateOfBirth to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class DateOfBirthBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the DateOfBirth builder within the context of a parent builder + /// + /// TBLDR + public DateOfBirthBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the day + /// + /// int + /// DateOfBirthBuilder + public DateOfBirthBuilder day(int data) + { + this.properties[CustomerVaultConstants.day] = data; + return this; + } + + /// + /// Set the month + /// + /// int + /// DateOfBirthBuilder + public DateOfBirthBuilder month(int data) + { + this.properties[CustomerVaultConstants.month] = data; + return this; + } + + /// + /// Set the year + /// + /// int + /// DateOfBirthBuilder + public DateOfBirthBuilder year(int data) + { + this.properties[CustomerVaultConstants.year] = data; + return this; + } + } + } +} diff --git a/Paysafe/CustomerVault/EFTBankAccounts.cs b/Paysafe/CustomerVault/EFTBankAccounts.cs new file mode 100644 index 0000000..5922f5a --- /dev/null +++ b/Paysafe/CustomerVault/EFTBankAccounts.cs @@ -0,0 +1,448 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + //Created by Manjiri.Bankar on 03.05.2016. This is EFTBankAccounts class. + public class EFTBankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the EFTBankAccounts object with some set of properties + /// + /// Dictionary + public EFTBankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id,STRING_TYPE}, + {CustomerVaultConstants.nickName, STRING_TYPE}, + {CustomerVaultConstants.merchantRefNum, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.statusReason, STRING_TYPE}, + {CustomerVaultConstants.accountNumber, STRING_TYPE}, + {CustomerVaultConstants.accountHolderName, STRING_TYPE}, + {CustomerVaultConstants.transitNumber, STRING_TYPE}, + {CustomerVaultConstants.institutionId, STRING_TYPE}, + {CustomerVaultConstants.lastDigits, STRING_TYPE}, + {CustomerVaultConstants.billingAddressId, STRING_TYPE}, + {CustomerVaultConstants.paymentToken,STRING_TYPE}, + {CustomerVaultConstants.profileId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the nickName + /// + /// string + public string nickName() + { + return this.getProperty(CustomerVaultConstants.nickName); + } + + /// + /// Set the nickName + /// + /// void + public void nickName(string data) + { + this.setProperty(CustomerVaultConstants.nickName, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CustomerVaultConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CustomerVaultConstants.merchantRefNum, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the statusReason + /// + /// string + public string statusReason() + { + return this.getProperty(CustomerVaultConstants.statusReason); + } + + /// + /// Set the statusReason + /// + /// void + public void statusReason(string data) + { + this.setProperty(CustomerVaultConstants.statusReason, data); + } + + /// + /// Get the accountNumber + /// + /// string + public string accountNumber() + { + return this.getProperty(CustomerVaultConstants.accountNumber); + } + + /// + /// Set the accountNumber + /// + /// void + public void accountNumber(string data) + { + this.setProperty(CustomerVaultConstants.accountNumber, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(CustomerVaultConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(CustomerVaultConstants.accountHolderName, data); + } + + /// + /// Get the transitNumber + /// + /// string + public string transitNumber() + { + return this.getProperty(CustomerVaultConstants.sortCode); + } + + /// + /// Set the transitNumber + /// + /// void + public void transitNumber(string data) + { + this.setProperty(CustomerVaultConstants.sortCode, data); + } + + /// + /// Get the institutionId + /// + /// string + public string institutionId() + { + return this.getProperty(CustomerVaultConstants.sortCode); + } + + /// + /// Set the institutionId + /// + /// void + public void institutionId(string data) + { + this.setProperty(CustomerVaultConstants.sortCode, data); + } + + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(CustomerVaultConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(CustomerVaultConstants.lastDigits, data); + } + + /// + /// Get the billingAddressId + /// + /// string + public string billingAddressId() + { + return this.getProperty(CustomerVaultConstants.billingAddressId); + } + + /// + /// Set the billingAddressId + /// + /// void + public void billingAddressId(string data) + { + this.setProperty(CustomerVaultConstants.billingAddressId, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the profileId + /// + /// String + public String profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(String data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + public static EFTAccountBuilder Builder() + { + return new EFTAccountBuilder(); + } + + /// + /// EFTAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated EFTAccount object + /// + public class EFTAccountBuilder : BaseJSONBuilder + { + /// + /// Set the id parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the nickName parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder merchantRefNum(string data) + { + this.properties[CustomerVaultConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder status(string data) + { + this.properties[CustomerVaultConstants.status] = data; + return this; + } + + /// + /// Set the statusReason parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder statusReason(string data) + { + this.properties[CustomerVaultConstants.statusReason] = data; + return this; + } + + /// + /// Set the accountNumber parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder accountNumber(string data) + { + this.properties[CustomerVaultConstants.accountNumber] = data; + return this; + } + + /// + /// Set the accountHolderName parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder accountHolderName(string data) + { + this.properties[CustomerVaultConstants.accountHolderName] = data; + return this; + } + + /// + /// Set the transitNumber parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder transitNumber(string data) + { + this.properties[CustomerVaultConstants.transitNumber] = data; + return this; + } + + /// + /// Set the institutionId parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder institutionId(string data) + { + this.properties[CustomerVaultConstants.institutionId] = data; + return this; + } + + /// + /// Set the lastDigits parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder lastDigits(string data) + { + this.properties[CustomerVaultConstants.lastDigits] = data; + return this; + } + + /// + /// Set the billingAddressId parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder billingAddressId(string data) + { + this.properties[CustomerVaultConstants.billingAddressId] = data; + return this; + } + + /// + /// Set the paymentToken parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder paymentToken(string data) + { + this.properties[CustomerVaultConstants.paymentToken] = data; + return this; + } + + + /// + /// Set the profileId parameter + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + } + } +} diff --git a/Paysafe/CustomerVault/Mandates.cs b/Paysafe/CustomerVault/Mandates.cs new file mode 100644 index 0000000..9436a05 --- /dev/null +++ b/Paysafe/CustomerVault/Mandates.cs @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + //Created by Manjiri.Bankar on 03.05.2016. This is Mandates class. + public class Mandates : Paysafe.Common.JSONObject + { + /// + /// Initialize the Mandates object with some set of properties + /// + /// Dictionary + public Mandates(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id,STRING_TYPE}, + {CustomerVaultConstants.reference, STRING_TYPE}, + {CustomerVaultConstants.bankAccountId, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.statusChangeDate,typeof(DateTime)}, + {CustomerVaultConstants.statusReasonCode, STRING_TYPE}, + {CustomerVaultConstants.statusReason, STRING_TYPE}, + {CustomerVaultConstants.paymentToken,STRING_TYPE}, + {CustomerVaultConstants.profileId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the reference + /// + /// reference + public string reference() + { + return this.getProperty(CustomerVaultConstants.reference); + } + + /// + /// Set the reference + /// + /// void + public void reference(string data) + { + this.setProperty(CustomerVaultConstants.reference, data); + } + + /// + /// Get the bankAccountId + /// + /// string + public string bankAccountId() + { + return this.getProperty(CustomerVaultConstants.bankAccountId); + } + + /// + /// Set the bankAccountId + /// + /// void + public void bankAccountId(string data) + { + this.setProperty(CustomerVaultConstants.bankAccountId, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the statusChangeDate + /// + /// string + public DateTime statusChangeDate() + { + return this.getProperty(CustomerVaultConstants.statusChangeDate); + } + + /// + /// Set the statusChangeDate + /// + /// void + public void statusChangeDate(DateTime data) + { + this.setProperty(CustomerVaultConstants.statusChangeDate, data); + } + + /// + /// Get the statusReasonCode + /// + /// string + public string statusReasonCode() + { + return this.getProperty(CustomerVaultConstants.statusReasonCode); + } + + /// + /// Set the statusReasonCode + /// + /// void + public void statusReasonCode(string data) + { + this.setProperty(CustomerVaultConstants.statusReasonCode, data); + } + + /// + /// Get the statusReason + /// + /// string + public string statusReason() + { + return this.getProperty(CustomerVaultConstants.statusReason); + } + + /// + /// Set the statusReason + /// + /// void + public void statusReason(string data) + { + this.setProperty(CustomerVaultConstants.statusReason, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the profileId + /// + /// String + public String profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(String data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + public static MandatesBuilder Builder() + { + return new MandatesBuilder(); + } + + /// + /// Mandates will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Profile object + /// + public class MandatesBuilder : BaseJSONBuilder + { + + /// + /// Set the id parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the reference parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder reference(string data) + { + this.properties[CustomerVaultConstants.reference] = data; + return this; + } + + /// + /// Set the bankAccountId parameter + /// + /// List + /// MandatesBuilder + public MandatesBuilder bankAccountId(string data) + { + this.properties[CustomerVaultConstants.bankAccountId] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder status(string data) + { + this.properties[CustomerVaultConstants.status] = data; + return this; + } + + /// + /// Set the statusReason parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder statusReason(string data) + { + this.properties[CustomerVaultConstants.statusReason] = data; + return this; + } + + /// + /// Set the statusChangeDate parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder statusChangeDate(DateTime data) + { + this.properties[CustomerVaultConstants.statusChangeDate] = data; + return this; + } + + /// + /// Set the statusReasonCode parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder statusReasonCode(string data) + { + this.properties[CustomerVaultConstants.statusReasonCode] = data; + return this; + } + + /// + /// Set the paymentToken parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder paymentToken(string data) + { + this.properties[CustomerVaultConstants.paymentToken] = data; + return this; + } + + + /// + /// Set the profileId parameter + /// + /// string + /// MandatesBuilder + public MandatesBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + } + + } +} diff --git a/Paysafe/CustomerVault/Profile.cs b/Paysafe/CustomerVault/Profile.cs new file mode 100644 index 0000000..6c790dc --- /dev/null +++ b/Paysafe/CustomerVault/Profile.cs @@ -0,0 +1,654 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + public class Profile : Paysafe.Common.JSONObject + { + /// + /// Initialize the Profile object with some set of properties + /// + /// Dictionary + public Profile(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.merchantCustomerId, STRING_TYPE}, + {CustomerVaultConstants.locale, CustomerVaultConstants.enumLocale}, + {CustomerVaultConstants.firstName, STRING_TYPE}, + {CustomerVaultConstants.middleName, STRING_TYPE}, + {CustomerVaultConstants.lastName, STRING_TYPE}, + {CustomerVaultConstants.dateOfBirth, typeof(DateOfBirth)}, + {CustomerVaultConstants.ip, STRING_TYPE}, + {CustomerVaultConstants.gender, CustomerVaultConstants.enumGender}, + {CustomerVaultConstants.nationality, STRING_TYPE}, + {CustomerVaultConstants.email, EMAIL_TYPE}, + {CustomerVaultConstants.phone, STRING_TYPE}, + {CustomerVaultConstants.cellPhone, STRING_TYPE}, + {CustomerVaultConstants.paymentToken, STRING_TYPE}, + {CustomerVaultConstants.addresses, typeof(List
)}, + {CustomerVaultConstants.cards, typeof(List)}, + {CustomerVaultConstants.error, typeof(OptError)}, + {CustomerVaultConstants.links, typeof(List)}, + {CustomerVaultConstants.card, typeof(Card)}, + {CustomerVaultConstants.achBankAccounts, typeof(List)}, + {CustomerVaultConstants.bacsBankAccounts, typeof(List)}, + {CustomerVaultConstants.sepaBankAccounts, typeof(List)}, + {CustomerVaultConstants.eftBankAccounts, typeof(List)} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the merchantCustomerId + /// + /// string + public string merchantCustomerId() + { + return this.getProperty(CustomerVaultConstants.merchantCustomerId); + } + + /// + /// Set the merchantCustomerId + /// + /// void + public void merchantCustomerId(string data) + { + this.setProperty(CustomerVaultConstants.merchantCustomerId, data); + } + + /// + /// Get the locale + /// + /// string + public string locale() + { + return this.getProperty(CustomerVaultConstants.locale); + } + + /// + /// Set the locale + /// + /// void + public void locale(string data) + { + this.setProperty(CustomerVaultConstants.locale, data); + } + + /// + /// Get the firstName + /// + /// string + public string firstName() + { + return this.getProperty(CustomerVaultConstants.firstName); + } + + /// + /// Set the firstName + /// + /// void + public void firstName(string data) + { + this.setProperty(CustomerVaultConstants.firstName, data); + } + + /// + /// Get the lastName + /// + /// string + public string lastName() + { + return this.getProperty(CustomerVaultConstants.lastName); + } + + /// + /// Set the lastName + /// + /// void + public void lastName(string data) + { + this.setProperty(CustomerVaultConstants.lastName, data); + } + + /// + /// Get the dateOfBirth + /// + /// DateOfBirth + public DateOfBirth dateOfBirth() + { + return this.getProperty(CustomerVaultConstants.dateOfBirth); + } + + /// + /// Set the dateOfBirth + /// + /// void + public void dateOfBirth(DateOfBirth data) + { + this.setProperty(CustomerVaultConstants.dateOfBirth, data); + } + + /// + /// Get the ip + /// + /// string + public string ip() + { + return this.getProperty(CustomerVaultConstants.ip); + } + + /// + /// Set the ip + /// + /// void + public void ip(string data) + { + this.setProperty(CustomerVaultConstants.ip, data); + } + + /// + /// Get the gender + /// + /// string + public string gender() + { + return this.getProperty(CustomerVaultConstants.gender); + } + + /// + /// Set the gender + /// + /// void + public void gender(string data) + { + this.setProperty(CustomerVaultConstants.gender, data); + } + + /// + /// Get the nationality + /// + /// string + public string nationality() + { + return this.getProperty(CustomerVaultConstants.nationality); + } + + /// + /// Set the nationality + /// + /// void + public void nationality(string data) + { + this.setProperty(CustomerVaultConstants.nationality, data); + } + + /// + /// Get the email + /// + /// string + public string email() + { + return this.getProperty(CustomerVaultConstants.email); + } + + /// + /// Set the email + /// + /// void + public void email(string data) + { + this.setProperty(CustomerVaultConstants.email, data); + } + + /// + /// Get the phone + /// + /// string + public string phone() + { + return this.getProperty(CustomerVaultConstants.phone); + } + + /// + /// Set the phone + /// + /// void + public void phone(string data) + { + this.setProperty(CustomerVaultConstants.phone, data); + } + + /// + /// Get the cellPhone + /// + /// string + public string cellPhone() + { + return this.getProperty(CustomerVaultConstants.cellPhone); + } + + /// + /// Set the cellPhone + /// + /// string + public void cellPhone(string data) + { + this.setProperty(CustomerVaultConstants.cellPhone, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the addresses + /// + /// List
+ public List
addresses() + { + return this.getProperty(CustomerVaultConstants.addresses); + } + + /// + /// Set the addresses + /// + /// void + public void addresses(List
data) + { + this.setProperty(CustomerVaultConstants.addresses, data); + } + + /// + /// Get the cards + /// + /// List + public List cards() + { + return this.getProperty(CustomerVaultConstants.cards); + } + + /// + /// Set the cards + /// + /// void + public void cards(List data) + { + this.setProperty(CustomerVaultConstants.cards, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(CustomerVaultConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(CustomerVaultConstants.error, data); + } + + /// + /// Get the links + /// + /// List + public List links() + { + return this.getProperty(CustomerVaultConstants.links); + } + + /// + /// Set the links + /// + /// void + public void links(List data) + { + this.setProperty(CustomerVaultConstants.links, data); + } + + + /// + /// Get the card + /// + /// Card + public Card card() + { + return this.getProperty(CustomerVaultConstants.card); + } + + /// + /// Set the card + /// + /// void + public void card(Card data) + { + this.setProperty(CustomerVaultConstants.card, data); + } + + + /// + /// Get the achBankAccounts + /// + /// List
+ public List achBankAccounts() + { + return this.getProperty(CustomerVaultConstants.achBankAccounts); + } + + /// + /// Set the achBankAccounts + /// + /// void + public void achBankAccounts(List data) + { + this.setProperty(CustomerVaultConstants.achBankAccounts, data); + } + + /// + /// Get the bacsBankAccounts + /// + /// List
+ public List bacsBankAccounts() + { + return this.getProperty(CustomerVaultConstants.bacsBankAccounts); + } + + /// + /// Set the bacsBankAccounts + /// + /// void + public void bacsBankAccounts(List data) + { + this.setProperty(CustomerVaultConstants.bacsBankAccounts, data); + } + /// + /// Get the sepaBankAccounts + /// + /// List
+ public List sepaBankAccounts() + { + return this.getProperty(CustomerVaultConstants.sepaBankAccounts); + } + + /// + /// Set the sepaBankAccounts + /// + /// void + public void sepaBankAccounts(List data) + { + this.setProperty(CustomerVaultConstants.sepaBankAccounts, data); + } + /// + /// Get the eftBankAccounts + /// + /// List
+ public List eftBankAccounts() + { + return this.getProperty(CustomerVaultConstants.eftBankAccounts); + } + + /// + /// Set the eftBankAccounts + /// + /// void + public void eftBankAccounts(List data) + { + this.setProperty(CustomerVaultConstants.eftBankAccounts, data); + } + + public static ProfileBuilder Builder() + { + return new ProfileBuilder(); + } + + /// + /// ProfileBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Profile object + /// + public class ProfileBuilder : BaseJSONBuilder + { + + /// + /// Set the id parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the merchantCustomerId parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder merchantCustomerId(string data) + { + this.properties[CustomerVaultConstants.merchantCustomerId] = data; + return this; + } + + /// + /// Set the locale parameter + /// + /// List + /// ProfileBuilder + public ProfileBuilder locale(string data) + { + this.properties[CustomerVaultConstants.locale] = data; + return this; + } + + /// + /// Set the firstName parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder firstName(string data) + { + this.properties[CustomerVaultConstants.firstName] = data; + return this; + } + + /// + /// Set the middleName parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder middleName(string data) + { + this.properties[CustomerVaultConstants.middleName] = data; + return this; + } + + /// + /// Set the lastName parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder lastName(string data) + { + this.properties[CustomerVaultConstants.lastName] = data; + return this; + } + + /// + /// Build a dateOfBirth within this authorization. + /// + /// DateOfBirth.DateOfBirthBuilder + public DateOfBirth.DateOfBirthBuilder dateOfBirth() + { + if (!this.properties.ContainsKey(CustomerVaultConstants.dateOfBirth)) + { + this.properties[CustomerVaultConstants.dateOfBirth] = new DateOfBirth.DateOfBirthBuilder(this); + } + return this.properties[CustomerVaultConstants.dateOfBirth] as DateOfBirth.DateOfBirthBuilder; + } + + /// + /// Set the ip parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder ip(string data) + { + this.properties[CustomerVaultConstants.ip] = data; + return this; + } + + /// + /// Set the gender parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder gender(string data) + { + this.properties[CustomerVaultConstants.gender] = data; + return this; + } + + /// + /// Set the nationality parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder nationality(string data) + { + this.properties[CustomerVaultConstants.nationality] = data; + return this; + } + + /// + /// Set the email parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder email(string data) + { + this.properties[CustomerVaultConstants.email] = data; + return this; + } + + /// + /// Set the phone parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder phone(string data) + { + this.properties[CustomerVaultConstants.phone] = data; + return this; + } + + /// + /// Set the cellPhone parameter + /// + /// string + /// ProfileBuilder + public ProfileBuilder cellPhone(string data) + { + this.properties[CustomerVaultConstants.cellPhone] = data; + return this; + } + + /// + /// Build a card object within this Profile. + /// + /// Profile.profileBuilder + public Card.CardBuilderSingelUse card() + { + if (!this.properties.ContainsKey(CustomerVaultConstants.card)) + { + this.properties[CustomerVaultConstants.card] = new Card.CardBuilderSingelUse(this); + } + return this.properties[CustomerVaultConstants.card] as Card.CardBuilderSingelUse; + } + + } + } +} diff --git a/Paysafe/CustomerVault/SEPABankAccounts.cs b/Paysafe/CustomerVault/SEPABankAccounts.cs new file mode 100644 index 0000000..4f36324 --- /dev/null +++ b/Paysafe/CustomerVault/SEPABankAccounts.cs @@ -0,0 +1,508 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.CustomerVault +{ + //Created by Manjiri.Bankar on 03.05.2016. This is SEPABankAccounts class. + public class SEPABankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the SEPABankAccounts object with some set of properties + /// + /// Dictionary + public SEPABankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {CustomerVaultConstants.id,STRING_TYPE}, + {CustomerVaultConstants.nickName, STRING_TYPE}, + {CustomerVaultConstants.merchantRefNum, STRING_TYPE}, + {CustomerVaultConstants.status, CustomerVaultConstants.enumStatus}, + {CustomerVaultConstants.statusReason, STRING_TYPE}, + {CustomerVaultConstants.accountHolderName, STRING_TYPE}, + {CustomerVaultConstants.iban, STRING_TYPE}, + {CustomerVaultConstants.bic, STRING_TYPE}, + {CustomerVaultConstants.lastDigits, STRING_TYPE}, + {CustomerVaultConstants.billingAddressId, STRING_TYPE}, + {CustomerVaultConstants.paymentToken,STRING_TYPE}, + {CustomerVaultConstants.mandates,typeof(List)}, + {CustomerVaultConstants.profileId, STRING_TYPE} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(CustomerVaultConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(CustomerVaultConstants.id, data); + } + + /// + /// Get the nickName + /// + /// string + public string nickName() + { + return this.getProperty(CustomerVaultConstants.nickName); + } + + /// + /// Set the nickName + /// + /// void + public void nickName(string data) + { + this.setProperty(CustomerVaultConstants.nickName, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(CustomerVaultConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(CustomerVaultConstants.merchantRefNum, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(CustomerVaultConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(CustomerVaultConstants.status, data); + } + + /// + /// Get the statusReason + /// + /// string + public string statusReason() + { + return this.getProperty(CustomerVaultConstants.statusReason); + } + + /// + /// Set the statusReason + /// + /// void + public void statusReason(string data) + { + this.setProperty(CustomerVaultConstants.statusReason, data); + } + + /// + /// Get the iban + /// + /// string + public string iban() + { + return this.getProperty(CustomerVaultConstants.iban); + } + + /// + /// Set the iban + /// + /// void + public void iban(string data) + { + this.setProperty(CustomerVaultConstants.iban, data); + } + + /// + /// Get the bic + /// + /// string + public string bic() + { + return this.getProperty(CustomerVaultConstants.bic); + } + + /// + /// Set the bic + /// + /// void + public void bic(string data) + { + this.setProperty(CustomerVaultConstants.bic, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(CustomerVaultConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(CustomerVaultConstants.accountHolderName, data); + } + + /// + /// Get the transitNumber + /// + /// string + public string transitNumber() + { + return this.getProperty(CustomerVaultConstants.sortCode); + } + + /// + /// Set the transitNumber + /// + /// void + public void transitNumber(string data) + { + this.setProperty(CustomerVaultConstants.sortCode, data); + } + + /// + /// Get the institutionId + /// + /// string + public string institutionId() + { + return this.getProperty(CustomerVaultConstants.sortCode); + } + + /// + /// Set the institutionId + /// + /// void + public void institutionId(string data) + { + this.setProperty(CustomerVaultConstants.sortCode, data); + } + + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(CustomerVaultConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(CustomerVaultConstants.lastDigits, data); + } + + /// + /// Get the billingAddressId + /// + /// string + public string billingAddressId() + { + return this.getProperty(CustomerVaultConstants.billingAddressId); + } + + /// + /// Set the billingAddressId + /// + /// void + public void billingAddressId(string data) + { + this.setProperty(CustomerVaultConstants.billingAddressId, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(CustomerVaultConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(CustomerVaultConstants.paymentToken, data); + } + + /// + /// Get the mandates + /// + /// List + public List mandates() + { + return this.getProperty(CustomerVaultConstants.mandates); + } + + /// + /// Set the mandates + /// + /// void + public void mandates(List data) + { + this.setProperty(CustomerVaultConstants.mandates, data); + } + + /// + /// Get the profileId + /// + /// String + public String profileId() + { + return this.getProperty(CustomerVaultConstants.profileId); + } + + /// + /// Set the profileId + /// + /// void + public void profileId(String data) + { + this.setProperty(CustomerVaultConstants.profileId, data); + } + + public static SEPAAccountBuilder Builder() + { + return new SEPAAccountBuilder(); + } + + /// + /// SEPAAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated SEPAAccount object + /// + public class SEPAAccountBuilder : BaseJSONBuilder + { + /// + /// Set the id parameterz + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder id(string data) + { + this.properties[CustomerVaultConstants.id] = data; + return this; + } + + /// + /// Set the nickName parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder nickName(string data) + { + this.properties[CustomerVaultConstants.nickName] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder merchantRefNum(string data) + { + this.properties[CustomerVaultConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder status(string data) + { + this.properties[CustomerVaultConstants.status] = data; + return this; + } + + /// + /// Set the statusReason parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder statusReason(string data) + { + this.properties[CustomerVaultConstants.statusReason] = data; + return this; + } + + /// + /// Set the iban parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder iban(string data) + { + this.properties[CustomerVaultConstants.iban] = data; + return this; + } + + /// + /// Set the bic parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder bic(string data) + { + this.properties[CustomerVaultConstants.bic] = data; + return this; + } + + /// + /// Set the accountHolderName parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder accountHolderName(string data) + { + this.properties[CustomerVaultConstants.accountHolderName] = data; + return this; + } + + /// + /// Set the transitNumber parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder transitNumber(string data) + { + this.properties[CustomerVaultConstants.transitNumber] = data; + return this; + } + + /// + /// Set the institutionId parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder institutionId(string data) + { + this.properties[CustomerVaultConstants.institutionId] = data; + return this; + } + + /// + /// Set the lastDigits parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder lastDigits(string data) + { + this.properties[CustomerVaultConstants.lastDigits] = data; + return this; + } + + /// + /// Set the billingAddressId parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder billingAddressId(string data) + { + this.properties[CustomerVaultConstants.billingAddressId] = data; + return this; + } + + /// + /// Set the paymentToken parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder paymentToken(string data) + { + this.properties[CustomerVaultConstants.paymentToken] = data; + return this; + } + + /// + /// Set the profileId parameter + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder profileId(string data) + { + this.properties[CustomerVaultConstants.profileId] = data; + return this; + } + + /// + /// Set the mandates parameter + /// + /// List + /// SEPAAccountBuilder + public SEPAAccountBuilder mandates(List data) + { + + this.properties[CustomerVaultConstants.mandates] = data; + return this; + } + + + } + } +} diff --git a/Paysafe/DirectDebit/ACHBankAccounts.cs b/Paysafe/DirectDebit/ACHBankAccounts.cs new file mode 100644 index 0000000..727e6c8 --- /dev/null +++ b/Paysafe/DirectDebit/ACHBankAccounts.cs @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is ACHBankAccounts class. + public class ACHBankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the ACHBankAccounts object with some set of properties + /// + /// Dictionary + public ACHBankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.paymentToken,STRING_TYPE}, + {DirectDebitConstants.payMethod, DirectDebitConstants.enumPaymentType}, + {DirectDebitConstants.paymentDescriptor, STRING_TYPE}, + {DirectDebitConstants.accountHolderName, STRING_TYPE}, + {DirectDebitConstants.accountType, STRING_TYPE}, + {DirectDebitConstants.accountNumber, STRING_TYPE}, + {DirectDebitConstants.routingNumber, STRING_TYPE}, + {DirectDebitConstants.lastDigits, STRING_TYPE} + + }; + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(DirectDebitConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(DirectDebitConstants.paymentToken, data); + } + + /// + /// Get the payMethod + /// + /// string + public string payMethod() + { + return this.getProperty(DirectDebitConstants.payMethod); + } + + /// + /// Set the payMethod + /// + /// void + public void payMethod(string data) + { + this.setProperty(DirectDebitConstants.payMethod, data); + } + + /// + /// Get the paymentDescriptor + /// + /// string + public string paymentDescriptor() + { + return this.getProperty(DirectDebitConstants.paymentDescriptor); + } + + /// + /// Set the paymentDescriptor + /// + /// void + public void paymentDescriptor(string data) + { + this.setProperty(DirectDebitConstants.paymentDescriptor, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(DirectDebitConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(DirectDebitConstants.accountHolderName, data); + } + + /// + /// Get the accountType + /// + /// string + public string accountType() + { + return this.getProperty(DirectDebitConstants.accountType); + } + + /// + /// Set the accountType + /// + /// void + public void accountType(string data) + { + this.setProperty(DirectDebitConstants.accountType, data); + } + + /// + /// Get the accountNumber + /// + /// string + public string accountNumber() + { + return this.getProperty(DirectDebitConstants.accountNumber); + } + + /// + /// Set the accountNumber + /// + /// void + public void accountNumber(string data) + { + this.setProperty(DirectDebitConstants.accountNumber, data); + } + /// + /// Get the routingNumber + /// + /// string + public string routingNumber() + { + return this.getProperty(DirectDebitConstants.routingNumber); + } + + /// + /// Set the routingNumber + /// + /// void + public void routingNumber(string data) + { + this.setProperty(DirectDebitConstants.routingNumber, data); + } + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(DirectDebitConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(DirectDebitConstants.lastDigits, data); + } + + + /// + /// ACHAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated ACHAccoun object + /// + public class ACHAccountBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the ACHAccountBuilder builder within the context of a parent builder + /// + /// TBLDR + public ACHAccountBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the paymentToken + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder paymentToken(string data) + { + this.properties[DirectDebitConstants.paymentToken] = data; + return this; + } + + /// + /// Set the payMethod + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder payMethod(string data) + { + this.properties[DirectDebitConstants.payMethod] = data; + return this; + } + /// + /// Set the paymentDescriptor + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder paymentDescriptor(string data) + { + this.properties[DirectDebitConstants.paymentDescriptor] = data; + return this; + } + /// + /// Set the accountHolderName + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder accountHolderName(string data) + { + this.properties[DirectDebitConstants.accountHolderName] = data; + return this; + } + /// + /// Set the accountType + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder accountType(string data) + { + this.properties[DirectDebitConstants.accountType] = data; + return this; + } + /// + /// Set the accountNumber + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder accountNumber(string data) + { + this.properties[DirectDebitConstants.accountNumber] = data; + return this; + } + /// + /// Set the routingNumber + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder routingNumber(string data) + { + this.properties[DirectDebitConstants.routingNumber] = data; + return this; + } + /// + /// Set the lastDigits + /// + /// string + /// ACHAccountBuilder + public ACHAccountBuilder lastDigits(string data) + { + this.properties[DirectDebitConstants.lastDigits] = data; + return this; + } + + } + + } +} diff --git a/Paysafe/DirectDebit/BACSBankAccounts.cs b/Paysafe/DirectDebit/BACSBankAccounts.cs new file mode 100644 index 0000000..72784b0 --- /dev/null +++ b/Paysafe/DirectDebit/BACSBankAccounts.cs @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is BACSBankAccounts class. + public class BACSBankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the EFTBankAccounts object with some set of properties + /// + /// Dictionary + public BACSBankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.paymentToken,STRING_TYPE}, + {DirectDebitConstants.accountHolderName, STRING_TYPE}, + {DirectDebitConstants.sortCode, STRING_TYPE}, + {DirectDebitConstants.mandateReference, STRING_TYPE}, + {DirectDebitConstants.lastDigits, STRING_TYPE}, + {DirectDebitConstants.accountNumber, STRING_TYPE} + }; + + // + /// Get the accountNumber + /// + /// string + public string accountNumber() + { + return this.getProperty(DirectDebitConstants.accountNumber); + } + + /// + /// Set the accountNumber + /// + /// void + public void accountNumber(string data) + { + this.setProperty(DirectDebitConstants.accountNumber, data); + } + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(DirectDebitConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(DirectDebitConstants.paymentToken, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(DirectDebitConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(DirectDebitConstants.accountHolderName, data); + } + + /// + /// Get the sortCode + /// + /// string + public string sortCode() + { + return this.getProperty(DirectDebitConstants.sortCode); + } + + /// + /// Set the sortCode + /// + /// void + public void sortCode(string data) + { + this.setProperty(DirectDebitConstants.sortCode, data); + } + + /// + /// Get the mandateReference + /// + /// string + public string mandateReference() + { + return this.getProperty(DirectDebitConstants.mandateReference); + } + + /// + /// Set the mandateReference + /// + /// void + public void mandateReference(string data) + { + this.setProperty(DirectDebitConstants.mandateReference, data); + } + + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(DirectDebitConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(DirectDebitConstants.lastDigits, data); + } + + /// + /// BACSBankAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated BACSBankAccount object + /// + public class BACSBankAccountBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the BillingDetails builder within the context of a parent builder + /// + /// TBLDR + public BACSBankAccountBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the paymentToken + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder paymentToken(string data) + { + this.properties[DirectDebitConstants.paymentToken] = data; + return this; + } + + /// + /// Set the accountHolderName + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder accountHolderName(string data) + { + this.properties[DirectDebitConstants.accountHolderName] = data; + return this; + } + /// + /// Set the paymentDescriptor + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder paymentDescriptor(string data) + { + this.properties[DirectDebitConstants.paymentDescriptor] = data; + return this; + } + /// + /// Set the sortCode + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder sortCode(string data) + { + this.properties[DirectDebitConstants.sortCode] = data; + return this; + } + /// + /// Set the reference + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder mandateReference(string data) + { + this.properties[DirectDebitConstants.mandateReference] = data; + return this; + } + + /// + /// Set the lastDigits + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder lastDigits(string data) + { + this.properties[DirectDebitConstants.lastDigits] = data; + return this; + } + + /// + /// Set the accountNumber + /// + /// string + /// BACSBankAccountBuilder + public BACSBankAccountBuilder accountNumber(string data) + { + this.properties[DirectDebitConstants.accountNumber] = data; + return this; + } + } + } +} diff --git a/Paysafe/DirectDebit/BillingDetails.cs b/Paysafe/DirectDebit/BillingDetails.cs new file mode 100644 index 0000000..8a4c86f --- /dev/null +++ b/Paysafe/DirectDebit/BillingDetails.cs @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is BillingDetails class. + public class BillingDetails : AddressDetails + { + + private static new Dictionary fieldTypes = new Dictionary(addressFieldTypes); + + public BillingDetails(Dictionary properties) + : base(fieldTypes, properties) + { + } + + + /// + /// BillingDetailsBuilder will allow a BillingDetails to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class BillingDetailsBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the BillingDetails builder within the context of a parent builder + /// + /// TBLDR + public BillingDetailsBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the street + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder street(string data) + { + this.properties[DirectDebitConstants.street] = data; + return this; + } + + /// + /// Set the street2 + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder street2(string data) + { + this.properties[DirectDebitConstants.street2] = data; + return this; + } + + /// + /// Set the city + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder city(string data) + { + this.properties[DirectDebitConstants.city] = data; + return this; + } + + /// + /// Set the state + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder state(string data) + { + this.properties[DirectDebitConstants.state] = data; + return this; + } + + /// + /// Set the country + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder country(string data) + { + this.properties[DirectDebitConstants.country] = data; + return this; + } + + /// + /// Set the zip + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder zip(string data) + { + this.properties[DirectDebitConstants.zip] = data; + return this; + } + + /// + /// Set the phone + /// + /// string + /// BillingDetailsBuilder + public BillingDetailsBuilder phone(string data) + { + this.properties[DirectDebitConstants.phone] = data; + return this; + } + } + } +} \ No newline at end of file diff --git a/Paysafe/DirectDebit/DateOfBirth.cs b/Paysafe/DirectDebit/DateOfBirth.cs new file mode 100644 index 0000000..0604083 --- /dev/null +++ b/Paysafe/DirectDebit/DateOfBirth.cs @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Newtonsoft.Json.Linq; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is DateOfBirth class. + public class DateOfBirth : RecipientDateOfBirth + { + /// + /// Initialize the Address object with some set of properties + /// + /// Dictionary + public DateOfBirth(Dictionary properties = null) + : base(properties) + { + } + + public DateOfBirth() + : base() + { + } + + /// + /// DateOfBirthBuilder will allow a DateOfBirth to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class DateOfBirthBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the DateOfBirth builder within the context of a parent builder + /// + /// TBLDR + public DateOfBirthBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the day + /// + /// int + /// DateOfBirthBuilder + public DateOfBirthBuilder day(int data) + { + this.properties[DirectDebitConstants.day] = data; + return this; + } + + /// + /// Set the month + /// + /// int + /// DateOfBirthBuilder + public DateOfBirthBuilder month(int data) + { + this.properties[DirectDebitConstants.month] = data; + return this; + } + + /// + /// Set the year + /// + /// int + /// DateOfBirthBuilder + public DateOfBirthBuilder year(int data) + { + this.properties[DirectDebitConstants.year] = data; + return this; + } + } + } +} diff --git a/Paysafe/DirectDebit/DirectDebitConstants.cs b/Paysafe/DirectDebit/DirectDebitConstants.cs new file mode 100644 index 0000000..efeadc2 --- /dev/null +++ b/Paysafe/DirectDebit/DirectDebitConstants.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is DirectDebitConstants class. + class DirectDebitConstants : Paysafe.Common.GlobalConstants + { + public static readonly List enumStatus = new List() { + statusReceived, + statusPending, + statusProcessing, + statusCompleted, + statusFailed, + statusCancelled, + }; + + public static readonly List enumPaymentType = new List() { + WEB, + TEL, + PPD, + CCD, + }; + } +} diff --git a/Paysafe/DirectDebit/DirectDebitService.cs b/Paysafe/DirectDebit/DirectDebitService.cs new file mode 100644 index 0000000..63f64dd --- /dev/null +++ b/Paysafe/DirectDebit/DirectDebitService.cs @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; +using PaysafeApiClient = Paysafe.PaysafeApiClient; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is DirectDebitService class. + public class DirectDebitService + { + /// + /// The api client, performs all http requests + /// + private PaysafeApiClient client; + + /// + /// The direct debit api base uri + /// + private string uri = "directdebit/v1/accounts/"; + + /// + /// Initialize the direct debit service with an client object + /// + /// PaysafeApiClient + public DirectDebitService(PaysafeApiClient client) + { + this.client = client; + } + + /// + /// Check if the service is available + /// + /// true if successful + public Boolean monitor() + { + Request request = new Request(uri: "directdebit/monitor"); + dynamic response = this.client.processRequest(request); + + return ("READY".Equals((string)(response[DirectDebitConstants.status]))); + } + + /// + /// Create submit for Purchases + /// + /// submit + /// Purchases + public Purchases submit(Purchases purchases) + { + purchases.setRequiredFields(new List { + DirectDebitConstants.merchantRefNum, + DirectDebitConstants.amount, + }); + purchases.checkRequiredFields(); + purchases.setOptionalFields(new List { + DirectDebitConstants.customerIp, + DirectDebitConstants.dupCheck, + DirectDebitConstants.ach, + DirectDebitConstants.bacs, + DirectDebitConstants.eft, + DirectDebitConstants.sepa, + DirectDebitConstants.billingDetails, + DirectDebitConstants.profile + }); + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI(client.account() + "/purchases"), + body: purchases + ); + dynamic response = this.client.processRequest(request); + + return new Purchases(response); + } + + /// + /// Create submit for Standalone Credits + /// + /// submit + /// StandaloneCredits + public StandaloneCredits submit(StandaloneCredits standalonecredits) + { + standalonecredits.setRequiredFields(new List { + DirectDebitConstants.merchantRefNum, + DirectDebitConstants.amount, + }); + standalonecredits.checkRequiredFields(); + standalonecredits.setOptionalFields(new List { + DirectDebitConstants.customerIp, + DirectDebitConstants.dupCheck, + DirectDebitConstants.ach, + DirectDebitConstants.bacs, + DirectDebitConstants.eft, + DirectDebitConstants.billingDetails, + DirectDebitConstants.profile, + }); + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI(client.account() + "/standalonecredits"), + body: standalonecredits + ); + dynamic response = this.client.processRequest(request); + + return new StandaloneCredits(response); + } + + /// + /// Create cancel for Purchases + /// + /// cancel + /// Purchases + public Purchases cancel(Purchases purchases) + { + purchases.setRequiredFields(new List { + DirectDebitConstants.status, + DirectDebitConstants.id + }); + purchases.checkRequiredFields(); + purchases.setOptionalFields(new List{ + DirectDebitConstants.ach, + DirectDebitConstants.bacs, + DirectDebitConstants.eft, + DirectDebitConstants.sepa, + }); + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI(client.account() + "/purchases/" + purchases.id()), + body: purchases + ); + dynamic response = this.client.processRequest(request); + + Purchases returnVal = new Purchases(response); + returnVal.id(purchases.id()); + return returnVal; + } + + /// + /// Create cancel for Standalone Credits + /// + /// cancel + /// StandaloneCredits + public StandaloneCredits cancel(StandaloneCredits standalonecredits) + { + standalonecredits.setRequiredFields(new List { + DirectDebitConstants.status, + DirectDebitConstants.id + }); + standalonecredits.checkRequiredFields(); + standalonecredits.setOptionalFields(new List{ + DirectDebitConstants.ach, + DirectDebitConstants.bacs, + DirectDebitConstants.eft, + }); + + Request request = new Request( + method: RequestType.PUT, + uri: this.prepareURI(client.account() + "/standalonecredits/" + standalonecredits.id()), + body: standalonecredits + ); + dynamic response = this.client.processRequest(request); + + StandaloneCredits returnVal = new StandaloneCredits(response); + returnVal.id(standalonecredits.id()); + return returnVal; + } + + /// + /// Create get + /// + /// get + /// Purchases + public Purchases get(Purchases purchase) + { + purchase.setRequiredFields(new List { + DirectDebitConstants.id, + }); + purchase.checkRequiredFields(); + purchase.setOptionalFields(new List{ + DirectDebitConstants.ach, + DirectDebitConstants.bacs, + DirectDebitConstants.eft, + DirectDebitConstants.sepa, + }); + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI(client.account() + "/purchases/" + purchase.id()), + body: purchase + ); + dynamic response = this.client.processRequest(request); + + return new Purchases(response); + } + + /// + /// Get matching Purchases + /// + /// + /// + /// + public Pagerator getPurchase(Purchases purchases = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (purchases != null && !String.IsNullOrWhiteSpace(purchases.merchantRefNum())) + { + queryStr.Add("merchantRefNum", purchases.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI(client.account() + "/purchases"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(Purchases), response); + } + + /// + /// Create get + /// + /// get + /// StandaloneCredits + public StandaloneCredits get(StandaloneCredits standalonescredits) + { + standalonescredits.setRequiredFields(new List { + DirectDebitConstants.id, + }); + standalonescredits.checkRequiredFields(); + standalonescredits.setOptionalFields(new List{ + DirectDebitConstants.ach, + DirectDebitConstants.bacs, + DirectDebitConstants.eft, + }); + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI(client.account() + "/standalonecredits/" + standalonescredits.id()), + body: standalonescredits + ); + dynamic response = this.client.processRequest(request); + + return new StandaloneCredits(response); + } + + /// + /// Get matching StandaloneCredits + /// + /// + /// + /// + public Pagerator getStandaloneCredits(StandaloneCredits standalonescredits = null, Filter filter = null) + { + Dictionary queryStr = new Dictionary(); + if (standalonescredits != null && !String.IsNullOrWhiteSpace(standalonescredits.merchantRefNum())) + { + queryStr.Add("merchantRefNum", standalonescredits.merchantRefNum()); + } + if (filter != null) + { + if (filter.limit != null) + { + queryStr.Add("limit", filter.limit.ToString()); + } + if (filter.offset != null) + { + queryStr.Add("offset", filter.offset.ToString()); + } + if (!String.IsNullOrWhiteSpace(filter.startDate)) + { + queryStr.Add("startDate", filter.startDate); + } + if (!String.IsNullOrWhiteSpace(filter.endDate)) + { + queryStr.Add("endDate", filter.endDate); + } + } + + Request request = new Request( + method: RequestType.GET, + uri: this.prepareURI(client.account() + "/standalonecredits"), + queryString: queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Pagerator(this.client, typeof(StandaloneCredits), response); + } + + private string prepareURI(string path) + { + return this.uri + path; + } + } +} diff --git a/Paysafe/DirectDebit/EFTBankAccounts.cs b/Paysafe/DirectDebit/EFTBankAccounts.cs new file mode 100644 index 0000000..2a08258 --- /dev/null +++ b/Paysafe/DirectDebit/EFTBankAccounts.cs @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is EFTBankAccounts class. + public class EFTBankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the EFTBankAccounts object with some set of properties + /// + /// Dictionary + public EFTBankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.paymentToken,STRING_TYPE}, + {DirectDebitConstants.paymentDescriptor, STRING_TYPE}, + {DirectDebitConstants.accountHolderName, STRING_TYPE}, + {DirectDebitConstants.accountNumber, STRING_TYPE}, + {DirectDebitConstants.transitNumber, STRING_TYPE}, + {DirectDebitConstants.institutionId, STRING_TYPE}, + {DirectDebitConstants.lastDigits, STRING_TYPE} + }; + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(DirectDebitConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(DirectDebitConstants.paymentToken, data); + } + + /// + /// Get the paymentDescriptor + /// + /// string + public string paymentDescriptor() + { + return this.getProperty(DirectDebitConstants.paymentDescriptor); + } + + /// + /// Set the paymentDescriptor + /// + /// void + public void paymentDescriptor(string data) + { + this.setProperty(DirectDebitConstants.paymentDescriptor, data); + } + + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(DirectDebitConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(DirectDebitConstants.accountHolderName, data); + } + + /// + /// Get the accountNumber + /// + /// string + public string accountNumber() + { + return this.getProperty(DirectDebitConstants.accountNumber); + } + + /// + /// Set the accountNumber + /// + /// void + public void accountNumber(string data) + { + this.setProperty(DirectDebitConstants.accountNumber, data); + } + + /// + /// Get the transitNumber + /// + /// string + public string transitNumber() + { + return this.getProperty(DirectDebitConstants.transitNumber); + } + + /// + /// Set the transitNumber + /// + /// void + public void transitNumber(string data) + { + this.setProperty(DirectDebitConstants.transitNumber, data); + } + + /// + /// Get the institutionId + /// + /// string + public string institutionId() + { + return this.getProperty(DirectDebitConstants.institutionId); + } + + /// + /// Set the institutionId + /// + /// void + public void institutionId(string data) + { + this.setProperty(DirectDebitConstants.institutionId, data); + } + + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(DirectDebitConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(DirectDebitConstants.lastDigits, data); + } + + /// + /// EFTAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated EFTAccount object + /// + public class EFTAccountBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + + /// + /// Initialize the EFTAccountBuilder builder within the context of a parent builder + /// + /// TBLDR + public EFTAccountBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the paymentToken + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder paymentToken(string data) + { + this.properties[DirectDebitConstants.paymentToken] = data; + return this; + } + + /// + /// Set the paymentDescriptor + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder paymentDescriptor(string data) + { + this.properties[DirectDebitConstants.paymentDescriptor] = data; + return this; + } + /// + /// Set the accountHolderName + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder accountHolderName(string data) + { + this.properties[DirectDebitConstants.accountHolderName] = data; + return this; + } + + /// + /// Set the accountNumber + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder accountNumber(string data) + { + this.properties[DirectDebitConstants.accountNumber] = data; + return this; + } + + /// + /// Set the transitNumber + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder transitNumber(string data) + { + this.properties[DirectDebitConstants.transitNumber] = data; + return this; + } + + /// + /// Set the institutionId + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder institutionId(string data) + { + this.properties[DirectDebitConstants.institutionId] = data; + return this; + } + + /// + /// Set the lastDigits + /// + /// string + /// EFTAccountBuilder + public EFTAccountBuilder lastDigits(string data) + { + this.properties[DirectDebitConstants.lastDigits] = data; + return this; + } + } + + } +} diff --git a/Paysafe/DirectDebit/Filter.cs b/Paysafe/DirectDebit/Filter.cs new file mode 100644 index 0000000..197993b --- /dev/null +++ b/Paysafe/DirectDebit/Filter.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is Filter class. + public class Filter + { + + /// + /// number of results per page + /// + + public int? limit = null; + + /// + /// The offset to start the request + /// + public int? offset = null; + + /// + /// The earliest date to match + /// + public String startDate = null; + + /// + /// The latest date to match + /// + public String endDate = null; + } +} diff --git a/Paysafe/DirectDebit/Pagerator.cs b/Paysafe/DirectDebit/Pagerator.cs new file mode 100644 index 0000000..8c56250 --- /dev/null +++ b/Paysafe/DirectDebit/Pagerator.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is Pagerator class. + public class Pagerator : AbstractPagerator + { + public Pagerator(PaysafeApiClient apiClient, Type pagingClassType, Dictionary data) + : base(apiClient, pagingClassType) + { + this.parseResponse(data); + } + + override protected sealed void parseResponse(Dictionary data) + { + if (!data.ContainsKey(this.arrayKey) || !(data[this.arrayKey] is List)) + { + throw new PaysafeException("Missing array key from results"); + } + foreach (dynamic obj in data[this.arrayKey] as List) + { + Object[] args = { obj }; + dynamic result = Activator.CreateInstance(this.classType, args); + this.results.Add(result); + } + this.nextPage = null; + + if (data.ContainsKey("links") + && data["links"] is List) + { + foreach (dynamic obj in (List)data["links"]) + { + Link tmpLink = new Link(obj); + if (tmpLink.rel().Equals("next")) + { + this.nextPage = tmpLink.href(); + break; + } + } + } + + if (data.ContainsKey("links") + && data["links"] is List) + { + foreach (dynamic obj in data["links"] as List) + { + Link tmpLink = new Link(obj); + if (tmpLink.rel().Equals("self")) + { + this.selfPage = tmpLink.href(); + break; + } + } + } + + if (data.ContainsKey("links") + && data["links"] is List) + { + foreach (dynamic obj in (List)data["links"]) + { + Link tmpLink = new Link(obj); + if (tmpLink.rel().Equals("previous")) + { + this.previousPage = tmpLink.href(); + break; + } + } + } + } + } +} diff --git a/Paysafe/DirectDebit/Profile.cs b/Paysafe/DirectDebit/Profile.cs new file mode 100644 index 0000000..a9c6f5b --- /dev/null +++ b/Paysafe/DirectDebit/Profile.cs @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is Profile class. + public class Profile : JSONObject + { + /// + /// Initialize the Profile object with some set of properties + /// + /// Dictionary + public Profile(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.firstName, STRING_TYPE}, + {DirectDebitConstants.lastName, STRING_TYPE}, + {DirectDebitConstants.email, EMAIL_TYPE}, + // {DirectDebitConstants.ssn,STRING_TYPE}, + {DirectDebitConstants.dateOfBirth,typeof(DateOfBirth)}, + }; + + + /// + /// Get the firstName + /// + /// string + public string firstName() + { + return this.getProperty(DirectDebitConstants.firstName); + } + + /// + /// Set the firstName + /// + /// void + public void firstName(string data) + { + this.setProperty(DirectDebitConstants.firstName, data); + } + + /// + /// Get the lastName + /// + /// string + public string lastName() + { + return this.getProperty(DirectDebitConstants.lastName); + } + + /// + /// Set the lastName + /// + /// void + public void lastName(string data) + { + this.setProperty(DirectDebitConstants.lastName, data); + } + + /// + /// Get the email + /// + /// string + public string email() + { + return this.getProperty(DirectDebitConstants.email); + } + + /// + /// Set the email + /// + /// void + public void email(string data) + { + this.setProperty(DirectDebitConstants.email, data); + } + + /// + /// Get the dateOfBirth + /// + /// DateOfBirth + public DateOfBirth dateOfBirth() + { + return this.getProperty(DirectDebitConstants.dateOfBirth); + } + + /// + /// Set the dateOfBirth + /// + /// void + public void dateOfBirth(DateOfBirth data) + { + this.setProperty(DirectDebitConstants.dateOfBirth, data); + } + + + /// + /// ProfileBuilder will allow a Profile to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class ProfileBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Profile builder within the context of a parent builder + /// + /// TBLDR + public ProfileBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the firstname + /// + /// string + /// ProfileBuilder + public ProfileBuilder firstName(string data) + { + this.properties[DirectDebitConstants.firstName] = data; + return this; + } + + /// + /// Set the lastname + /// + /// string + /// ProfileBuilder + public ProfileBuilder lastName(string data) + { + this.properties[DirectDebitConstants.lastName] = data; + return this; + } + + /// + /// Set the email + /// + /// string + /// ProfileBuilder + public ProfileBuilder email(string data) + { + this.properties[DirectDebitConstants.email] = data; + return this; + } + } + } +} diff --git a/Paysafe/DirectDebit/Purchases.cs b/Paysafe/DirectDebit/Purchases.cs new file mode 100644 index 0000000..6f041c0 --- /dev/null +++ b/Paysafe/DirectDebit/Purchases.cs @@ -0,0 +1,538 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; +using Paysafe.CustomerVault; +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is Purchases class. + public class Purchases : Paysafe.Common.JSONObject + { + /// + /// Initialize the Purchases object with some set of properties + /// + /// Dictionary + public Purchases(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize an Purchases object with an id + /// + /// + public Purchases(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// Gets the array key to access the array of purchase + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return "purchases"; + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.id, STRING_TYPE}, + {DirectDebitConstants.merchantRefNum,STRING_TYPE }, + {DirectDebitConstants.amount, INT_TYPE}, + {DirectDebitConstants.ach, typeof(ACHBankAccounts)}, + {DirectDebitConstants.eft, typeof(EFTBankAccounts)}, + {DirectDebitConstants.bacs, typeof(BACSBankAccounts)}, + {DirectDebitConstants.sepa, typeof(SEPABankAccounts)}, + {DirectDebitConstants.profile,typeof(Profile)}, + {DirectDebitConstants.billingDetails, typeof(BillingDetails)}, + {DirectDebitConstants.customerIp, STRING_TYPE}, + {DirectDebitConstants.dupCheck, BOOL_TYPE}, + {DirectDebitConstants.txnTime, typeof(DateTime)}, + {DirectDebitConstants.currencyCode,STRING_TYPE}, + {DirectDebitConstants.error, typeof(OptError)}, + {DirectDebitConstants.status, DirectDebitConstants.enumStatus}, + {DirectDebitConstants.links, typeof(List)} + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(DirectDebitConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(DirectDebitConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(DirectDebitConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(DirectDebitConstants.merchantRefNum, data); + } + + /// + /// Get the amount + /// + /// int + public int amount() + { + return this.getProperty(DirectDebitConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(DirectDebitConstants.amount, data); + } + + /// + /// Get the ach + /// + /// ACHBankAccount + public ACHBankAccounts ach() + { + return this.getProperty(DirectDebitConstants.ach); + } + + /// + /// Set the ach + /// + /// void + public void ach(ACHBankAccounts data) + { + this.setProperty(DirectDebitConstants.ach, data); + } + + /// + /// Get the eft + /// + /// EFTBankAccount + public EFTBankAccounts eft() + { + return this.getProperty(DirectDebitConstants.eft); + } + + /// + /// Set the eft + /// + /// void + public void eft(EFTBankAccounts data) + { + this.setProperty(DirectDebitConstants.eft, data); + } + + /// + /// Get the bacs + /// + /// BACSBankAccount + public BACSBankAccounts bacs() + { + return this.getProperty(DirectDebitConstants.bacs); + } + + /// + /// Set the bacs + /// + /// void + public void bacs(BACSBankAccounts data) + { + this.setProperty(DirectDebitConstants.bacs, data); + } + + /// + /// Get the sepa + /// + /// SEPABankAccount + public SEPABankAccounts sepa() + { + return this.getProperty(DirectDebitConstants.sepa); + } + + /// + /// Set the sepa + /// + /// void + public void sepa(SEPABankAccounts data) + { + this.setProperty(DirectDebitConstants.sepa, data); + } + + /// + /// Get the profile + /// + /// Profile + public Profile profile() + { + return this.getProperty(DirectDebitConstants.profile); + } + + /// + /// Set the profile + /// + /// void + public void profile(Profile data) + { + this.setProperty(DirectDebitConstants.profile, data); + } + + /// + /// Get the billingDetails + /// + /// string + public BillingDetails billingDetails() + { + return this.getProperty(DirectDebitConstants.billingDetails); + } + + /// + /// Set the billingDetails + /// + /// void + public void billingDetails(BillingDetails data) + { + this.setProperty(DirectDebitConstants.billingDetails, data); + } + + + /// + /// Get the customerIp + /// + /// string + public string customerIp() + { + return this.getProperty(DirectDebitConstants.customerIp); + } + + /// + /// Set the customerIp + /// + /// void + public void customerIp(string data) + { + this.setProperty(DirectDebitConstants.customerIp, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public bool dupCheck() + { + return this.getProperty(DirectDebitConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(string data) + { + this.setProperty(DirectDebitConstants.dupCheck, data); + } + + /// + /// Get the txnTime + /// + /// DateTime + public DateTime txnTime() + { + return this.getProperty(DirectDebitConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(DateTime data) + { + this.setProperty(DirectDebitConstants.txnTime, data); + } + + /// + /// Get the currencyCode + /// + /// string + public string currencyCode() + { + return this.getProperty(DirectDebitConstants.currencyCode); + } + + /// + /// Set the currencyCode + /// + /// void + public void ip(string data) + { + this.setProperty(DirectDebitConstants.currencyCode, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(DirectDebitConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(DirectDebitConstants.status, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(DirectDebitConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(DirectDebitConstants.error, data); + } + + /// + /// Get the Links + /// + /// Link + public List links() + { + return this.getProperty(DirectDebitConstants.links); + } + + /// + /// Set the Links + /// + /// void + public void links(List data) + { + this.setProperty(DirectDebitConstants.links, data); + } + + public static PurchasesBuilder Builder() + { + return new PurchasesBuilder(); + } + + /// + /// PurchasesBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Profile object + /// + public class PurchasesBuilder : BaseJSONBuilder + { + + /// + /// Set the id parameter + /// + /// string + /// PurchasesBuilder + public PurchasesBuilder id(string data) + { + this.properties[DirectDebitConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// PurchasesBuilder + public PurchasesBuilder merchantRefNum(string data) + { + this.properties[DirectDebitConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount parameter + /// + /// List + /// PurchasesBuilder + public PurchasesBuilder amount(int data) + { + this.properties[DirectDebitConstants.amount] = data; + return this; + } + + /// + /// Build a ACHBankAccount within this authorization. + /// + /// ACHBankAccount.ACHAccountBuilder + public ACHBankAccounts.ACHAccountBuilder ach() + { + if (!this.properties.ContainsKey(DirectDebitConstants.ach)) + { + this.properties[DirectDebitConstants.ach] = new ACHBankAccounts.ACHAccountBuilder(this); + } + return this.properties[DirectDebitConstants.ach] as ACHBankAccounts.ACHAccountBuilder; + } + + /// + /// Build a BACSBankAccount within this authorization. + /// + /// BACSBankAccount.BACSBankAccountBuilder> + public BACSBankAccounts.BACSBankAccountBuilder bacs() + { + if (!this.properties.ContainsKey(DirectDebitConstants.bacs)) + { + this.properties[DirectDebitConstants.bacs] = new BACSBankAccounts.BACSBankAccountBuilder(this); + } + return this.properties[DirectDebitConstants.bacs] as BACSBankAccounts.BACSBankAccountBuilder; + } + + /// + /// Build a EFTBankAccount within this authorization. + /// + /// EFTBankAccount.EFTAccountBuilder + public EFTBankAccounts.EFTAccountBuilder eft() + { + if (!this.properties.ContainsKey(DirectDebitConstants.eft)) + { + this.properties[DirectDebitConstants.eft] = new EFTBankAccounts.EFTAccountBuilder(this); + } + return this.properties[DirectDebitConstants.eft] as EFTBankAccounts.EFTAccountBuilder; + } + + /// + /// Build a SEPABankAccount within this authorization. + /// + /// SEPABankAccount.SEPAAccountBuilder + public SEPABankAccounts.SEPAAccountBuilder sepa() + { + if (!this.properties.ContainsKey(DirectDebitConstants.sepa)) + { + this.properties[DirectDebitConstants.sepa] = new SEPABankAccounts.SEPAAccountBuilder(this); + } + return this.properties[DirectDebitConstants.sepa] as SEPABankAccounts.SEPAAccountBuilder; + } + + /// + /// Build a profile within this authorization. + /// + /// profile.profileBuilder + public Profile.ProfileBuilder profile() + { + if (!this.properties.ContainsKey(DirectDebitConstants.profile)) + { + this.properties[DirectDebitConstants.profile] = new Profile.ProfileBuilder(this); + } + return this.properties[DirectDebitConstants.profile] as Profile.ProfileBuilder; + } + + /// + /// Build a billing details object within this authorization. + /// + /// BillingDetails.BillingDetailsBuilder + public BillingDetails.BillingDetailsBuilder billingDetails() + { + if (!this.properties.ContainsKey(DirectDebitConstants.billingDetails)) + { + this.properties[DirectDebitConstants.billingDetails] = new BillingDetails.BillingDetailsBuilder(this); + } + return this.properties[DirectDebitConstants.billingDetails] as BillingDetails.BillingDetailsBuilder; + } + + /// + /// Set the customerIp parameter + /// + /// string + /// PurchasesBuilder + public PurchasesBuilder customerIp(string data) + { + this.properties[DirectDebitConstants.customerIp] = data; + return this; + } + + /// + /// Set the dupCheck parameter + /// + /// string + /// PurchasesBuilder + public PurchasesBuilder dupCheck(bool data) + { + this.properties[DirectDebitConstants.dupCheck] = data; + return this; + } + + /// + /// Set the currencyCode parameter + /// + /// string + /// PurchasesBuilder + public PurchasesBuilder currencyCode(string data) + { + this.properties[DirectDebitConstants.currencyCode] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// PurchasesBuilder + public PurchasesBuilder status(string data) + { + this.properties[DirectDebitConstants.status] = data; + return this; + } + } + } + +} diff --git a/Paysafe/DirectDebit/SEPABankAccounts.cs b/Paysafe/DirectDebit/SEPABankAccounts.cs new file mode 100644 index 0000000..6c8ba8e --- /dev/null +++ b/Paysafe/DirectDebit/SEPABankAccounts.cs @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is SEPABankAccounts class. + public class SEPABankAccounts : Paysafe.Common.JSONObject + { + /// + /// Initialize the SEPABankAccounts object with some set of properties + /// + /// Dictionary + public SEPABankAccounts(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.paymentToken,STRING_TYPE}, + {DirectDebitConstants.mandateReference,STRING_TYPE}, + {DirectDebitConstants.accountHolderName,STRING_TYPE}, + {DirectDebitConstants.iban,STRING_TYPE}, + {DirectDebitConstants.lastDigits,STRING_TYPE}, + + }; + + /// + /// Get the paymentToken + /// + /// string + public string paymentToken() + { + return this.getProperty(DirectDebitConstants.paymentToken); + } + + /// + /// Set the paymentToken + /// + /// void + public void paymentToken(string data) + { + this.setProperty(DirectDebitConstants.paymentToken, data); + } + + /// + /// Get the mandateReference + /// + /// string + public string mandateReference() + { + return this.getProperty(DirectDebitConstants.mandateReference); + } + + /// + /// Set the mandateReference + /// + /// void + public void mandateReference(string data) + { + this.setProperty(DirectDebitConstants.mandateReference, data); + } + /// + /// Get the accountHolderName + /// + /// string + public string accountHolderName() + { + return this.getProperty(DirectDebitConstants.accountHolderName); + } + + /// + /// Set the accountHolderName + /// + /// void + public void accountHolderName(string data) + { + this.setProperty(DirectDebitConstants.accountHolderName, data); + } + /// + /// Get the iban + /// + /// string + public string iban() + { + return this.getProperty(DirectDebitConstants.iban); + } + + /// + /// Set the iban + /// + /// void + public void iban(string data) + { + this.setProperty(DirectDebitConstants.iban, data); + } + /// + /// Get the lastDigits + /// + /// string + public string lastDigits() + { + return this.getProperty(DirectDebitConstants.lastDigits); + } + + /// + /// Set the lastDigits + /// + /// void + public void lastDigits(string data) + { + this.setProperty(DirectDebitConstants.lastDigits, data); + } + + /// + /// SEPAAccountBuilder will allow an account to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated SEPABankAccount object + /// + public class SEPAAccountBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + + /// + /// Initialize the SEPAAccountBuilder builder within the context of a parent builder + /// + /// TBLDR + public SEPAAccountBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the paymentToken + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder paymentToken(string data) + { + this.properties[DirectDebitConstants.paymentToken] = data; + return this; + } + + /// + /// Set the mandateReference + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder mandateReference(string data) + { + this.properties[DirectDebitConstants.mandateReference] = data; + return this; + } + + /// + /// Set the accountHolderName + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder accountHolderName(string data) + { + this.properties[DirectDebitConstants.accountHolderName] = data; + return this; + } + + /// + /// Set the iban + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder iban(string data) + { + this.properties[DirectDebitConstants.iban] = data; + return this; + } + + /// + /// Set the lastDigits + /// + /// string + /// SEPAAccountBuilder + public SEPAAccountBuilder lastDigits(string data) + { + this.properties[DirectDebitConstants.lastDigits] = data; + return this; + } + + } + + } +} diff --git a/Paysafe/DirectDebit/ShippingDetails.cs b/Paysafe/DirectDebit/ShippingDetails.cs new file mode 100644 index 0000000..dfc24f5 --- /dev/null +++ b/Paysafe/DirectDebit/ShippingDetails.cs @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is ShippingDetails class. + public class ShippingDetails : AddressDetails + { + /// + /// Initialize the ShippingDetails object with some set of properties + /// + /// Dictionary + public ShippingDetails(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary(addressFieldTypes) + { + {DirectDebitConstants.recipientName, STRING_TYPE}, + {DirectDebitConstants.carrier, DirectDebitConstants.enumCarrier}, + {DirectDebitConstants.shipMethod, DirectDebitConstants.enumShipMethod} + }; + + /// + /// Get the recipientName + /// + /// string + public string recipientName() + { + return this.getProperty(DirectDebitConstants.recipientName); + } + + /// + /// Set the recipientName + /// + /// void + public void recipientName(string data) + { + this.setProperty(DirectDebitConstants.recipientName, data); + } + + /// + /// Get the carrier + /// + /// List + public List carrier() + { + return this.getProperty(DirectDebitConstants.carrier); + } + + /// + /// Set the carrier + /// + /// void + public void carrier(string data) + { + this.setProperty(DirectDebitConstants.carrier, data); + } + + /// + /// Get the shipMethod + /// + /// string + public string shipMethod() + { + return this.getProperty(DirectDebitConstants.shipMethod); + } + + /// + /// Set the shipMethod + /// + /// void + public void shipMethod(string data) + { + this.setProperty(DirectDebitConstants.shipMethod, data); + } + + /// + /// ShippingDetailsBuilder will allow a ShippingDetails to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back to the parent builder + /// + public class ShippingDetailsBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the ShippingDetails builder within the context of a parent builder + /// + /// TBLDR + public ShippingDetailsBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the recipientName + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder recipientName(string data) + { + this.properties[DirectDebitConstants.recipientName] = data; + return this; + } + + /// + /// Set the street + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder street(string data) + { + this.properties[DirectDebitConstants.street] = data; + return this; + } + + /// + /// Set the street2 + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder street2(string data) + { + this.properties[DirectDebitConstants.street2] = data; + return this; + } + + /// + /// Set the city + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder city(string data) + { + this.properties[DirectDebitConstants.city] = data; + return this; + } + + /// + /// Set the state + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder state(string data) + { + this.properties[DirectDebitConstants.state] = data; + return this; + } + + /// + /// Set the country + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder country(string data) + { + this.properties[DirectDebitConstants.country] = data; + return this; + } + + /// + /// Set the zip + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder zip(string data) + { + this.properties[DirectDebitConstants.zip] = data; + return this; + } + + /// + /// Set the phone + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder phone(string data) + { + this.properties[DirectDebitConstants.phone] = data; + return this; + } + + /// + /// Set the carrier + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder carrier(string data) + { + this.properties[DirectDebitConstants.carrier] = data; + return this; + } + + /// + /// Set the shipMethod + /// + /// string + /// ShippingDetailsBuilder + public ShippingDetailsBuilder shipMethod(string data) + { + this.properties[DirectDebitConstants.shipMethod] = data; + return this; + } + } + } +} diff --git a/Paysafe/DirectDebit/StandaloneCredits.cs b/Paysafe/DirectDebit/StandaloneCredits.cs new file mode 100644 index 0000000..80384c0 --- /dev/null +++ b/Paysafe/DirectDebit/StandaloneCredits.cs @@ -0,0 +1,552 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.DirectDebit +{ + //Created by Manjiri.Bankar on 03.05.2016. This is StandaloneCredits class. + public class StandaloneCredits : Paysafe.Common.JSONObject + { + /// + /// Initialize the StandaloneCredits object with some set of properties + /// + /// Dictionary + public StandaloneCredits(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// Initialize an StandaloneCredits object with an id + /// + /// + public StandaloneCredits(String id) + : base(fieldTypes) + { + this.id(id); + } + + /// + /// Gets the array key to access the array of StandaloneCredits + /// + /// The key to be checked in the returning JSON + public static string getPageableArrayKey() + { + return "standaloneCredits"; + } + + private static new Dictionary fieldTypes = new Dictionary + { + {DirectDebitConstants.id, STRING_TYPE}, + {DirectDebitConstants.merchantRefNum,STRING_TYPE }, + {DirectDebitConstants.amount,INT_TYPE}, + {DirectDebitConstants.ach, typeof(ACHBankAccounts)}, + {DirectDebitConstants.eft, typeof(EFTBankAccounts)}, + {DirectDebitConstants.bacs, typeof(BACSBankAccounts)}, + {DirectDebitConstants.profile,typeof(Profile)}, + {DirectDebitConstants.billingDetails, typeof(BillingDetails)}, + {DirectDebitConstants.shippingDetails, typeof(ShippingDetails)}, + {DirectDebitConstants.customerIp, STRING_TYPE}, + {DirectDebitConstants.dupCheck, BOOL_TYPE}, + {DirectDebitConstants.txnTime, typeof(DateTime)}, + {DirectDebitConstants.currencyCode,STRING_TYPE}, + {DirectDebitConstants.error, typeof(OptError)}, + {DirectDebitConstants.status, DirectDebitConstants.enumStatus}, + {DirectDebitConstants.links, typeof(List)} + + }; + + /// + /// Get the id + /// + /// string + public string id() + { + return this.getProperty(DirectDebitConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(string data) + { + this.setProperty(DirectDebitConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// string + public string merchantRefNum() + { + return this.getProperty(DirectDebitConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(string data) + { + this.setProperty(DirectDebitConstants.merchantRefNum, data); + } + + /// + /// Get the amount + /// + /// int + public int amount() + { + return this.getProperty(DirectDebitConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(DirectDebitConstants.amount, data); + } + + /// + /// Get the ach + /// + /// ACHBankAccount + public ACHBankAccounts ach() + { + return this.getProperty(DirectDebitConstants.ach); + } + + /// + /// Set the ach + /// + /// void + public void ach(ACHBankAccounts data) + { + this.setProperty(DirectDebitConstants.ach, data); + } + + /// + /// Get the eft + /// + /// EFTBankAccount + public EFTBankAccounts eft() + { + return this.getProperty(DirectDebitConstants.eft); + } + + /// + /// Set the eft + /// + /// void + public void eft(EFTBankAccounts data) + { + this.setProperty(DirectDebitConstants.eft, data); + } + + /// + /// Get the bacs + /// + /// BACSBankAccount + public BACSBankAccounts bacs() + { + return this.getProperty(DirectDebitConstants.bacs); + } + + /// + /// Set the bacs + /// + /// void + public void bacs(BACSBankAccounts data) + { + this.setProperty(DirectDebitConstants.bacs, data); + } + + + /// + /// Get the profile + /// + /// Profile + public Profile profile() + { + return this.getProperty(DirectDebitConstants.profile); + } + + /// + /// Set the profile + /// + /// void + public void profile(Profile data) + { + this.setProperty(DirectDebitConstants.profile, data); + } + + /// + /// Get the billingDetails + /// + /// string + public BillingDetails billingDetails() + { + return this.getProperty(DirectDebitConstants.billingDetails); + } + + /// + /// Set the billingDetails + /// + /// void + public void billingDetails(BillingDetails data) + { + this.setProperty(DirectDebitConstants.billingDetails, data); + } + + /// + /// Get the shippingDetails + /// + /// string + public ShippingDetails shippingDetails() + { + return this.getProperty(DirectDebitConstants.shippingDetails); + } + + /// + /// Set the shippingDetails + /// + /// void + public void shippingDetails(ShippingDetails data) + { + this.setProperty(DirectDebitConstants.shippingDetails, data); + } + + /// + /// Get the customerIp + /// + /// string + public string customerIp() + { + return this.getProperty(DirectDebitConstants.customerIp); + } + + /// + /// Set the customerIp + /// + /// void + public void customerIp(string data) + { + this.setProperty(DirectDebitConstants.customerIp, data); + } + + /// + /// Get the dupCheck + /// + /// bool + public bool dupCheck() + { + return this.getProperty(DirectDebitConstants.dupCheck); + } + + /// + /// Set the dupCheck + /// + /// void + public void dupCheck(string data) + { + this.setProperty(DirectDebitConstants.dupCheck, data); + } + + /// + /// Get the txnTime + /// + /// DateTime + public DateTime txnTime() + { + return this.getProperty(DirectDebitConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(DateTime data) + { + this.setProperty(DirectDebitConstants.txnTime, data); + } + + /// + /// Get the currencyCode + /// + /// string + public string currencyCode() + { + return this.getProperty(DirectDebitConstants.currencyCode); + } + + /// + /// Set the currencyCode + /// + /// void + public void currencyCode(string data) + { + this.setProperty(DirectDebitConstants.currencyCode, data); + } + + /// + /// Get the status + /// + /// string + public string status() + { + return this.getProperty(DirectDebitConstants.status); + } + + /// + /// Set the status + /// + /// void + public void status(string data) + { + this.setProperty(DirectDebitConstants.status, data); + } + + /// + /// Get the error + /// + /// OptError + public OptError error() + { + return this.getProperty(DirectDebitConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(OptError data) + { + this.setProperty(DirectDebitConstants.error, data); + } + + /// + /// Get the Links + /// + /// Link + public List links() + { + return this.getProperty(DirectDebitConstants.links); + } + + /// + /// Set the Links + /// + /// void + public void links(List data) + { + this.setProperty(DirectDebitConstants.error, data); + } + + public static StandaloneCreditsBuilder Builder() + { + return new StandaloneCreditsBuilder(); + } + + /// + /// PurchasesBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Profile object + /// + public class StandaloneCreditsBuilder : BaseJSONBuilder + { + + /// + /// Set the id parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder id(string data) + { + this.properties[DirectDebitConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder merchantRefNum(string data) + { + this.properties[DirectDebitConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount parameter + /// + /// List + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder amount(int data) + { + this.properties[DirectDebitConstants.amount] = data; + return this; + } + + /// + /// Build a ACHBankAccount within this authorization. + /// + /// ACHBankAccount.ACHAccountBuilder + public ACHBankAccounts.ACHAccountBuilder ach() + { + if (!this.properties.ContainsKey(DirectDebitConstants.ach)) + { + this.properties[DirectDebitConstants.ach] = new ACHBankAccounts.ACHAccountBuilder(this); + } + return this.properties[DirectDebitConstants.ach] as ACHBankAccounts.ACHAccountBuilder; + } + + /// + /// Build a BACSBankAccount within this authorization. + /// + /// BACSBankAccount.BACSBankAccountBuilder> + public BACSBankAccounts.BACSBankAccountBuilder bacs() + { + if (!this.properties.ContainsKey(DirectDebitConstants.bacs)) + { + this.properties[DirectDebitConstants.bacs] = new BACSBankAccounts.BACSBankAccountBuilder(this); + } + return this.properties[DirectDebitConstants.bacs] as BACSBankAccounts.BACSBankAccountBuilder; + } + + /// + /// Build a EFTBankAccount within this authorization. + /// + /// EFTBankAccount.EFTAccountBuilder + public EFTBankAccounts.EFTAccountBuilder eft() + { + if (!this.properties.ContainsKey(DirectDebitConstants.eft)) + { + this.properties[DirectDebitConstants.eft] = new EFTBankAccounts.EFTAccountBuilder(this); + } + return this.properties[DirectDebitConstants.eft] as EFTBankAccounts.EFTAccountBuilder; + } + + /// + /// Build a profile within this authorization. + /// + /// profile.profileBuilder + public Profile.ProfileBuilder profile() + { + if (!this.properties.ContainsKey(DirectDebitConstants.profile)) + { + this.properties[DirectDebitConstants.profile] = new Profile.ProfileBuilder(this); + } + return this.properties[DirectDebitConstants.profile] as Profile.ProfileBuilder; + } + + /// + /// Build a billing details object within this authorization. + /// + /// BillingDetails.BillingDetailsBuilder + public BillingDetails.BillingDetailsBuilder billingDetails() + { + if (!this.properties.ContainsKey(DirectDebitConstants.billingDetails)) + { + this.properties[DirectDebitConstants.billingDetails] = new BillingDetails.BillingDetailsBuilder(this); + } + return this.properties[DirectDebitConstants.billingDetails] as BillingDetails.BillingDetailsBuilder; + } + + + /// + /// Build a ShippingDetails within this authorization. + /// + /// ShippingDetails.ShippingDetailsBuilder + public ShippingDetails.ShippingDetailsBuilder dateOfBirth() + { + if (!this.properties.ContainsKey(DirectDebitConstants.dateOfBirth)) + { + this.properties[DirectDebitConstants.dateOfBirth] = new ShippingDetails.ShippingDetailsBuilder(this); + } + return this.properties[DirectDebitConstants.dateOfBirth] as ShippingDetails.ShippingDetailsBuilder; + } + + + + /// + /// Set the customerIp parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder customerIp(string data) + { + this.properties[DirectDebitConstants.customerIp] = data; + return this; + } + + /// + /// Set the dupCheck parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder dupCheck(bool data) + { + this.properties[DirectDebitConstants.dupCheck] = data; + return this; + } + + /// + /// Set the txnTime parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder txnTime(DateTime data) + { + this.properties[DirectDebitConstants.txnTime] = data; + return this; + } + + /// + /// Set the currencyCode parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder currencyCode(string data) + { + this.properties[DirectDebitConstants.currencyCode] = data; + return this; + } + + /// + /// Set the status parameter + /// + /// string + /// StandaloneCreditsBuilder + public StandaloneCreditsBuilder status(string data) + { + this.properties[DirectDebitConstants.status] = data; + return this; + } + } + } +} diff --git a/Paysafe/Environment.cs b/Paysafe/Environment.cs new file mode 100644 index 0000000..aa79f3e --- /dev/null +++ b/Paysafe/Environment.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + + +namespace Paysafe +{ + public enum Environment + { + LIVE, + TEST + } +} diff --git a/Paysafe/Paysafe.csproj b/Paysafe/Paysafe.csproj new file mode 100644 index 0000000..ffdbbf7 --- /dev/null +++ b/Paysafe/Paysafe.csproj @@ -0,0 +1,141 @@ + + + + + 10.0 + Debug + AnyCPU + {1AA4F97B-967A-4420-B3CC-EF1EFBAA72F8} + Library + Properties + Paysafe + Paysafe + v4.0 + Profile344 + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 975b9097 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + MinimumRecommendedRules.ruleset + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\packages\Newtonsoft.Json.6.0.6\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll + + + + + + + + + + \ No newline at end of file diff --git a/Paysafe/PaysafeApiClient.cs b/Paysafe/PaysafeApiClient.cs new file mode 100644 index 0000000..8197ebc --- /dev/null +++ b/Paysafe/PaysafeApiClient.cs @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2014 Paysafe Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Net; +using System.IO; +using CardPaymentService = Paysafe.CardPayments.CardPaymentService; +using CustomerVaultService = Paysafe.CustomerVault.CustomerVaultService; +using DirectDebitService = Paysafe.DirectDebit.DirectDebitService; +using ThreeDSecureService = Paysafe.ThreeDSecure.ThreeDSecureService; +using Paysafe.Common; + +[assembly: CLSCompliant(true)] + +namespace Paysafe +{ + public class PaysafeApiClient + { + /// + /// The api key id + /// + private String apiKeyId; + + /// + /// The api key passsword + /// + private String apiKeyPassword; + + /// + /// The api environment (test/live) + /// + private Environment apiEnvironment; + + /// + /// The merchant account (used only by the CardPayments api) + /// + private String apiAccount; + + /// + /// The api endpoint to which all requests should be sent + /// + private String apiEndPoint; + + /// + /// Initialize the api client. + /// + /// string + /// string + /// Environment + /// string + public PaysafeApiClient(string keyId, string keyPassword, Environment environment, string account = "") + { + this.apiKey(keyId); + this.apiPassword(keyPassword); + this.environment(environment); + this.account(account); + } + + /// + /// Sets the api key id + /// + /// string + protected void apiKey(string newKeyId) + { + if (newKeyId == null) + { + throw new PaysafeException("You must specify an API Key"); + } + this.apiKeyId = newKeyId; + } + + /// + /// Sets the api key password + /// + /// string + protected void apiPassword(string newKeyPassword) + { + if (newKeyPassword == null) + { + throw new PaysafeException("You must specify an API Password"); + } + this.apiKeyPassword = newKeyPassword; + } + + /// + /// Sets the environment, and api endpoint + /// + /// Environment + protected void environment(Environment newEnvironment) + { + this.apiEnvironment = newEnvironment; + + if (this.apiEnvironment == Environment.TEST) + { + this.apiEndPoint = "https://api.test.netbanx.com"; + } + else + { + this.apiEndPoint = "https://api.netbanx.com"; + } + + } + + /// + /// Sets the merchant account number for use with the card payments api + /// + /// string + public void account(string newAccount) + { + this.apiAccount = newAccount; + } + + /// + /// Get the merchant account number + /// + /// string + public String account() + { + return this.apiAccount; + } + + /// + /// Get an instance of the card payment service + /// + /// CardPaymentService + public CardPaymentService cardPaymentService() + { + return new CardPaymentService(this); + } + + /// + /// Get an instance of the customer vault service + /// + /// CustomerVaultService + public CustomerVaultService customerVaultService() { + return new Paysafe.CustomerVault.CustomerVaultService(this); + } + + + + /// + /// Get an instance of the Direct debit service + /// + /// DirectDebitService + public DirectDebitService directDebitService() + + { + return new DirectDebitService(this); + } + + /// + /// Get an instance of the ThreeDSecure service + /// + /// ThreeDSecureService + public ThreeDSecureService threeDSecureService() + { + return new ThreeDSecureService(this); + } + + /// + /// Returns the base64 encoded authentication string for the http request headers + /// + /// string + private string getAuthString() + { + return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(this.apiKeyId + ":" + this.apiKeyPassword)); + } + + /// + /// This method will perform a the http request synchronously, and return the json decoded result + /// + /// + /// Dictionary + public Dictionary processRequest(Request request) + { + HttpWebRequest conn = (HttpWebRequest)WebRequest.CreateHttp(request.buildUrl(this.apiEndPoint)); + conn.Headers["Authorization"] = "Basic " + this.getAuthString(); + conn.ContentType = "application/json; charset=utf-8"; + + conn.Method = request.method(); + if (request.method().Equals(RequestType.POST.ToString()) + || request.method().Equals(RequestType.PUT.ToString())) + { + string requestBody = request.body(); + byte[] requestData = Encoding.UTF8.GetBytes(requestBody); + + var resultRequest = conn.BeginGetRequestStream(null, null); + Stream postStream = conn.EndGetRequestStream(resultRequest); + postStream.Write(requestData, 0, requestData.Length); + postStream.Dispose(); + } + + try + { + var responseRequest = conn.BeginGetResponse(null, null); + WebResponse responseObject = conn.EndGetResponse(responseRequest); + + StreamReader sr = new StreamReader(responseObject.GetResponseStream()); + return PaysafeApiClient.parseResponse(sr.ReadToEnd()); + } + catch (System.Net.WebException ex) + { + HttpWebResponse response = (HttpWebResponse)ex.Response; + StreamReader sr = new StreamReader(response.GetResponseStream()); + string body = sr.ReadToEnd(); + + string exceptionType = null; + switch (response.StatusCode) + { + case HttpStatusCode.BadRequest: // 400 + exceptionType = "InvalidRequestException"; + break; + case HttpStatusCode.Unauthorized: // 401 + exceptionType = "InvalidCredentialsException"; + break; + case HttpStatusCode.PaymentRequired: //402 + exceptionType = "RequestDeclinedException"; + break; + case HttpStatusCode.Forbidden: //403 + exceptionType = "PermissionException"; + break; + case HttpStatusCode.NotFound: //404 + exceptionType = "EntityNotFoundException"; + break; + case HttpStatusCode.Conflict: //409 + exceptionType = "RequestConflictException"; + break; + case HttpStatusCode.NotAcceptable: //406 + case HttpStatusCode.UnsupportedMediaType: //415 + case HttpStatusCode.InternalServerError: //500 + case HttpStatusCode.NotImplemented: //501 + case HttpStatusCode.BadGateway: //502 + case HttpStatusCode.ServiceUnavailable: //503 + case HttpStatusCode.GatewayTimeout: //504 + case HttpStatusCode.HttpVersionNotSupported: //505 + exceptionType = "APIException"; + break; + } + if (exceptionType != null) + { + String message = ex.Message; + Dictionary rawResponse = PaysafeApiClient.parseResponse(body); + if (rawResponse.ContainsKey("error")) + { + message = rawResponse["error"]["message"]; + } + + Object[] args = { message, ex.InnerException }; + PaysafeException PaysafeException = Activator.CreateInstance + (Type.GetType("Paysafe.Common." + exceptionType), args) as PaysafeException; + PaysafeException.rawResponse(rawResponse); + if (rawResponse.ContainsKey("error")) + { + PaysafeException.code(int.Parse(rawResponse["error"]["code"])); + } + throw PaysafeException; + } + throw; + } + throw new PaysafeException("An unknown error has occurred."); + } + + public static Dictionary parseResponse(string response) + { + if (String.IsNullOrWhiteSpace(response)) + { + return null; + } + return JsonHelper.Deserialize(response) as Dictionary; + } + + } +} diff --git a/Paysafe/Properties/AssemblyInfo.cs b/Paysafe/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..83b4217 --- /dev/null +++ b/Paysafe/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Paysafe-sdk-csharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Paysafe-sdk-csharp")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Paysafe/RequestType.cs b/Paysafe/RequestType.cs new file mode 100644 index 0000000..0eeefa8 --- /dev/null +++ b/Paysafe/RequestType.cs @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + + +namespace Paysafe +{ + public enum RequestType + { + GET, + POST, + PUT, + DELETE + } +} diff --git a/Paysafe/ThreeDSecure/Authentications.cs b/Paysafe/ThreeDSecure/Authentications.cs new file mode 100644 index 0000000..0ff7f42 --- /dev/null +++ b/Paysafe/ThreeDSecure/Authentications.cs @@ -0,0 +1,487 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using Paysafe.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Paysafe.ThreeDSecure +{ + //Created by Tushar.Sukhiya on 03.05.2016. This is Authentications class. + public class Authentications : JSONObject + { + /// + /// Initialize the Authentications object with some set of properties + /// + /// Dictionary + public Authentications(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {ThreeDSecureConstants.id, STRING_TYPE}, + {ThreeDSecureConstants.merchantRefNum, STRING_TYPE}, + {ThreeDSecureConstants.paResp, STRING_TYPE}, + {ThreeDSecureConstants.customerIp, STRING_TYPE}, + {ThreeDSecureConstants.txnTime, typeof(DateTime)}, + {ThreeDSecureConstants.error, typeof(Error)}, + {ThreeDSecureConstants.status, ThreeDSecureConstants.enumStatus}, + {ThreeDSecureConstants.threeDResult, ThreeDSecureConstants.enumThreeDResult}, + {ThreeDSecureConstants.signatureStatus, ThreeDSecureConstants.enumSignatureStatus}, + {ThreeDSecureConstants.eci, INT_TYPE}, + {ThreeDSecureConstants.cavv, STRING_TYPE}, + {ThreeDSecureConstants.xid, STRING_TYPE}, + {ThreeDSecureConstants.enrollmentId, STRING_TYPE}, + {ThreeDSecureConstants.links, typeof(List)}, + {ThreeDSecureConstants.enrollmentchecks, typeof(List)} + }; + + /// + /// Get the id + /// + /// String + public string id() + { + return this.getProperty(ThreeDSecureConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(String data) + { + this.setProperty(ThreeDSecureConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// String + public string merchantRefNum() + { + return this.getProperty(ThreeDSecureConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(String data) + { + this.setProperty(ThreeDSecureConstants.merchantRefNum, data); + } + + /// + /// Get the paRes + /// + /// String + public string paRes() + { + return this.getProperty(ThreeDSecureConstants.paResp); + } + + /// + /// Set the paRes + /// + /// void + public void paRes(String data) + { + this.setProperty(ThreeDSecureConstants.paResp, data); + } + + /// + /// Get the customerIp + /// + /// String + public string customerIp() + { + return this.getProperty(ThreeDSecureConstants.customerIp); + } + + /// + /// Set the customerIp + /// + /// void + public void customerIp(String data) + { + this.setProperty(ThreeDSecureConstants.customerIp, data); + } + + /// + /// Get the txnTime + /// + /// DateTime + public DateTime txnTime() + { + return this.getProperty(ThreeDSecureConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(DateTime data) + { + this.setProperty(ThreeDSecureConstants.txnTime, data); + } + + /// + /// Get the error + /// + /// Error + public Error error() + { + return this.getProperty(ThreeDSecureConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(Error data) + { + this.setProperty(ThreeDSecureConstants.error, data); + } + + /// + /// Get the status + /// + /// String + public string status() + { + return this.getProperty(ThreeDSecureConstants.status); + } + + /// + /// Set the status + /// + /// String + public void status(String data) + { + this.setProperty(ThreeDSecureConstants.status, data); + } + + /// + /// Get the threeDResult + /// + /// String + public string threeDResult() + { + return this.getProperty(ThreeDSecureConstants.threeDResult); + } + + /// + /// Set the threeDResult + /// + /// String + public void threeDResult(String data) + { + this.setProperty(ThreeDSecureConstants.threeDResult, data); + } + + /// + /// Get the signatureStatus + /// + /// String + public string signatureStatus() + { + return this.getProperty(ThreeDSecureConstants.signatureStatus); + } + + /// + /// Set the signatureStatus + /// + /// String + public void signatureStatus(String data) + { + this.setProperty(ThreeDSecureConstants.signatureStatus, data); + } + + /// + /// Get the eci + /// + /// integer + public int eci() + { + return this.getProperty(ThreeDSecureConstants.eci); + } + + /// + /// Set the eci + /// + /// void + public void eci(int data) + { + this.setProperty(ThreeDSecureConstants.eci, data); + } + + /// + /// Get the cavv + /// + /// String + public string cavv() + { + return this.getProperty(ThreeDSecureConstants.cavv); + } + + /// + /// Set the cavv + /// + /// void + public void cavv(String data) + { + this.setProperty(ThreeDSecureConstants.cavv, data); + } + + /// + /// Get the xid + /// + /// String + public string xid() + { + return this.getProperty(ThreeDSecureConstants.xid); + } + + /// + /// Set the xid + /// + /// void + public void xid(String data) + { + this.setProperty(ThreeDSecureConstants.xid, data); + } + + public static AuthenticationsBuilder Builder() + { + return new AuthenticationsBuilder(); + } + + /// + /// Get the enrollmentId + /// + /// String + public string enrollmentId() + { + return this.getProperty(ThreeDSecureConstants.enrollmentId); + } + + /// + /// Set the enrollmentId + /// + /// void + public void enrollmentId(String data) + { + this.setProperty(ThreeDSecureConstants.enrollmentId, data); + } + + /// + /// Get the Links + /// + /// Link + public List links() + { + return this.getProperty(ThreeDSecureConstants.links); + } + + /// + /// Set the Links + /// + /// void + public void links(List data) + { + this.setProperty(ThreeDSecureConstants.links, data); + } + + /// + /// Get the enrollmentchecks + /// + /// EnrollmentChecks + public List enrollmentchecks() + { + return this.getProperty(ThreeDSecureConstants.enrollmentchecks); + } + + /// + /// Set the enrollmentchecks + /// + /// void + public void enrollmentchecks(List data) + { + this.setProperty(ThreeDSecureConstants.enrollmentchecks, data); + } + + /// + /// AuthenticationsBuilder will allow an authentication to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated Authentications object + /// + public class AuthenticationsBuilder : BaseJSONBuilder + { + /// + /// Set the id parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder id(string data) + { + this.properties[ThreeDSecureConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder merchantRefNum(string data) + { + this.properties[ThreeDSecureConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the paResp parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder paResp(string data) + { + this.properties[ThreeDSecureConstants.paResp] = data; + return this; + } + + /// + /// Set the customerIp parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder customerIp(string data) + { + this.properties[ThreeDSecureConstants.customerIp] = data; + return this; + } + + /// + /// Set the txnTime parameter + /// + /// DateTime + /// AuthenticationsBuilder + public AuthenticationsBuilder txnTime(DateTime data) + { + this.properties[ThreeDSecureConstants.txnTime] = data; + return this; + } + + /// + /// Build a Error object within this Authentications. + /// + /// Error.ErrorBuilder + public Error.ErrorBuilder error() + { + if (!this.properties.ContainsKey(ThreeDSecureConstants.error)) + { + this.properties[ThreeDSecureConstants.error] = new Error.ErrorBuilder(this); + } + return this.properties[ThreeDSecureConstants.error] as Error.ErrorBuilder; + } + + /// + /// Set the status parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder status(string data) + { + this.properties[ThreeDSecureConstants.status] = data; + return this; + } + + /// + /// Set the threeDResult parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder threeDResult(string data) + { + this.properties[ThreeDSecureConstants.threeDResult] = data; + return this; + } + + /// + /// Set the signatureStatus parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder signatureStatus(string data) + { + this.properties[ThreeDSecureConstants.signatureStatus] = data; + return this; + } + + /// + /// Set the eci parameter + /// + /// Integer + /// AuthenticationsBuilder + public AuthenticationsBuilder eci(int data) + { + this.properties[ThreeDSecureConstants.eci] = data; + return this; + } + + /// + /// Set the cavv parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder cavv(string data) + { + this.properties[ThreeDSecureConstants.cavv] = data; + return this; + } + + /// + /// Set the xid parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder xid(string data) + { + this.properties[ThreeDSecureConstants.xid] = data; + return this; + } + + /// + /// Set the enrollmentId parameter + /// + /// string + /// AuthenticationsBuilder + public AuthenticationsBuilder enrollmentId(string data) + { + this.properties[ThreeDSecureConstants.enrollmentId] = data; + return this; + } + } + } +} diff --git a/Paysafe/ThreeDSecure/Card.cs b/Paysafe/ThreeDSecure/Card.cs new file mode 100644 index 0000000..a2d750a --- /dev/null +++ b/Paysafe/ThreeDSecure/Card.cs @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.ThreeDSecure +{ + public class Card : JSONObject + { + + /// + /// Initialize the Card object with some set of properties + /// + /// Dictionary + public Card(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + /// + /// This object is used to validate any properties set within the object + /// + private static new Dictionary fieldTypes = new Dictionary + { + {ThreeDSecureConstants.paymentToken, STRING_TYPE}, + {ThreeDSecureConstants.cardNum, STRING_TYPE}, + {ThreeDSecureConstants.cardType, ThreeDSecureConstants.enumType}, + {ThreeDSecureConstants.lastDigits, STRING_TYPE}, + {ThreeDSecureConstants.cardExpiry, typeof(CardExpiry)}, + {ThreeDSecureConstants.cvv, STRING_TYPE}, + {ThreeDSecureConstants.track1, STRING_TYPE}, + {ThreeDSecureConstants.track2, STRING_TYPE}, + }; + + /// + /// Get the payment token + /// + /// string + public string paymentToken() + { + return this.getProperty(ThreeDSecureConstants.paymentToken); + } + + /// + /// Set the payment token + /// + /// string + public void paymentToken(string data) + { + this.setProperty(ThreeDSecureConstants.paymentToken, data); + } + + /// + /// Get the card number + /// + /// string + public string cardNum() + { + return this.getProperty(ThreeDSecureConstants.cardNum); + } + + /// + /// Set the card number + /// + /// string + public void cardNum(string data) + { + this.setProperty(ThreeDSecureConstants.cardNum, data); + } + + /// + /// Get the card's type + /// + /// string + public string cardType() + { + return this.getProperty(ThreeDSecureConstants.cardType); + } + + /// + /// Set the card's type + /// + /// string + public void cardType(string data) + { + this.setProperty(ThreeDSecureConstants.cardType, data); + } + + /// + /// Get the card's last digits + /// + /// string + public string lastDigits() + { + return this.getProperty(ThreeDSecureConstants.lastDigits); + } + + /// + /// Set the card's last digits + /// + /// string + public void lastDigits(string data) + { + this.setProperty(ThreeDSecureConstants.lastDigits, data); + } + + /// + /// Get the card expiry + /// + /// CardExpiry + public CardExpiry cardExpiry() + { + return this.getProperty(ThreeDSecureConstants.cardExpiry); + } + + /// + /// Set the card expiry + /// + /// CardExpiry + public void cardExpiry(CardExpiry data) + { + this.setProperty(ThreeDSecureConstants.cardExpiry, data); + } + + /// + /// Get the card cvv + /// + /// string + public string cvv() + { + return this.getProperty(ThreeDSecureConstants.cvv); + } + + /// + /// Set the card cvv + /// + /// string + public void cvv(string data) + { + this.setProperty(ThreeDSecureConstants.cvv, data); + } + + /// + /// Get the track1 data + /// + /// string + public string track1() + { + return this.getProperty(ThreeDSecureConstants.track1); + } + + /// + /// Set the track1 data + /// + /// string + public void track1(string data) + { + this.setProperty(ThreeDSecureConstants.track1, data); + } + + /// + /// Get the track2 data + /// + /// string + public string track2() + { + return this.getProperty(ThreeDSecureConstants.track1); + } + + /// + /// Set the track2 data + /// + /// string + public void track2(string data) + { + this.setProperty(ThreeDSecureConstants.track2, data); + } + + /// + /// CardBuilder will allow an card to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back tot he parent builder + /// + public class CardBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Card builder within the context of a parent builder + /// + /// TBLDR + public CardBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the payment token + /// + /// string + /// CardBuilder + public CardBuilder paymentToken(string data) + { + this.properties[ThreeDSecureConstants.paymentToken] = data; + return this; + } + + /// + /// Set the card number + /// + /// string + /// CardBuilder + public CardBuilder cardNum(string data) + { + this.properties[ThreeDSecureConstants.cardNum] = data; + return this; + } + + /// + /// Set the card's type + /// + /// string + /// CardBuilder + public CardBuilder cardType(string data) + { + this.properties[ThreeDSecureConstants.cardType] = data; + return this; + } + + /// + /// Set the card's last digits + /// + /// string + /// CardBuilder + public CardBuilder lastDigits(string data) + { + this.properties[ThreeDSecureConstants.lastDigits] = data; + return this; + } + + /// + /// Build a card expiry within this card. + /// + /// CardExpiry.CardExpiryBuilder> + public CardExpiry.CardExpiryBuilder> cardExpiry() + { + if (!this.properties.ContainsKey(ThreeDSecureConstants.cardExpiry)) + { + this.properties[ThreeDSecureConstants.cardExpiry] = new CardExpiry.CardExpiryBuilder>(this); + } + return this.properties[ThreeDSecureConstants.cardExpiry] as CardExpiry.CardExpiryBuilder>; + } + + /// + /// Set the card cvv + /// + /// string + /// CardBuilder + public CardBuilder cvv(string data) + { + this.properties[ThreeDSecureConstants.cvv] = data; + return this; + } + + /// + /// Set the track1 data + /// + /// string + /// CardBuilder + public CardBuilder track1(string data) + { + this.properties[ThreeDSecureConstants.track1] = data; + return this; + } + + /// + /// Set the track2 data + /// + /// string + /// CardBuilder + public CardBuilder track2(string data) + { + this.properties[ThreeDSecureConstants.track2] = data; + return this; + } + } + } +} diff --git a/Paysafe/ThreeDSecure/EnrollmentChecks.cs b/Paysafe/ThreeDSecure/EnrollmentChecks.cs new file mode 100644 index 0000000..2b82c63 --- /dev/null +++ b/Paysafe/ThreeDSecure/EnrollmentChecks.cs @@ -0,0 +1,560 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.ThreeDSecure +{ + //Created by Tushar.Sukhiya on 03.05.2016. This is EnrollmentChecks class. + public class EnrollmentChecks: JSONObject + { + /// + /// Initialize the EnrollmentLookups object with some set of properties + /// + /// Dictionary + public EnrollmentChecks(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {ThreeDSecureConstants.id, STRING_TYPE}, + {ThreeDSecureConstants.merchantRefNum, STRING_TYPE}, + {ThreeDSecureConstants.amount, INT_TYPE}, + {ThreeDSecureConstants.currency, STRING_TYPE}, + {ThreeDSecureConstants.card, typeof(Card)}, + {ThreeDSecureConstants.customerIp, STRING_TYPE}, + {ThreeDSecureConstants.userAgent, STRING_TYPE}, + {ThreeDSecureConstants.acceptHeader, STRING_TYPE}, + {ThreeDSecureConstants.merchantUrl, STRING_TYPE}, + {ThreeDSecureConstants.txnTime, typeof(DateTime)}, + {ThreeDSecureConstants.error, typeof(Error)}, + {ThreeDSecureConstants.status, ThreeDSecureConstants.enumStatus}, + {ThreeDSecureConstants.acsURL, STRING_TYPE}, + {ThreeDSecureConstants.paReq, STRING_TYPE}, + {ThreeDSecureConstants.eci, INT_TYPE}, + {ThreeDSecureConstants.threeDEnrollment, ThreeDSecureConstants.enumThreeDEnrollment}, + {ThreeDSecureConstants.links, typeof(List)} + }; + + /// + /// Get the id + /// + /// String + public string id() + { + return this.getProperty(ThreeDSecureConstants.id); + } + + /// + /// Set the id + /// + /// void + public void id(String data) + { + this.setProperty(ThreeDSecureConstants.id, data); + } + + /// + /// Get the merchantRefNum + /// + /// String + public string merchantRefNum() + { + return this.getProperty(ThreeDSecureConstants.merchantRefNum); + } + + /// + /// Set the merchantRefNum + /// + /// void + public void merchantRefNum(String data) + { + this.setProperty(ThreeDSecureConstants.merchantRefNum, data); + } + + /// + /// Get the amount + /// + /// Integer + public int amount() + { + return this.getProperty(ThreeDSecureConstants.amount); + } + + /// + /// Set the amount + /// + /// void + public void amount(int data) + { + this.setProperty(ThreeDSecureConstants.amount, data); + } + + /// + /// Get the currency + /// + /// String + public string currency() + { + return this.getProperty(ThreeDSecureConstants.currency); + } + + /// + /// Set the currency + /// + /// void + public void currency(String data) + { + this.setProperty(ThreeDSecureConstants.currency, data); + } + + /// + /// Get the card + /// + /// Card + public Card card() + { + return this.getProperty(ThreeDSecureConstants.card); + } + + /// + /// Set the card + /// + /// void + public void card(Card data) + { + this.setProperty(ThreeDSecureConstants.card, data); + } + + /// + /// Get the customerIp + /// + /// String + public string customerIp() + { + return this.getProperty(ThreeDSecureConstants.customerIp); + } + + /// + /// Set the customerIp + /// + /// void + public void customerIp(String data) + { + this.setProperty(ThreeDSecureConstants.customerIp, data); + } + + /// + /// Get the userAgent + /// + /// String + public string userAgent() + { + return this.getProperty(ThreeDSecureConstants.userAgent); + } + + /// + /// Set the userAgent + /// + /// void + public void userAgent(String data) + { + this.setProperty(ThreeDSecureConstants.userAgent, data); + } + + /// + /// Get the acceptHeader + /// + /// String + public string acceptHeader() + { + return this.getProperty(ThreeDSecureConstants.acceptHeader); + } + + /// + /// Set the acceptHeader + /// + /// void + public void acceptHeader(String data) + { + this.setProperty(ThreeDSecureConstants.acceptHeader, data); + } + + /// + /// Get the merchantUrl + /// + /// String + public string merchantUrl() + { + return this.getProperty(ThreeDSecureConstants.merchantUrl); + } + + /// + /// Set the merchantUrl + /// + /// void + public void merchantUrl(String data) + { + this.setProperty(ThreeDSecureConstants.merchantUrl, data); + } + + /// + /// Get the txnTime + /// + /// DateTime + public DateTime txnTime() + { + return this.getProperty(ThreeDSecureConstants.txnTime); + } + + /// + /// Set the txnTime + /// + /// void + public void txnTime(DateTime data) + { + this.setProperty(ThreeDSecureConstants.txnTime, data); + } + + /// + /// Get the error + /// + /// Error + public Error error() + { + return this.getProperty(ThreeDSecureConstants.error); + } + + /// + /// Set the error + /// + /// void + public void error(Error data) + { + this.setProperty(ThreeDSecureConstants.error, data); + } + + /// + /// Get the status + /// + /// String + public string status() + { + return this.getProperty(ThreeDSecureConstants.status); + } + + /// + /// Set the status + /// + /// String + public void status(String data) + { + this.setProperty(ThreeDSecureConstants.status, data); + } + + /// + /// Get the acsURL + /// + /// String + public string acsURL() + { + return this.getProperty(ThreeDSecureConstants.acsURL); + } + + /// + /// Set the acsURL + /// + /// String + public void acsURL(String data) + { + this.setProperty(ThreeDSecureConstants.acsURL, data); + } + + /// + /// Get the paReq + /// + /// String + public string paReq() + { + return this.getProperty(ThreeDSecureConstants.paReq); + } + + /// + /// Set the paReq + /// + /// String + public void paReq(String data) + { + this.setProperty(ThreeDSecureConstants.paReq, data); + } + + /// + /// Get the eci + /// + /// Integer + public int eci() + { + return this.getProperty(ThreeDSecureConstants.eci); + } + + /// + /// Set the eci + /// + /// void + public void eci(int data) + { + this.setProperty(ThreeDSecureConstants.eci, data); + } + + /// + /// Get the threeDEnrollment + /// + /// String + public string threeDEnrollment() + { + return this.getProperty(ThreeDSecureConstants.threeDEnrollment); + } + + /// + /// Set the threeDEnrollment + /// + /// String + public void threeDEnrollment(String data) + { + this.setProperty(ThreeDSecureConstants.threeDEnrollment, data); + } + + /// + /// Get the Links + /// + /// Link + public List links() + { + return this.getProperty(ThreeDSecureConstants.links); + } + + /// + /// Set the Links + /// + /// void + public void links(List data) + { + this.setProperty(ThreeDSecureConstants.error, data); + } + + public static EnrollmentChecksBuilder Builder() + { + return new EnrollmentChecksBuilder(); + } + + /// + /// EnrollmentChecksBuilder will allow an authorization to be initialized. + /// set all properties and subpropeties, then trigger .Build() to + /// get the generated EnrollmentLookups object + /// + public class EnrollmentChecksBuilder : BaseJSONBuilder + { + /// + /// Set the id parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder id(string data) + { + this.properties[ThreeDSecureConstants.id] = data; + return this; + } + + /// + /// Set the merchantRefNum parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder merchantRefNum(string data) + { + this.properties[ThreeDSecureConstants.merchantRefNum] = data; + return this; + } + + /// + /// Set the amount parameter + /// + /// Integer + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder amount(int data) + { + this.properties[ThreeDSecureConstants.amount] = data; + return this; + } + + /// + /// Set the currency parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder currency(string data) + { + this.properties[ThreeDSecureConstants.currency] = data; + return this; + } + + /// + /// Build a card within this EnrollmentLookups. + /// + /// Card.CardBuilder + public Card.CardBuilder card() + { + if (!this.properties.ContainsKey(ThreeDSecureConstants.card)) + { + this.properties[ThreeDSecureConstants.card] = new Card.CardBuilder(this); + } + return this.properties[ThreeDSecureConstants.card] as Card.CardBuilder; + } + + /// + /// Set the customerIp parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder customerIp(string data) + { + this.properties[ThreeDSecureConstants.customerIp] = data; + return this; + } + + /// + /// Set the userAgent parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder userAgent(string data) + { + this.properties[ThreeDSecureConstants.userAgent] = data; + return this; + } + + /// + /// Set the acceptHeader parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder acceptHeader(string data) + { + this.properties[ThreeDSecureConstants.acceptHeader] = data; + return this; + } + + /// + /// Set the merchantUrl parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder merchantUrl(string data) + { + this.properties[ThreeDSecureConstants.merchantUrl] = data; + return this; + } + + /// + /// Set the txnTime parameter + /// + /// DateTime + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder txnTime(DateTime data) + { + this.properties[ThreeDSecureConstants.txnTime] = data; + return this; + } + + /// + /// Build a Error object within this EnrollmentChecksBuilder. + /// + /// Error.ErrorBuilder + public Error.ErrorBuilder error() + { + if (!this.properties.ContainsKey(ThreeDSecureConstants.error)) + { + this.properties[ThreeDSecureConstants.error] = new Error.ErrorBuilder(this); + } + return this.properties[ThreeDSecureConstants.error] as Error.ErrorBuilder; + } + + /// + /// Set the status parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder status(string data) + { + this.properties[ThreeDSecureConstants.status] = data; + return this; + } + + /// + /// Set the acsURL parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder acsURL(string data) + { + this.properties[ThreeDSecureConstants.acsURL] = data; + return this; + } + + /// + /// Set the paReq parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder paReq(string data) + { + this.properties[ThreeDSecureConstants.paReq] = data; + return this; + } + + /// + /// Set the eci parameter + /// + /// Integer + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder eci(int data) + { + this.properties[ThreeDSecureConstants.eci] = data; + return this; + } + + /// + /// Set the threeDEnrollment parameter + /// + /// string + /// EnrollmentChecksBuilder + public EnrollmentChecksBuilder threeDEnrollment(string data) + { + this.properties[ThreeDSecureConstants.threeDEnrollment] = data; + return this; + } + } + } +} diff --git a/Paysafe/ThreeDSecure/Error.cs b/Paysafe/ThreeDSecure/Error.cs new file mode 100644 index 0000000..720250c --- /dev/null +++ b/Paysafe/ThreeDSecure/Error.cs @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.ThreeDSecure +{ + //Created by Tushar.Sukhiya on 03.05.2016. This is Error Class. + public class Error : JSONObject + { + /// + /// Initialize the Error object with some set of properties + /// + /// Dictionary + public Error(Dictionary properties = null) + : base(fieldTypes, properties) + { + } + + private static new Dictionary fieldTypes = new Dictionary + { + {ThreeDSecureConstants.code, STRING_TYPE}, + {ThreeDSecureConstants.message, STRING_TYPE} + }; + + /// + /// Get the code + /// + /// String + public string code() + { + return this.getProperty(ThreeDSecureConstants.code); + } + + /// + /// Set the code + /// + /// void + public void code(String data) + { + this.setProperty(ThreeDSecureConstants.code, data); + } + + /// + /// Get the message + /// + /// String + public string message() + { + return this.getProperty(ThreeDSecureConstants.message); + } + + /// + /// Set the message + /// + /// void + public void message(String data) + { + this.setProperty(ThreeDSecureConstants.message, data); + } + + /// + /// ErrorBuilder will allow an Error to be initialized + /// within another builder. Set properties and subpropeties, then trigger .Done() to + /// get back tot he parent builder + /// + public class ErrorBuilder : NestedJSONBuilder + where TBLDR : GenericJSONBuilder + { + /// + /// Initialize the Error builder within the context of a parent builder + /// + /// TBLDR + public ErrorBuilder(TBLDR parent) + : base(parent) + { + this.parent = parent; + } + + /// + /// Set the code + /// + /// string + /// ErrorBuilder + public ErrorBuilder code(string data) + { + this.properties[ThreeDSecureConstants.code] = data; + return this; + } + + /// + /// Set the message + /// + /// string + /// ErrorBuilder + public ErrorBuilder message(string data) + { + this.properties[ThreeDSecureConstants.message] = data; + return this; + } + } + } +} diff --git a/Paysafe/ThreeDSecure/ThreeDSecureConstants.cs b/Paysafe/ThreeDSecure/ThreeDSecureConstants.cs new file mode 100644 index 0000000..839835d --- /dev/null +++ b/Paysafe/ThreeDSecure/ThreeDSecureConstants.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.ThreeDSecure +{ + //Created by Tushar.Sukhiya on 03.05.2016. This is ThreeDSecureConstants class. + class ThreeDSecureConstants: GlobalConstants + { + public static readonly List enumStatus = new List() { + statusCompleted, + statusFailed + }; + public static readonly List enumThreeDEnrollment = new List() { + threeDEnrolled, //Cardholder authentication available + threeDNotEnrolled, // Cardholder not enrolled in authentication + threeDEnrollmentUnavailable //Cardholder authentication unavailable + }; + public static readonly List enumThreeDResult = new List() { + authenticated, //Cardholder authentication available + authenticationAttempted, //Cardholder authentication attempted + authenticationFailed, //Cardholder authentication Failed + authenticationUnavailable, //Cardholder authentication Unavailable + authenticationError //Cardholder authentication Error + }; + public static readonly List enumSignatureStatus = new List() { + signatureSatisfied, //All transaction and signature checks satisfied + signatureNotSatisfied, //At least one transaction or signature check failed + }; + public static readonly List enumType = new List() { + AM ,// American Express + DC ,// Diners Club + DI ,//Discover + JC ,// JCB + MC ,//MasterCard + MD ,// Maestro + SF ,// Swiff + SO ,// Solo + VI ,// Visa + VD ,// Visa Debit + VE // Visa Electron + }; + } +} diff --git a/Paysafe/ThreeDSecure/ThreeDSecureService.cs b/Paysafe/ThreeDSecure/ThreeDSecureService.cs new file mode 100644 index 0000000..ff13a53 --- /dev/null +++ b/Paysafe/ThreeDSecure/ThreeDSecureService.cs @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2014 Optimal Payments + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Paysafe.Common; + +namespace Paysafe.ThreeDSecure +{ + //Created by Tushar.Sukhiya on 03.05.2016. This is ThreeDSecureService class + public class ThreeDSecureService + { + /// + /// The api client, performs all http requests + /// + private PaysafeApiClient client; + + /// + /// The ThreeDSecure api base uri + /// + private string uri = "threedsecure/v1"; + + /// + /// Initialize the ThreeDSecure service with an client object + /// + /// PaysafeApiClient + public ThreeDSecureService(PaysafeApiClient client) + { + this.client = client; + } + + /// + /// Check if the service is available + /// + /// true if successful + public Boolean monitor() + { + Request request = new Request(uri: "threedsecure/monitor"); + dynamic response = this.client.processRequest(request); + + return ("READY".Equals((string)(response[ThreeDSecureConstants.status]))); + } + + /// + /// Submit an enrollment lookup request + /// + /// EnrollmentLookups + /// EnrollmentLookups + public EnrollmentChecks submit(EnrollmentChecks enrollmentChecks) + { + enrollmentChecks.setRequiredFields(new List { + ThreeDSecureConstants.merchantRefNum, + ThreeDSecureConstants.amount, + ThreeDSecureConstants.currency, + ThreeDSecureConstants.card, + ThreeDSecureConstants.customerIp, + ThreeDSecureConstants.userAgent, + ThreeDSecureConstants.acceptHeader, + ThreeDSecureConstants.merchantUrl + }); + + enrollmentChecks.checkRequiredFields(); + + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/accounts/" + client.account() +"/enrollmentchecks"), + body: enrollmentChecks + ); + dynamic response = this.client.processRequest(request); + + return new EnrollmentChecks(response); + } + + /// + /// Get the Enrollment Lookup + /// + /// EnrollmentLookups + /// EnrollmentLookups + public EnrollmentChecks get(EnrollmentChecks enrollmentChecks) + { + enrollmentChecks.setRequiredFields(new List { ThreeDSecureConstants.id }); + enrollmentChecks.checkRequiredFields(); + + Request request = new Request( + uri: this.prepareURI("/accounts/" + client.account() + "/enrollmentchecks/" + enrollmentChecks.id()) + ); + + dynamic response = this.client.processRequest(request); + + return new EnrollmentChecks(response); + } + + /// + /// Submit an authentications request + /// + /// Authentications + /// Authentications + public Authentications submit(Authentications authentications) + { + authentications.setRequiredFields(new List { + ThreeDSecureConstants.merchantRefNum, + ThreeDSecureConstants.paResp, + }); + + authentications.checkRequiredFields(); + Request request = new Request( + method: RequestType.POST, + uri: this.prepareURI("/accounts/" + client.account() + "/enrollmentchecks/" + authentications.enrollmentId() + "/authentications"), + body: authentications + ); + dynamic response = this.client.processRequest(request); + + return new Authentications(response); + } + + /// + /// Get an authentication usind id + /// + /// Authentications + /// Authentications + public Authentications get(Authentications authentications, bool includeEnrollment = false) + { + authentications.setRequiredFields(new List { ThreeDSecureConstants.id }); + authentications.checkRequiredFields(); + + Dictionary queryStr = new Dictionary(); + StringBuilder toInclude = new StringBuilder(); + + if (includeEnrollment) + { + toInclude.Append("enrollmentchecks"); + } + queryStr.Add("fields", toInclude.ToString()); + + Request request = new Request( + uri: this.prepareURI("/accounts/" + client.account() + "/authentications/" + authentications.id()), + queryString : queryStr + ); + + dynamic response = this.client.processRequest(request); + + return new Authentications(response); + } + + private string prepareURI(string path) + { + return this.uri + path; + } + } +} diff --git a/Paysafe/app.config b/Paysafe/app.config new file mode 100644 index 0000000..0195a71 --- /dev/null +++ b/Paysafe/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Paysafe/packages.config b/Paysafe/packages.config new file mode 100644 index 0000000..b0017c9 --- /dev/null +++ b/Paysafe/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 8632b80..7a8f091 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ -# paysafe_sdk_csharp -Paysafe C-Sharp SDK +# Paysafe Payments C# SDK + +--- + +## Installation + +Building this SDK requires Microsoft Visual Studio 2013 Professional to be installed. + +## Usage + +### Running Sample Code + +Launch Microsoft Visual Studio and open the SDK project. In the Solution Explorer, locate *SampleApp* and right-click on it then click *View -> View in Browser*. This will launch the sample application. \ No newline at end of file diff --git a/SampleApp/3DS classification.html b/SampleApp/3DS classification.html new file mode 100644 index 0000000..ae8b300 --- /dev/null +++ b/SampleApp/3DS classification.html @@ -0,0 +1,24 @@ + + + + + + +

Three D Secure API

+ + + diff --git a/SampleApp/Properties/AssemblyInfo.cs b/SampleApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9c202d0 --- /dev/null +++ b/SampleApp/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SampleApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SampleApp")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1a229e79-2f8f-4cac-9895-7c163d6a7c14")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SampleApp/SampleApp.csproj b/SampleApp/SampleApp.csproj new file mode 100644 index 0000000..c58339d --- /dev/null +++ b/SampleApp/SampleApp.csproj @@ -0,0 +1,246 @@ + + + + + Debug + AnyCPU + + + 2.0 + {A98AFF11-EA57-4475-9A27-7DB43053BA3F} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + SampleApp + SampleApp + v4.5 + true + + + + + 65047319 + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + card-payment-simple.aspx + ASPXCodeBehind + + + card-payment-simple.aspx + + + card-payment-w-customervault.aspx + ASPXCodeBehind + + + card-payment-w-customervault.aspx + + + customervault-mandate-w-BACSAccount.aspx + ASPXCodeBehind + + + customervault-mandate-w-BACSAccount.aspx + + + customervault-mandate-w-SEPAAccount.aspx + ASPXCodeBehind + + + customervault-mandate-w-SEPAAccount.aspx + + + customervault-w-ACHAccount.aspx + ASPXCodeBehind + + + customervault-w-ACHAccount.aspx + + + customervault-w-BACSAccount.aspx + ASPXCodeBehind + + + customervault-w-BACSAccount.aspx + + + customervault-w-EFTAccount.aspx + ASPXCodeBehind + + + customervault-w-EFTAccount.aspx + + + customervault-w-SEPAAccount.aspx + ASPXCodeBehind + + + customervault-w-SEPAAccount.aspx + + + direct-debit-purchase-ACHAccount.aspx + ASPXCodeBehind + + + direct-debit-purchase-ACHAccount.aspx + + + direct-debit-purchase-EFTAccount.aspx + ASPXCodeBehind + + + direct-debit-purchase-EFTAccount.aspx + + + direct-debit-purchase-w-token-all accounts.aspx + ASPXCodeBehind + + + direct-debit-purchase-w-token-all accounts.aspx + + + direct-debit-standalonecredits-ACHAccount.aspx + ASPXCodeBehind + + + direct-debit-standalonecredits-ACHAccount.aspx + + + direct-debit-standalonecredits-EFTAccount.aspx + ASPXCodeBehind + + + direct-debit-standalonecredits-EFTAccount.aspx + + + direct-debit-standalonecredits-w-token-all accounts.aspx + ASPXCodeBehind + + + direct-debit-standalonecredits-w-token-all accounts.aspx + + + + ThreeDSecure_Authentication.aspx + ASPXCodeBehind + + + ThreeDSecure_Authentication.aspx + + + ThreeDSecure_EnrollmentChecks.aspx + ASPXCodeBehind + + + ThreeDSecure_EnrollmentChecks.aspx + + + + + Web.config + + + Web.config + + + + + {1aa4f97b-967a-4420-b3cc-ef1efbaa72f8} + Paysafe + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 64618 + / + http://localhost:64618/ + False + False + + + False + + + + + + \ No newline at end of file diff --git a/SampleApp/SampleApp.csproj.user b/SampleApp/SampleApp.csproj.user new file mode 100644 index 0000000..d2c6185 --- /dev/null +++ b/SampleApp/SampleApp.csproj.user @@ -0,0 +1,27 @@ + + + + + + + index.html + SpecificPage + True + False + False + False + + + + + + + + + True + True + + + + + \ No newline at end of file diff --git a/SampleApp/ThreeDSecure_Authentication.aspx b/SampleApp/ThreeDSecure_Authentication.aspx new file mode 100644 index 0000000..2cfd8fc --- /dev/null +++ b/SampleApp/ThreeDSecure_Authentication.aspx @@ -0,0 +1,138 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ThreeDSecure_Authentication.aspx.cs" Inherits="SampleApp.ThreeDSecure_Authentication" %> + + + + + + Three D Secure Authentications Request + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ EnrollmentChecks Request +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ Card +
+ +
+
+ +
+
+ +
+ +
+ +
+ Authentications Request +
+ +
+
+ +
+
+ +
+ + +
+ + + + <% } %> + + \ No newline at end of file diff --git a/SampleApp/ThreeDSecure_Authentication.aspx.cs b/SampleApp/ThreeDSecure_Authentication.aspx.cs new file mode 100644 index 0000000..9a544a8 --- /dev/null +++ b/SampleApp/ThreeDSecure_Authentication.aspx.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Paysafe; +using Authentication = Paysafe.ThreeDSecure.Authentications; +using EnrollmentChecks = Paysafe.ThreeDSecure.EnrollmentChecks; + +namespace SampleApp +{ + public partial class ThreeDSecure_Authentication : System.Web.UI.Page + { + protected string response = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + try + { + EnrollmentChecks enrollmentChecks = EnrollmentChecks.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .currency(Request.Form["currency"]) + .customerIp(Request.Form["customerIp"]) + .userAgent(Request.Form["userAgent"]) + .card() + .cardNum(Request.Form["cardNum"]) + .cardExpiry() + .month(Convert.ToInt32(Double.Parse(Request.Form["month"]))) + .year(Convert.ToInt32(Double.Parse(Request.Form["year"]))) + .Done() + .Done() + .acceptHeader(Request.Form["acceptHeader"]) + .merchantUrl(Request.Form["merchantUrl"]) + .Build(); + + EnrollmentChecks response_enrollmentChecks = client.threeDSecureService().submit(enrollmentChecks); + + enrollmentChecks.id("1346db4c-817e-47bb-9752-3a59f3e350f2"); + + Authentication authentications = Authentication.Builder() + .merchantRefNum(enrollmentChecks.merchantRefNum()) + .paResp("eJzNWNey4ziS/ZWKmkdFN72bUN0J0FMiRZGi1UsHnehEIxrRfP1Q91ZX362o2Jjd3ofVi4BEZuIkEnkAcP+vubp/eSZdnzf1t6/I7/DXL0kdNXFep9++2pb4G/31X297K+uShL8k0dglb3st6fsgTb7k8bevXbnAv8O/I39EYdo/u2qAkT8QnEQZEsFp5g+GQREa/wNFv77tz8BM+nejf7w3v6sRCPMbhpAovKl8B/K24fgd3UN/drcZuygL6uFtH0QPVjm94QzKwPAe+t7dV0mn8G8kjdAMvhl+dPfQX3bn8dXqN/RzHr/56KGOsOsSesakXUBqG/bqrJeUT8G3PfTS2MfBkLyhMELCBIJ8QeB/Isg/UWYPvcv37csdqJpx8428gHwW7Ldl6rZVXN5ofBv60dsnc9vUyaaxQfzR3kN/YWuD+g3+9MNI6uV7k+4t720/5NUvMb3L9/0QDGP/5u+h7619FDyfb1oBUh/NsqgSi1hyFkVC7hF2yq6ovcX6rrJPovwNJjZQ2/+7FbinTZcPWfWGfOj8JdhDLyjQewrf9pc8rbfJuuTLtpHq/tvXbBjaf0LQNE2/T9jvTZdC6BYIBDPQphD3efqPrx9WSazUt+Z/ZMYFdVPnUXDP12DYNoaWDFkTf/mB7VduLPPlCYFMgfttc/VbhOD1by8JjCHE5hP6tdNPkf0ns/wMtuuD3/osQF4T/OTobW8mt+S1I5Ivtqls1YCgFE2RLzB8nib98L+Z8M/JPnv4058T3Mfk7Vpciiq/kQKvgqNHIugzrc9Oi8Y6/u1Puw/NPfQD4Xf4H7n6tCYfiiNNwFjc1SnlcrnTUD6FmMrBgXyILBBi1gJPOpgPGNV41ZW9jDhKnn86+BTLEQC9tYmcF5V3qdecWmD+tvZzP+MGNatBazBRzzauISxrExcQJSwTwVz0q8+coZZOa7BOSCc9xGBwHhMc05iIG2VagcYdj0JtcPAlHXn23JHXoy6Yu3DKWxrDx1EEvmYA5lnjzpERQ4YmZda6sZZbjpgywctRQnbDahyeYcrcSFy4QLUNyIUhMldz+5GoLXfIh4tlpNRUocJlfLBXRV9BZledK/bYqKQ8fMqvLEaJvZcTRZdW411eRm8EbbgMp90FCa3HSbvDTNgwBu9M2G3IClXtPLnPOio3p2/fPu2Z7xk5JstHBjwCZvhgCD5aXNIN+W3bvBsnaYrC+zzHgTLlOIMPZMOxBlsIEQuc2LR8ZGUuMRPMAsMWAc+umhlNouHzjmEowkTwvovkUXUvr6izBtJ9uVrCRWOBBBBbYGftYKDi4NeH9irFd83UJuHDlhemdvDd+BkuyBJurKyZYOLT9zFVmGL96pmc7xK4ZvQT92EjCdNBNgrB0AD+7p/LNNmqHNioxDHhQSJO8HyyhEWzhEm3NETjzWCTLe8yPv0h02RhFlfgsOnJYUFq8eUpC93DErhmffVOTeAdNqzKJID3eWVhun+K054FC5w/bDWLk5CNE5mn6p6yvx/DloeLMvGGfzg2VyV7RidgCCxrAD5NhTN4jRsNt7VZoKtGpqrnPNsOteUhcYfArYHjqHrYsNndwM7nOleeMfy4cvU4DOoa9rJVZnO/O6ypVJZOhcGShkpFej5yyW6pzFiqTTO6grNSSN5wz02LKkpVSQWcKansdjvlRW0Xx+uuuYzgmMejfOvmRIgNhwvV0o0wiqePjA2MQHdo1bOmgS8UShmWDqBKzBbKmSpRNIprSpdgWwzkq9c4qudSRDrZRFEmxpw9dqTOG7fVPgQNM49DrzswzN7wWEeWFpebC3nOxwQf8lAMfQcvhqIUpAqy5C5HrtsqQXAunyzFUA3KKsRlEeQDShzsagAKxwZu3GroNNyr8cYuHH83mFa8p4Y/0mRQwP1a9BzYsg5+tfeBvq29AO6VFzzDyjAmp8lhQydc9a62fAG3PWtRDil02WMGYYaUgQVjRdO5j8yNuCti++ja6mil3WfmSOnN49ZpgnvgafLqk8QZrrxTT6xZXMpowJSOe5lCp3vG/dPm6/5ulQlGYuP1GTcWM+9OK8WurraQSCtO5tVo+PNdc0jDRg8IoqUXx4l3KJTsYim5ZN6cnVzGrbApD7lJKCTE4Fh54bi8QzoGUBgv7OpmmPFjiWgeaxQD/2B7rbkZ7Xjq3JEMS9zygtrCzoEsHZOg7tnT8X5K7+Roc7T/oBQTGGbEWo6QdALeovcJcBfiImpkgZ1nC2fwExCKpxFVDzUrp5scFoAsaNdeJhwjssJ4kdfPzPRrqipeVNVsVMUtw2rmLukg1fpLqpr/HlUJEz/9SVXZn1RV+Nan0p0/l66gaqD88JVpnAkrs8AD/YMmGouFiXssHLKwTic5i06aZc9aIcwaX64nC8DuS1a8ZAD/IStY5O/FYE/CjxjmHzGE0v0e1sYnfP1nfDO3gsOH3LdAGXOfaO34X2hNUVil+Hnthe+lQoPXOJce38tmqJoqUY8XGht3OtxR7em4S2YjUUqqq7tDdbvSpt0nRLmDF+dUWeeLfE5dB4mkgFcXo88psSLK86FYLxc1R6JlNQG3BMJZgNjdtru6vo5aXntyuoNYPsZGbLgA7k7oV2SaiEbzLzdkdvrjvYw9r0LNR9s7t0scmhMuXdWFDu4w4Xkp0JZby7DH2BfC0JDTYnqIJp9laHfmzXLOw/RUoZ27Cx4HRfdoUdMz2VDyrucU8aHU+B2748SOuDEL23VIfWQWgRqNxmwaP1iK09Of02OkqDTlXekVqXwd1otgpq9cc7kqfoTBiDaK4sRECB1q2SKfSOLyFKeh9pMGvTFqEab3VdB8TtuWWpgUHhiA1QAscZeHdFFCjH8/LmwAcGXLBVBZVMRuzhhWXjlfkqfSU1ZyJSnrbqHASQR0dz1SYx/qU0vI8iFOKOip7C6U6PpjY07tLMmPqq/R/G7kDX7XA3bx1yPT0M+AD1hriowG4i+0OqGZbLJDLDxvS3Rkc/VCdZIB+dpOPqj3Zj3dVvi6Yn3OX0qr7YJ7ZwTWDSPvMl6uJkoBlnd2XlecvCZbdTVg8SN2khJUybhQN89jyRA7BXaotOJ0vhRIu1memoi2R/KiKY9RxKfiOB2QQwCuMedE7LzajXq6KQkU3AUbf9xws+bN4hm0KOWEHC+T3oG/LSLFXFQR85hDi87NCsFOn1aJcTo30QzxhAWYGMGkllJ4Ur8F5vUxaBk8/WdUJRgvqloeKZi2VKTKAajuGql13Kxx+quUabL2924lKzB/3Eqq77cSb7uTYv8Hpc7iHm8JiGYps2YBQlvt6SQ2m0x5ySad/yGbolXwNNb+oEhW0z9TUoRmbVRtWAtgfMwbWZz9KU5LsDRWeLcFs3YMXbEOUXqIKuYZ83+ferebU/7z2oPv5cJP4DV+BM2rdDh0ptHrdsE6RmpGeMgce6PSmdITnMjzcr5N7QGliLXX/V0cV5FkkvXN1m1Wq11BubBxuT2WaaeezxzKBNgcQZKZS60Q38pEb7RhpgXYtWiiugqc1YtVnR+UY24Mzgli9dFucD9JWpZr1vwYnxdML3mRYKAUPju45aoRXMK2a3a06EUBG9Pp7bQbuKdL3mQckvubEwNa0UaOuITa02tUHGJ60i25YnvK+a6W8IGW2a1/P1P6nI7H1o+aTF2o3hdQPTTY+pAUFO49T9z9EVvD6rY5kMy4iDHHdHLPI1sSS3l32qU7PW6BEuA0f4tKaHsUKjnulbINoHHc1mRO+Bhr1aNnYYtfrBtPp9thBbY7Z7zlIrYn+XW0mbDOsr4gSvoqGY0f7nZYPUh6zo58kAxXJDZETZHur3zKF01Ir/CUXh/gv9NvvKSMrf/HrxXlZz6YXjqxMG2xgg3Rjf75FSB+fwVsvC+6Ul2fd+kMH0bUcINxSxhiP0ZpyY4GtWKQ3GXxk4MIUrECsCRwv2OuB1zWoINDBxKayk56ZjyFs7PAp5WUhmiCbX34pNmL8JzIPO41G61Fxh2KTBeDoOVy9cTfmrEL1BwSlKuqS7YreuzaXDvvRGluFLSBGkNGvVVsQjLKTCs70scf9WrKEQuH6xHOC6OOnx51xIMMHjy7k8Hc7Nyye66JfIVLL6WPCeZK4mnaTpRyhBCQp4OHU/AtlS6ONp5AzRxxlWivROPHQFpDEro8lRiGFl8P0112QJKUyVGyGhdxuaM0OTWxMkCzGI1ZTVN1iI+SXsEcfi4yFrmFQ94MbNAOxxjdGb+6gUJ/vZuhH2/pv17Z758K3z9qvj5vff7Y+W+MPPYH") + .enrollmentId("1346db4c-817e-47bb-9752-3a59f3e350f2") + .Build(); + + Authentication response_authentication = client.threeDSecureService().submit(authentications); + this.response = response_authentication.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/ThreeDSecure_Authentication.aspx.designer.cs b/SampleApp/ThreeDSecure_Authentication.aspx.designer.cs new file mode 100644 index 0000000..28f8e40 --- /dev/null +++ b/SampleApp/ThreeDSecure_Authentication.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class ThreeDSecure_Authentication { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/ThreeDSecure_EnrollmentChecks.aspx b/SampleApp/ThreeDSecure_EnrollmentChecks.aspx new file mode 100644 index 0000000..9e90db3 --- /dev/null +++ b/SampleApp/ThreeDSecure_EnrollmentChecks.aspx @@ -0,0 +1,105 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ThreeDSecure.aspx.cs" Inherits="SampleApp.ThreeDSecure" %> + + + + + + Three D Secure EnrollmentChecks Request + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ EnrollmentChecks Request +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ Card +
+ +
+
+ +
+
+ +
+ +
+ + + + <% } %> + + diff --git a/SampleApp/ThreeDSecure_EnrollmentChecks.aspx.cs b/SampleApp/ThreeDSecure_EnrollmentChecks.aspx.cs new file mode 100644 index 0000000..8906d52 --- /dev/null +++ b/SampleApp/ThreeDSecure_EnrollmentChecks.aspx.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Paysafe; +using EnrollmentChecks = Paysafe.ThreeDSecure.EnrollmentChecks; + +namespace SampleApp +{ + public partial class ThreeDSecure : System.Web.UI.Page + { + protected string response = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + EnrollmentChecks enrollmentChecks = EnrollmentChecks.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .currency(Request.Form["currency"]) + .customerIp(Request.Form["customerIp"]) + .userAgent(Request.Form["userAgent"]) + .card() + .cardNum(Request.Form["cardNum"]) + .cardExpiry() + .month(Convert.ToInt32(Double.Parse(Request.Form["month"]))) + .year(Convert.ToInt32(Double.Parse(Request.Form["year"]))) + .Done() + .Done() + .acceptHeader(Request.Form["acceptHeader"]) + .merchantUrl(Request.Form["merchantUrl"]) + .Build(); + + EnrollmentChecks response = client.threeDSecureService().submit(enrollmentChecks); + this.response = response.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/ThreeDSecure_EnrollmentChecks.aspx.designer.cs b/SampleApp/ThreeDSecure_EnrollmentChecks.aspx.designer.cs new file mode 100644 index 0000000..0381bed --- /dev/null +++ b/SampleApp/ThreeDSecure_EnrollmentChecks.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class ThreeDSecure { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/Web.Debug.config b/SampleApp/Web.Debug.config new file mode 100644 index 0000000..2e302f9 --- /dev/null +++ b/SampleApp/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/SampleApp/Web.Release.config b/SampleApp/Web.Release.config new file mode 100644 index 0000000..c358444 --- /dev/null +++ b/SampleApp/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/SampleApp/Web.config b/SampleApp/Web.config new file mode 100644 index 0000000..09f0bc5 --- /dev/null +++ b/SampleApp/Web.config @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleApp/card-payment-simple.aspx b/SampleApp/card-payment-simple.aspx new file mode 100644 index 0000000..c0d0830 --- /dev/null +++ b/SampleApp/card-payment-simple.aspx @@ -0,0 +1,162 @@ +<%@ Page Async="true" Language="C#" AutoEventWireup="true" CodeBehind="card-payment-simple.aspx.cs" Inherits="SampleApp.card_payment_simple" %> + + + + + + Paysafe SDK - CardPayment Simple + + + <% if (payment_id != null) + { %> +

Payment Successful! ID: <% Response.Write(payment_id); %>

+ <% } + else + { %> +
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Order Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/card-payment-simple.aspx.cs b/SampleApp/card-payment-simple.aspx.cs new file mode 100644 index 0000000..05607e2 --- /dev/null +++ b/SampleApp/card-payment-simple.aspx.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; + +namespace SampleApp +{ + public partial class card_payment_simple : System.Web.UI.Page + { + protected String payment_id = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + string[] monthNames = ui.DateTimeFormat.MonthNames; + int monthsInYear = ui.Calendar.GetMonthsInYear(DateTime.Now.Year); + + int monthNumber = 0; + var monthsDataSource = monthNames.Take(monthsInYear).Select(monthName => new + { + Name = monthName, + Value = ++monthNumber + }); + + this.card_expiry_month.DataTextField = "Name"; + this.card_expiry_month.DataValueField = "Value"; + this.card_expiry_month.DataSource = monthsDataSource; + + this.card_expiry_month.DataBind(); + if (Request.Form["card_expiry_month"] == null) + { + this.card_expiry_month.SelectedValue = DateTime.Now.Month.ToString(); + } + + for (int i = 0; i < 5; i++) + { + String year = (DateTime.Today.Year + i).ToString(); + ListItem li = new ListItem(year, year); + this.card_expiry_year.Items.Add(li); + } + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["accountNumber"]; + int currencyBaseUnitsMultiplier = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CurrencyBaseUnitsMultiplier"]); + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + Authorization auth = client.cardPaymentService().authorize(Authorization.Builder() + .merchantRefNum(Request.Form["merchant_ref_num"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]) * currencyBaseUnitsMultiplier)) + .settleWithAuth(true) + .card() + .cardNum(Request.Form["card_number"]) + .cvv(Request.Form["card_cvv"]) + .cardExpiry() + .month(Convert.ToInt32(Request.Form["card_expiry_month"])) + .year(Convert.ToInt32(Request.Form["card_expiry_month"])) + .Done() + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .Done() + .Build()); + this.payment_id = auth.id(); + } + } +} \ No newline at end of file diff --git a/SampleApp/card-payment-simple.aspx.designer.cs b/SampleApp/card-payment-simple.aspx.designer.cs new file mode 100644 index 0000000..ece0407 --- /dev/null +++ b/SampleApp/card-payment-simple.aspx.designer.cs @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class card_payment_simple { + + /// + /// card_expiry_month control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList card_expiry_month; + + /// + /// card_expiry_year control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList card_expiry_year; + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/card-payment-w-customervault.aspx b/SampleApp/card-payment-w-customervault.aspx new file mode 100644 index 0000000..cc2f70e --- /dev/null +++ b/SampleApp/card-payment-w-customervault.aspx @@ -0,0 +1,189 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="card-payment-w-customervault.aspx.cs" Inherits="SampleApp.card_payment_w_customervault" %> + + + + + + Paysafe SDK - CardPayment With Customer Vault + + + <% if (payment_id != null) + { %> +

Payment Successful! ID: <% Response.Write(payment_id); %>

+ <% } + else + { %> +
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Order Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/card-payment-w-customervault.aspx.cs b/SampleApp/card-payment-w-customervault.aspx.cs new file mode 100644 index 0000000..0a6e3a2 --- /dev/null +++ b/SampleApp/card-payment-w-customervault.aspx.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; + +namespace SampleApp +{ + public partial class card_payment_w_customervault : System.Web.UI.Page + { + protected String payment_id = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + string[] monthNames = ui.DateTimeFormat.MonthNames; + int monthsInYear = ui.Calendar.GetMonthsInYear(DateTime.Now.Year); + + int monthNumber = 0; + var monthsDataSource = monthNames.Take(monthsInYear).Select(monthName => new + { + Name = monthName, + Value = ++monthNumber + }); + + this.card_expiry_month.DataTextField = "Name"; + this.card_expiry_month.DataValueField = "Value"; + this.card_expiry_month.DataSource = monthsDataSource; + + this.card_expiry_month.DataBind(); + if (Request.Form["card_expiry_month"] == null) + { + this.card_expiry_month.SelectedValue = DateTime.Now.Month.ToString(); + } + + for (int i = 0; i < 5; i++) + { + String year = (DateTime.Today.Year + i).ToString(); + ListItem li = new ListItem(year, year); + this.card_expiry_year.Items.Add(li); + } + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["accountNumber"]; + int currencyBaseUnitsMultiplier = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["CurrencyBaseUnitsMultiplier"]); + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(Request.Form["merchant_customer_id"]) + .locale("en_US") + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Build()); + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .profileId(profile.id()) + .Build()); + Card card = client.customerVaultService().create(Card.Builder() + .cardNum(Request.Form["card_number"]) + .cardExpiry() + .month(Convert.ToInt32(Request.Form["card_expiry_month"])) + .year(Convert.ToInt32(Request.Form["card_expiry_year"])) + .Done() + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + Authorization auth = client.cardPaymentService().authorize(Authorization.Builder() + .merchantRefNum(Request.Form["merchant_ref_num"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]) * currencyBaseUnitsMultiplier)) + .settleWithAuth(true) + .card() + .paymentToken(card.paymentToken()) + .Done() + .Build()); + this.payment_id = auth.id(); + } + } +} \ No newline at end of file diff --git a/SampleApp/card-payment-w-customervault.aspx.designer.cs b/SampleApp/card-payment-w-customervault.aspx.designer.cs new file mode 100644 index 0000000..f2d9f31 --- /dev/null +++ b/SampleApp/card-payment-w-customervault.aspx.designer.cs @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class card_payment_w_customervault { + + /// + /// card_expiry_month control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList card_expiry_month; + + /// + /// card_expiry_year control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList card_expiry_year; + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervault-mandate-w-BACSAccount.aspx b/SampleApp/customervault-mandate-w-BACSAccount.aspx new file mode 100644 index 0000000..0272ccd --- /dev/null +++ b/SampleApp/customervault-mandate-w-BACSAccount.aspx @@ -0,0 +1,49 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customervault-mandate-w-BACSAccount.aspx.cs" Inherits="SampleApp.customervault_mandate_w_BACSAccount" %> + + + + + + Customer Vault with Accounts + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ BACS Bank Account Details With Mandate +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + + diff --git a/SampleApp/customervault-mandate-w-BACSAccount.aspx.cs b/SampleApp/customervault-mandate-w-BACSAccount.aspx.cs new file mode 100644 index 0000000..c8021e8 --- /dev/null +++ b/SampleApp/customervault-mandate-w-BACSAccount.aspx.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; +namespace SampleApp +{ + public partial class customervault_mandate_w_BACSAccount : System.Web.UI.Page + { + protected String response = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + List mandateList = new List(); + Mandates mandate = Mandates.Builder() + .reference("SUBCRIP345") + .Build(); + mandateList.Add(mandate); + + BACSBankAccounts account = client.customerVaultService().create(BACSBankAccounts.Builder() + .nickName(Request.Form["nick_name"]) + .accountNumber(Request.Form["nick_name"]) + .mandates(mandateList) + .accountHolderName(Request.Form["account_holder_name"]) + .sortCode(Request.Form["sort_code"]) + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + this.response = account.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/customervault-mandate-w-BACSAccount.aspx.designer.cs b/SampleApp/customervault-mandate-w-BACSAccount.aspx.designer.cs new file mode 100644 index 0000000..cafbd0f --- /dev/null +++ b/SampleApp/customervault-mandate-w-BACSAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class customervault_mandate_w_BACSAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervault-mandate-w-SEPAAccount.aspx b/SampleApp/customervault-mandate-w-SEPAAccount.aspx new file mode 100644 index 0000000..826ad3c --- /dev/null +++ b/SampleApp/customervault-mandate-w-SEPAAccount.aspx @@ -0,0 +1,48 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customervault-mandate-w-SEPAAccount.aspx.cs" Inherits="SampleApp.customervault_mandate_w_SEPAAccount" %> + + + + + + Paysafe SDK - CardPayment With Customer Vault + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ SEPA Bank Account Details With Mandates +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/customervault-mandate-w-SEPAAccount.aspx.cs b/SampleApp/customervault-mandate-w-SEPAAccount.aspx.cs new file mode 100644 index 0000000..4f4a897 --- /dev/null +++ b/SampleApp/customervault-mandate-w-SEPAAccount.aspx.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; +namespace SampleApp +{ + public partial class customervault_mandate_w_SEPAAccount : System.Web.UI.Page + { + protected String response = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + List mandateList = new List(); + + Mandates mandate = Mandates.Builder() + .reference("SUBCRIP35") + .Build(); + mandateList.Add(mandate); + + SEPABankAccounts account = client.customerVaultService().create(SEPABankAccounts.Builder() + .iban(Request.Form["iban"]) + .bic(Request.Form["bic"]) + .mandates(mandateList) + .accountHolderName(Request.Form["account_holder_name"]) + .nickName(Request.Form["nick_name"]) + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + this.response = account.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/customervault-mandate-w-SEPAAccount.aspx.designer.cs b/SampleApp/customervault-mandate-w-SEPAAccount.aspx.designer.cs new file mode 100644 index 0000000..5e2e0cb --- /dev/null +++ b/SampleApp/customervault-mandate-w-SEPAAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class customervault_mandate_w_SEPAAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervault-w-ACHAccount.aspx b/SampleApp/customervault-w-ACHAccount.aspx new file mode 100644 index 0000000..d30fbad --- /dev/null +++ b/SampleApp/customervault-w-ACHAccount.aspx @@ -0,0 +1,70 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customervault-w-ACHAccount.aspx.cs" Inherits="SampleApp.customervault_w_ACHAccount" %> + + + + + + Customer Vault with Accounts + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ ACH Bank Account Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + + diff --git a/SampleApp/customervault-w-ACHAccount.aspx.cs b/SampleApp/customervault-w-ACHAccount.aspx.cs new file mode 100644 index 0000000..aef0ee6 --- /dev/null +++ b/SampleApp/customervault-w-ACHAccount.aspx.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; + +namespace SampleApp +{ + public partial class customervault_w_ACHAccount : System.Web.UI.Page + { + protected String response = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + ACHBankAccounts account = client.customerVaultService().create(ACHBankAccounts.Builder() + .nickName(Request.Form["nick_name"]) + .accountNumber(Request.Form["account_number"]) + .routingNumber(Request.Form["routing_number"]) + .accountHolderName(Request.Form["account_holder_name"]) + .billingAddressId(address.id()) + .accountType(Request.Form["account_type"]) + .merchantRefNum(Request.Form["merchant_customer_id"]) + .profileId(profile.id()) + .Build()); + this.response = account.ToString(); + } + catch(Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/customervault-w-ACHAccount.aspx.designer.cs b/SampleApp/customervault-w-ACHAccount.aspx.designer.cs new file mode 100644 index 0000000..8ede9ab --- /dev/null +++ b/SampleApp/customervault-w-ACHAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class customervault_w_ACHAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervault-w-BACSAccount.aspx b/SampleApp/customervault-w-BACSAccount.aspx new file mode 100644 index 0000000..4c17a5a --- /dev/null +++ b/SampleApp/customervault-w-BACSAccount.aspx @@ -0,0 +1,48 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customervault-w-BACSAccount.aspx.cs" Inherits="SampleApp.customervault_w_BACSAccount" %> + + + + + + Customer Vault with Accounts + + + <% if (response != null) + { %> +

Payment Successful ID:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ BACS Bank Account Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/customervault-w-BACSAccount.aspx.cs b/SampleApp/customervault-w-BACSAccount.aspx.cs new file mode 100644 index 0000000..4469860 --- /dev/null +++ b/SampleApp/customervault-w-BACSAccount.aspx.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; + + +namespace SampleApp +{ + public partial class customervault_w_BACSAccount : System.Web.UI.Page + { + protected String response = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + BACSBankAccounts account = client.customerVaultService().create(BACSBankAccounts.Builder() + .nickName(Request.Form["nick_name"]) + .accountNumber(Request.Form["account_number"]) + .accountHolderName(Request.Form["account_holder_name"]) + .sortCode(Request.Form["sort_code"]) + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + this.response = account.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/customervault-w-BACSAccount.aspx.designer.cs b/SampleApp/customervault-w-BACSAccount.aspx.designer.cs new file mode 100644 index 0000000..1a216c7 --- /dev/null +++ b/SampleApp/customervault-w-BACSAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class customervault_w_BACSAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervault-w-EFTAccount.aspx b/SampleApp/customervault-w-EFTAccount.aspx new file mode 100644 index 0000000..625449c --- /dev/null +++ b/SampleApp/customervault-w-EFTAccount.aspx @@ -0,0 +1,70 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customervault-w-EFTAccount.aspx.cs" Inherits="SampleApp.customervault_w_EFTAccount" %> + + + + + + Paysafe SDK - CardPayment With Customer Vault + + + <% if (response != null) + { %> +

Payment Successful ID:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ EFT Bank Account Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + + diff --git a/SampleApp/customervault-w-EFTAccount.aspx.cs b/SampleApp/customervault-w-EFTAccount.aspx.cs new file mode 100644 index 0000000..d7516eb --- /dev/null +++ b/SampleApp/customervault-w-EFTAccount.aspx.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; + +namespace SampleApp +{ + public partial class customervault_w_EFTAccount : System.Web.UI.Page + { + protected String response = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + EFTBankAccounts account = client.customerVaultService().create(EFTBankAccounts.Builder() + .accountNumber(Request.Form["account_number"]) + .transitNumber(Request.Form["transit_number"]) + .institutionId(Request.Form["institution_id"]) + .accountHolderName(Request.Form["account_holder_name"]) + .nickName(Request.Form["nick_name"]) + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + this.response = account.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/customervault-w-EFTAccount.aspx.designer.cs b/SampleApp/customervault-w-EFTAccount.aspx.designer.cs new file mode 100644 index 0000000..4746db3 --- /dev/null +++ b/SampleApp/customervault-w-EFTAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class customervault_w_EFTAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervault-w-SEPAAccount.aspx b/SampleApp/customervault-w-SEPAAccount.aspx new file mode 100644 index 0000000..ebf0b13 --- /dev/null +++ b/SampleApp/customervault-w-SEPAAccount.aspx @@ -0,0 +1,55 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customervault-w-SEPAAccount.aspx.cs" Inherits="SampleApp.customervault_w_SEPAAccount" %> + + + + + + Paysafe SDK - CardPayment With Customer Vault + + + <% if (response != null) + { %> +

Payment Successful ID:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ SEPA Bank Account Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + + diff --git a/SampleApp/customervault-w-SEPAAccount.aspx.cs b/SampleApp/customervault-w-SEPAAccount.aspx.cs new file mode 100644 index 0000000..bda474e --- /dev/null +++ b/SampleApp/customervault-w-SEPAAccount.aspx.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Authorization = Paysafe.CardPayments.Authorization; +using Paysafe.CustomerVault; + +namespace SampleApp +{ + public partial class customervault_w_SEPAAccount : System.Web.UI.Page + { + protected String response = null; + + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Profile profile = client.customerVaultService().create(Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Address address = client.customerVaultService().create(Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + SEPABankAccounts account = client.customerVaultService().create(SEPABankAccounts.Builder() + .iban(Request.Form["iban"]) + .bic(Request.Form["bic"]) + .accountHolderName(Request.Form["account_holder_name"]) + .nickName(Request.Form["nick_name"]) + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + this.response = account.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/customervault-w-SEPAAccount.aspx.designer.cs b/SampleApp/customervault-w-SEPAAccount.aspx.designer.cs new file mode 100644 index 0000000..647506b --- /dev/null +++ b/SampleApp/customervault-w-SEPAAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class customervault_w_SEPAAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/customervaultclassification.html b/SampleApp/customervaultclassification.html new file mode 100644 index 0000000..f16f883 --- /dev/null +++ b/SampleApp/customervaultclassification.html @@ -0,0 +1,15 @@ + + + + + + +

Customer Vault Bank Account

+ + + + + + + + \ No newline at end of file diff --git a/SampleApp/direct-debit-purchase-ACHAccount.aspx b/SampleApp/direct-debit-purchase-ACHAccount.aspx new file mode 100644 index 0000000..7e0296f --- /dev/null +++ b/SampleApp/direct-debit-purchase-ACHAccount.aspx @@ -0,0 +1,197 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-purchase-ACHAccount.aspx.cs" Inherits="SampleApp.direct_debit_purchase_ACHAccount" %> + + + + + + Purchase With ACHAccount + + + <% if (response != null) + { %> +

Payment Successful ID:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ Direct Debit Purchase +
+ +
+
+ +
+
+ +
+
+ +
+ ACH Account +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + + diff --git a/SampleApp/direct-debit-purchase-ACHAccount.aspx.cs b/SampleApp/direct-debit-purchase-ACHAccount.aspx.cs new file mode 100644 index 0000000..bfe27e3 --- /dev/null +++ b/SampleApp/direct-debit-purchase-ACHAccount.aspx.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Purchases = Paysafe.DirectDebit.Purchases; + +namespace SampleApp +{ + public partial class direct_debit_purchase_ACHAccount : System.Web.UI.Page + { + protected String response = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .ach() + .accountHolderName(Request.Form["account_holder_name"]) + .accountNumber(Request.Form["account_number"]) + .accountType(Request.Form["account_type"]) + .routingNumber(Request.Form["routing_number"]) + .payMethod(Request.Form["pay_method"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.response = response.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-purchase-ACHAccount.aspx.designer.cs b/SampleApp/direct-debit-purchase-ACHAccount.aspx.designer.cs new file mode 100644 index 0000000..954fad5 --- /dev/null +++ b/SampleApp/direct-debit-purchase-ACHAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_purchase_ACHAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-purchase-BACSAccount.aspx b/SampleApp/direct-debit-purchase-BACSAccount.aspx new file mode 100644 index 0000000..694e791 --- /dev/null +++ b/SampleApp/direct-debit-purchase-BACSAccount.aspx @@ -0,0 +1,197 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-purchase-BACSAccount.aspx.cs" Inherits="SampleApp.direct_debit_purchase_BACSAccount" %> + + + + + + Purchase With BACSAccount + + + <% if (payment_id != null) + { %> +

Payment Successful! ID: <% Response.Write(payment_id); %>

+ <% } + else + { %> +
+
+ Direct Debit Purchase +
+ +
+
+ +
+
+ +
+
+ +
+ BACS Account +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/direct-debit-purchase-BACSAccount.aspx.cs b/SampleApp/direct-debit-purchase-BACSAccount.aspx.cs new file mode 100644 index 0000000..37d7a12 --- /dev/null +++ b/SampleApp/direct-debit-purchase-BACSAccount.aspx.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using OptimalPayments; +using Purchases = OptimalPayments.DirectDebit.Purchases; + +namespace SampleApp +{ + public partial class direct_debit_purchase_BACSAccount : System.Web.UI.Page + { + protected String payment_id = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + OptimalApiClient client = new OptimalApiClient(apiKey, apiSecret, OptimalPayments.Environment.TEST, accountNumber); + try + { + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .bacs() + .accountHolderName(Request.Form["account_holder_name"]) + .accountNumber(Request.Form["account_number"]) + .sortCode(Request.Form["sort_code"]) + .mandateReference(Request.Form["mandate_Reference"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.payment_id = response.id(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-purchase-BACSAccount.aspx.designer.cs b/SampleApp/direct-debit-purchase-BACSAccount.aspx.designer.cs new file mode 100644 index 0000000..922f173 --- /dev/null +++ b/SampleApp/direct-debit-purchase-BACSAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_purchase_BACSAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-purchase-EFTAccount.aspx b/SampleApp/direct-debit-purchase-EFTAccount.aspx new file mode 100644 index 0000000..412bb30 --- /dev/null +++ b/SampleApp/direct-debit-purchase-EFTAccount.aspx @@ -0,0 +1,190 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-purchase-EFTAccount.aspx.cs" Inherits="SampleApp.direct_debit_purchase_EFTAccount" %> + + + + + + Purchase With EFTAccount + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ Direct Debit Purchase +
+ +
+
+ +
+
+ +
+
+ +
+ EFT Account +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/direct-debit-purchase-EFTAccount.aspx.cs b/SampleApp/direct-debit-purchase-EFTAccount.aspx.cs new file mode 100644 index 0000000..760e0b9 --- /dev/null +++ b/SampleApp/direct-debit-purchase-EFTAccount.aspx.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using Purchases = Paysafe.DirectDebit.Purchases; +namespace SampleApp +{ + public partial class direct_debit_purchase_EFTAccount : System.Web.UI.Page + { + protected string response = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .eft() + .accountHolderName(Request.Form["account_holder_name"]) + .accountNumber(Request.Form["account_number"]) + .transitNumber(Request.Form["transit_number"]) + .institutionId(Request.Form["institution_id"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.response = response.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-purchase-EFTAccount.aspx.designer.cs b/SampleApp/direct-debit-purchase-EFTAccount.aspx.designer.cs new file mode 100644 index 0000000..564330c --- /dev/null +++ b/SampleApp/direct-debit-purchase-EFTAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_purchase_EFTAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-purchase-SEPAAccount.aspx b/SampleApp/direct-debit-purchase-SEPAAccount.aspx new file mode 100644 index 0000000..799f2ca --- /dev/null +++ b/SampleApp/direct-debit-purchase-SEPAAccount.aspx @@ -0,0 +1,152 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-purchase-SEPAAccount.aspx.cs" Inherits="SampleApp.direct_debit_purchase_SEPAAccount" %> + + + + + + Purchase With SEPAAccount + + <% if (payment_id != null) + { %> +

Payment Successful! ID: <% Response.Write(payment_id); %>

+ <% } + else + { %> +
+
+ Direct Debit Purchase +
+ +
+
+ +
+
+ +
+
+ +
+ SEPA Account +
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + diff --git a/SampleApp/direct-debit-purchase-SEPAAccount.aspx.cs b/SampleApp/direct-debit-purchase-SEPAAccount.aspx.cs new file mode 100644 index 0000000..699dbbb --- /dev/null +++ b/SampleApp/direct-debit-purchase-SEPAAccount.aspx.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using OptimalPayments; +using OptimalPayments.CustomerVault; +using Purchases = OptimalPayments.DirectDebit.Purchases; +namespace SampleApp +{ + public partial class direct_debit_purchase_SEPAAccount : System.Web.UI.Page + { + protected string payment_id = null; + protected string accountName; + protected Mandates mandate; + protected SEPABankAccounts account; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + OptimalApiClient client = new OptimalApiClient(apiKey, apiSecret, OptimalPayments.Environment.TEST, accountNumber); + try + { + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .sepa() + .mandateReference(Request.Form["mandate_reference"]) + .accountHolderName(Request.Form["account_holder_name"]) + .iban(Request.Form["iban"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.payment_id = response.id(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-purchase-SEPAAccount.aspx.designer.cs b/SampleApp/direct-debit-purchase-SEPAAccount.aspx.designer.cs new file mode 100644 index 0000000..90345f7 --- /dev/null +++ b/SampleApp/direct-debit-purchase-SEPAAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_purchase_SEPAAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-purchase-w-token-all accounts.aspx b/SampleApp/direct-debit-purchase-w-token-all accounts.aspx new file mode 100644 index 0000000..badef1d --- /dev/null +++ b/SampleApp/direct-debit-purchase-w-token-all accounts.aspx @@ -0,0 +1,61 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-purchase-w-token-all accounts.aspx.cs" Inherits="SampleApp.direct_debit_purchase_w_token_all_accounts" %> + + + + + + Purchase with Payment Token All Accounts + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ Direct Debit Purchase With Token +

Select Account

+
+ + + + + + +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/direct-debit-purchase-w-token-all accounts.aspx.cs b/SampleApp/direct-debit-purchase-w-token-all accounts.aspx.cs new file mode 100644 index 0000000..0c1b9f4 --- /dev/null +++ b/SampleApp/direct-debit-purchase-w-token-all accounts.aspx.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Paysafe; +using Purchases = Paysafe.DirectDebit.Purchases; +namespace SampleApp +{ + public partial class direct_debit_purchase_w_token_all_accounts : System.Web.UI.Page + { + protected String response = null; + protected string accountName; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + try + { + string val = radio.SelectedItem.Value.ToString(); + if(val.Equals("ACH")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Paysafe.CustomerVault.Profile profile = client.customerVaultService().create( + Paysafe.CustomerVault.Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Paysafe.CustomerVault.Address address = client.customerVaultService().create( + Paysafe.CustomerVault.Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + Paysafe.CustomerVault.ACHBankAccounts account = client.customerVaultService().create( + Paysafe.CustomerVault.ACHBankAccounts.Builder() + .nickName("Johns RBC Business Bank Account") + .accountNumber(getRandomNumber()) + .routingNumber("123456789") + .accountHolderName("XYZ Business") + .billingAddressId(address.id()) + .accountType("CHECKING") + .merchantRefNum(System.Guid.NewGuid().ToString()) + .profileId(profile.id()) + .Build()); + + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .ach() + .paymentToken(account.paymentToken()) + .payMethod("WEB") + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.response = response.ToString(); + } + else if (val.Equals("BACS")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber_BACS"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .bacs() + .paymentToken(Request.Form["payment_token"]) + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.response = response.ToString(); + } + else if (val.Equals("EFT")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber_EFT"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Paysafe.CustomerVault.Profile profile = client.customerVaultService().create( + Paysafe.CustomerVault.Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Paysafe.CustomerVault.Address address = client.customerVaultService().create( + Paysafe.CustomerVault.Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + Paysafe.CustomerVault.EFTBankAccounts account = client.customerVaultService().create( + Paysafe.CustomerVault.EFTBankAccounts.Builder() + .accountNumber(getRandomNumber()) + .transitNumber("11224") + .institutionId("123") + .accountHolderName("John Smith") + .nickName("Johns RBC Business Bank Account") + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + + Purchases response = client.directDebitService().submit(Purchases.Builder() + .merchantRefNum(System.Guid.NewGuid().ToString()) + .amount(10038) + .eft() + .paymentToken(account.paymentToken()) + .Done() + .Build() + ); + this.response = response.ToString(); + } + else if (val.Equals("SEPA")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber_SEPA"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Purchases response = client.directDebitService().submit(Purchases.Builder() + .merchantRefNum(System.Guid.NewGuid().ToString()) + .amount(10038) + .sepa() + .paymentToken(Request.Form["payment_token"]) + .Done() + .Build() + ); + this.response = response.ToString(); + } + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + /// + /// Get Random number + /// + /// getRandomNumber + /// 10 digit number + private string getRandomNumber() + { + Random random = new Random(); + StringBuilder builder = new StringBuilder(); + int ch; + for (int i = 0; i < 8; i++) + { + ch = Convert.ToInt32(random.Next(0, 9)); + builder.Append(ch); + } + + string val = builder.ToString(); + return val; + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-purchase-w-token-all accounts.aspx.designer.cs b/SampleApp/direct-debit-purchase-w-token-all accounts.aspx.designer.cs new file mode 100644 index 0000000..3050362 --- /dev/null +++ b/SampleApp/direct-debit-purchase-w-token-all accounts.aspx.designer.cs @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_purchase_w_token_all_accounts { + + /// + /// radio control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList radio; + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx b/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx new file mode 100644 index 0000000..ad54917 --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx @@ -0,0 +1,196 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-standalonecredits-ACHAccount.aspx.cs" Inherits="SampleApp.direct_debit_standalonecredits_ACHAccount" %> + + + + + + Purchase With ACHAccount + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ Direct Debit StandAloneCredits +
+ +
+
+ +
+
+ +
+
+ +
+ ACH Account +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.cs b/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.cs new file mode 100644 index 0000000..272353c --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using StandaloneCredits = Paysafe.DirectDebit.StandaloneCredits; +namespace SampleApp +{ + public partial class direct_debit_standalonecredits_ACHAccount : System.Web.UI.Page + { + protected String response = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + try + { + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + StandaloneCredits standalonecredit = StandaloneCredits.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .ach() + .accountHolderName(Request.Form["account_holder_name"]) + .accountNumber(Request.Form["account_number"]) + .accountType(Request.Form["account_type"]) + .routingNumber(Request.Form["routing_number"]) + .payMethod(Request.Form["pay_method"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + StandaloneCredits response = client.directDebitService().submit(standalonecredit); + this.response = response.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.designer.cs b/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.designer.cs new file mode 100644 index 0000000..eb1f9d5 --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-ACHAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_standalonecredits_ACHAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx b/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx new file mode 100644 index 0000000..d83994c --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx @@ -0,0 +1,197 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-standalonecredits-BACSAccount.aspx.cs" Inherits="SampleApp.direct_debit_standalonecredits_BACSAccount" %> + + + + + + StandaloneCredits With BACSAccount + + + <% if (payment_id != null) + { %> +

Payment Successful! ID: <% Response.Write(payment_id); %>

+ <% } + else + { %> +
+
+ Direct Debit StandaloneCredits +
+ +
+
+ +
+
+ +
+
+ +
+ BACS Account +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.cs b/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.cs new file mode 100644 index 0000000..7b04c8c --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using OptimalPayments; +using StandaloneCredits = OptimalPayments.DirectDebit.StandaloneCredits; + +namespace SampleApp +{ + public partial class direct_debit_standalonecredits_BACSAccount : System.Web.UI.Page + { + protected String payment_id = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + OptimalApiClient client = new OptimalApiClient(apiKey, apiSecret, OptimalPayments.Environment.TEST, accountNumber); + try + { + StandaloneCredits standaloneCredits = StandaloneCredits.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .bacs() + .accountHolderName(Request.Form["account_holder_name"]) + .accountNumber(Request.Form["account_number"]) + .sortCode(Request.Form["sort_code"]) + .mandateReference(Request.Form["mandate_Reference"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + StandaloneCredits response = client.directDebitService().submit(standaloneCredits); + this.payment_id = response.id(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.designer.cs b/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.designer.cs new file mode 100644 index 0000000..aac0aec --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-BACSAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_standalonecredits_BACSAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx b/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx new file mode 100644 index 0000000..ed3d521 --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx @@ -0,0 +1,190 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-standalonecredits-EFTAccount.aspx.cs" Inherits="SampleApp.direct_debit_standalonecredits_EFTAccount" %> + + + + + + Purchase With EFTAccount + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ Direct Debit StandaloneCredits +
+ +
+
+ +
+
+ +
+
+ +
+ EFT Account +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ Profile +
+ +
+
+ +
+
+ +
+
+
+ Billing Details +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.cs b/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.cs new file mode 100644 index 0000000..5398595 --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +using Paysafe; +using StandaloneCredits = Paysafe.DirectDebit.StandaloneCredits; +namespace SampleApp +{ + public partial class direct_debit_standalonecredits_EFTAccount : System.Web.UI.Page + { + protected string response = null; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + try + { + StandaloneCredits standaloneCredits = StandaloneCredits.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .eft() + .accountHolderName(Request.Form["account_holder_name"]) + .accountNumber(Request.Form["account_number"]) + .transitNumber(Request.Form["transit_number"]) + .institutionId(Request.Form["institution_id"]) + .Done() + .customerIp(Request.Form["customer_ip"]) + .profile() + .firstName(Request.Form["first_name"]) + .lastName(Request.Form["last_name"]) + .email(Request.Form["email"]) + .Done() + .billingDetails() + .street(Request.Form["street"]) + .city(Request.Form["city"]) + .state(Request.Form["state"]) + .country(Request.Form["country"]) + .zip(Request.Form["zip"]) + .phone(Request.Form["phone"]) + .Done() + .Build(); + StandaloneCredits response = client.directDebitService().submit(standaloneCredits); + this.response = response.ToString(); + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.designer.cs b/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.designer.cs new file mode 100644 index 0000000..d32417c --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-EFTAccount.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_standalonecredits_EFTAccount { + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx b/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx new file mode 100644 index 0000000..bb84eac --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx @@ -0,0 +1,60 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="direct-debit-standalonecredits-w-token-all accounts.aspx.cs" Inherits="SampleApp.direct_debit_standalonecredits_w_token_all_accounts" %> + + + + + + Purchase with Payment Token All Accounts + + + <% if (response != null) + { %> +

Payment Successful:


<% Response.Write(response); %> + <% } + else + { %> +
+
+ Direct Debit StandaloneCredits With Token +

Select Account

+
+ + + + + +
+
+ +
+
+ +
+
+ +
+
+ + + <% } %> + + diff --git a/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.cs b/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.cs new file mode 100644 index 0000000..48771d6 --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.cs @@ -0,0 +1,187 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using Paysafe; +using Purchases = Paysafe.DirectDebit.Purchases; +namespace SampleApp +{ + public partial class direct_debit_standalonecredits_w_token_all_accounts : System.Web.UI.Page + { + protected String response = null; + protected string accountName; + protected void Page_Load(object sender, EventArgs e) + { + System.Globalization.CultureInfo ui = System.Globalization.CultureInfo.CurrentUICulture; + btnSubmit.Click += new System.EventHandler(this.submit); + } + protected void submit(object sender, System.EventArgs e) + { + try + { + string apiKey = System.Configuration.ConfigurationManager.AppSettings["ApiKey"]; + string apiSecret = System.Configuration.ConfigurationManager.AppSettings["ApiSecret"]; + + string val = radio.SelectedItem.Value.ToString(); + if (val.Equals("ACH")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Paysafe.CustomerVault.Profile profile = client.customerVaultService().create( + Paysafe.CustomerVault.Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Paysafe.CustomerVault.Address address = client.customerVaultService().create( + Paysafe.CustomerVault.Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + Paysafe.CustomerVault.ACHBankAccounts account = client.customerVaultService().create( + Paysafe.CustomerVault.ACHBankAccounts.Builder() + .nickName("Johns RBC Business Bank Account") + .accountNumber(getRandomNumber()) + .routingNumber("123456789") + .accountHolderName("XYZ Business") + .billingAddressId(address.id()) + .accountType("CHECKING") + .merchantRefNum(System.Guid.NewGuid().ToString()) + .profileId(profile.id()) + .Build()); + + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .ach() + .paymentToken(account.paymentToken()) + .payMethod("WEB") + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.response = response.ToString(); + } + else if (val.Equals("BACS")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber_BACS"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Purchases purchase = Purchases.Builder() + .merchantRefNum(Request.Form["merchant_customer_id"]) + .amount(Convert.ToInt32(Double.Parse(Request.Form["amount"]))) + .bacs() + .paymentToken(Request.Form["payment_token"]) + .Done() + .Build(); + Purchases response = client.directDebitService().submit(purchase); + this.response = response.ToString(); + } + else if (val.Equals("EFT")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber_EFT"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Paysafe.CustomerVault.Profile profile = client.customerVaultService().create( + Paysafe.CustomerVault.Profile.Builder() + .merchantCustomerId(System.Guid.NewGuid().ToString()) + .locale("en_US") + .firstName("John") + .lastName("Smith") + .email("john.smith@somedomain.com") + .phone("713-444-5555") + .Build()); + + Paysafe.CustomerVault.Address address = client.customerVaultService().create( + Paysafe.CustomerVault.Address.Builder() + .nickName("home") + .street("100 Queen Street West") + .street2("Unit 201") + .city("Toronto") + .country("CA") + .state("ON") + .zip("M5H 2N2") + .recipientName("Jane Doe") + .phone("647-788-3901") + .profileId(profile.id()) + .Build()); + + Paysafe.CustomerVault.EFTBankAccounts account = client.customerVaultService().create( + Paysafe.CustomerVault.EFTBankAccounts.Builder() + .accountNumber(getRandomNumber()) + .transitNumber("11224") + .institutionId("123") + .accountHolderName("John Smith") + .nickName("Johns RBC Business Bank Account") + .billingAddressId(address.id()) + .profileId(profile.id()) + .Build()); + + Purchases response = client.directDebitService().submit(Purchases.Builder() + .merchantRefNum(System.Guid.NewGuid().ToString()) + .amount(10038) + .eft() + .paymentToken(Request.Form["payment_token"]) + .Done() + .Build() + ); + this.response = response.ToString(); + } + else if (val.Equals("SEPA")) + { + string accountNumber = System.Configuration.ConfigurationManager.AppSettings["AccountNumber_SEPA"]; + PaysafeApiClient client = new PaysafeApiClient(apiKey, apiSecret, Paysafe.Environment.TEST, accountNumber); + + Purchases response = client.directDebitService().submit(Purchases.Builder() + .merchantRefNum(System.Guid.NewGuid().ToString()) + .amount(10038) + .sepa() + .paymentToken(Request.Form["payment_token"]) + .Done() + .Build() + ); + this.response = response.ToString(); + } + } + catch (Exception ex) + { + Response.Write("Error Message is : " + ex.Message + "\n"); + } + } + /// + /// Get Random number + /// + /// getRandomNumber + /// 10 digit number + private string getRandomNumber() + { + Random random = new Random(); + StringBuilder builder = new StringBuilder(); + int ch; + for (int i = 0; i < 8; i++) + { + ch = Convert.ToInt32(random.Next(0, 9)); + builder.Append(ch); + } + + string val = builder.ToString(); + return val; + } + } +} \ No newline at end of file diff --git a/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.designer.cs b/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.designer.cs new file mode 100644 index 0000000..0942f29 --- /dev/null +++ b/SampleApp/direct-debit-standalonecredits-w-token-all accounts.aspx.designer.cs @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp { + + + public partial class direct_debit_standalonecredits_w_token_all_accounts { + + /// + /// radio control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList radio; + + /// + /// btnSubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSubmit; + } +} diff --git a/SampleApp/directdebit classification.html b/SampleApp/directdebit classification.html new file mode 100644 index 0000000..5552dc2 --- /dev/null +++ b/SampleApp/directdebit classification.html @@ -0,0 +1,41 @@ + + + + + + +

Direct Debit API

+ + + diff --git a/SampleApp/index.html b/SampleApp/index.html new file mode 100644 index 0000000..f00f21b --- /dev/null +++ b/SampleApp/index.html @@ -0,0 +1,11 @@ + + + +

Sample Scripts

+ + + + + + + diff --git a/packages/repositories.config b/packages/repositories.config new file mode 100644 index 0000000..7dbdbc3 --- /dev/null +++ b/packages/repositories.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file