From 8a44ed3c0e393fbecd532086e3487f46d1709fea Mon Sep 17 00:00:00 2001 From: Alexa Snyder Date: Tue, 8 Oct 2024 14:47:28 -0500 Subject: [PATCH 1/2] new method to initialize request to save a credit card --- .../Integrations/Interfaces/ICreditCardSaver.cs | 12 ++++++++---- .../BlueSnapService.cs | 7 ++++++- .../CardConnectService.cs | 8 +++++++- .../Models/PayPalOrder.cs | 1 + .../PayPalClient.cs | 16 ++++++++++++++++ .../PayPalService.cs | 6 ++++++ .../StripeService.cs | 5 +++++ 7 files changed, 49 insertions(+), 6 deletions(-) diff --git a/OrderCloud.Catalyst/Integrations/Interfaces/ICreditCardSaver.cs b/OrderCloud.Catalyst/Integrations/Interfaces/ICreditCardSaver.cs index db4003b..a6ad5de 100644 --- a/OrderCloud.Catalyst/Integrations/Interfaces/ICreditCardSaver.cs +++ b/OrderCloud.Catalyst/Integrations/Interfaces/ICreditCardSaver.cs @@ -10,10 +10,14 @@ namespace OrderCloud.Catalyst /// public interface ICreditCardSaver { - /// - /// List Saved Credit Cards - /// - Task> ListSavedCardsAsync(string customerID, OCIntegrationConfig configOverride = null); + /// + /// Creates a token used to create a saved card after full card details have been tokenized by the payment provider + /// + Task InitializeCreateSavedCardRequestAsync(OCIntegrationConfig overrideConfig = null); + /// + /// List Saved Credit Cards + /// + Task> ListSavedCardsAsync(string customerID, OCIntegrationConfig configOverride = null); /// /// Get a single saved credit card /// diff --git a/OrderCloud.Integrations.Payment.BlueSnap/BlueSnapService.cs b/OrderCloud.Integrations.Payment.BlueSnap/BlueSnapService.cs index 756b880..84b6114 100644 --- a/OrderCloud.Integrations.Payment.BlueSnap/BlueSnapService.cs +++ b/OrderCloud.Integrations.Payment.BlueSnap/BlueSnapService.cs @@ -55,7 +55,12 @@ public async Task VoidAuthorizationAsync(FollowUpCCTransact return BlueSnapTransactionMapper.ToCardTransactionResult(result); } - public async Task> ListSavedCardsAsync(string customerID, OCIntegrationConfig overrideConfig = null) + public Task InitializeCreateSavedCardRequestAsync(OCIntegrationConfig overrideConfig = null) + { + throw new NotImplementedException(); + } + + public async Task> ListSavedCardsAsync(string customerID, OCIntegrationConfig overrideConfig = null) { var config = ValidateConfig(overrideConfig ?? _defaultConfig); var shopper = await BlueSnapClient.GetVaultedShopper(customerID, config); diff --git a/OrderCloud.Integrations.Payment.CardConnect/CardConnectService.cs b/OrderCloud.Integrations.Payment.CardConnect/CardConnectService.cs index dbcb2aa..f353a9f 100644 --- a/OrderCloud.Integrations.Payment.CardConnect/CardConnectService.cs +++ b/OrderCloud.Integrations.Payment.CardConnect/CardConnectService.cs @@ -51,7 +51,13 @@ public async Task VoidAuthorizationAsync(FollowUpCCTransact var cardConnectVoidAuthorizationResponse = await CardConnectClient.VoidPreviousAuthorization(transaction.ToCardConnectFundReversalRequest(config), config); return cardConnectVoidAuthorizationResponse.ToIntegrationsCCFundReversalResponse(); } - public async Task> ListSavedCardsAsync(string customerId, OCIntegrationConfig overrideConfig = null) + + public Task InitializeCreateSavedCardRequestAsync(OCIntegrationConfig overrideConfig = null) + { + throw new NotImplementedException(); + } + + public async Task> ListSavedCardsAsync(string customerId, OCIntegrationConfig overrideConfig = null) { var config = ValidateConfig(overrideConfig ?? _defaultConfig); var cardConnectSavedCards = await CardConnectClient.GetProfileAsync(customerId, config.MerchantId, config); diff --git a/OrderCloud.Integrations.Payment.PayPal/Models/PayPalOrder.cs b/OrderCloud.Integrations.Payment.PayPal/Models/PayPalOrder.cs index c732855..8531eb1 100644 --- a/OrderCloud.Integrations.Payment.PayPal/Models/PayPalOrder.cs +++ b/OrderCloud.Integrations.Payment.PayPal/Models/PayPalOrder.cs @@ -136,5 +136,6 @@ public class PayPalPaymentToken public PayPalCustomer customer { get; set; } public PaymentSource payment_source { get; set; } public List links { get; set; } + public string status { get; set; } } } diff --git a/OrderCloud.Integrations.Payment.PayPal/PayPalClient.cs b/OrderCloud.Integrations.Payment.PayPal/PayPalClient.cs index 967c460..342b0c2 100644 --- a/OrderCloud.Integrations.Payment.PayPal/PayPalClient.cs +++ b/OrderCloud.Integrations.Payment.PayPal/PayPalClient.cs @@ -100,6 +100,22 @@ public static async Task RefundPaymentAsync(PayPalConfig conf }).ReceiveJson(); } + public static async Task CreateVaultSetupToken(PayPalConfig config) + { + var response = await BuildClient(config) + .AppendPathSegments("v3", "vault", "setup-tokens") + .PostJsonAsync(new + { + payment_source = new PaymentSource() + { + card = new Card() + } + }); + + var tokenResponse = await response.GetJsonAsync(); + return tokenResponse.id; + } + // https://developer.paypal.com/docs/api/payment-tokens/v3/#payment-tokens_create public static async Task CreatePaymentTokenAsync(PayPalConfig config, PCISafeCardDetails card, PaymentSystemCustomer customer) { diff --git a/OrderCloud.Integrations.Payment.PayPal/PayPalService.cs b/OrderCloud.Integrations.Payment.PayPal/PayPalService.cs index 699f356..6e34d94 100644 --- a/OrderCloud.Integrations.Payment.PayPal/PayPalService.cs +++ b/OrderCloud.Integrations.Payment.PayPal/PayPalService.cs @@ -81,6 +81,12 @@ public PayPalService(OCIntegrationConfig defaultConfig) : base(defaultConfig) { } + public async Task InitializeCreateSavedCardRequestAsync(OCIntegrationConfig overrideConfig = null) + { + var config = ValidateConfig(overrideConfig ?? _defaultConfig); + return await PayPalClient.CreateVaultSetupToken(config); + } + public async Task> ListSavedCardsAsync(string customerID, OCIntegrationConfig overrideConfig = null) { var config = ValidateConfig(overrideConfig ?? _defaultConfig); diff --git a/OrderCloud.Integrations.Payment.Stripe/StripeService.cs b/OrderCloud.Integrations.Payment.Stripe/StripeService.cs index aa929ca..b8bc8c5 100644 --- a/OrderCloud.Integrations.Payment.Stripe/StripeService.cs +++ b/OrderCloud.Integrations.Payment.Stripe/StripeService.cs @@ -89,6 +89,11 @@ public async Task CreateSavedCardAsync(PaymentSystemCustome return paymentMethodMapper.MapPaymentMethodCreateResponse(customer.ID, paymentMethod); } + public Task InitializeCreateSavedCardRequestAsync(OCIntegrationConfig overrideConfig = null) + { + throw new NotImplementedException(); + } + public async Task> ListSavedCardsAsync(string customerID, OCIntegrationConfig configOverride = null) { From 8f53f4671d0ff6efbab352ce29ead67c591eaedd Mon Sep 17 00:00:00 2001 From: Alexa Snyder Date: Tue, 8 Oct 2024 14:48:12 -0500 Subject: [PATCH 2/2] bump versions --- OrderCloud.Catalyst/OrderCloud.Catalyst.csproj | 2 +- .../OrderCloud.Integrations.Payment.PayPal.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OrderCloud.Catalyst/OrderCloud.Catalyst.csproj b/OrderCloud.Catalyst/OrderCloud.Catalyst.csproj index 5a698c9..1891ff6 100644 --- a/OrderCloud.Catalyst/OrderCloud.Catalyst.csproj +++ b/OrderCloud.Catalyst/OrderCloud.Catalyst.csproj @@ -3,7 +3,7 @@ netstandard2.0 True - 2.4.0 + 2.5.0 ordercloud-dotnet-catalyst OrderCloud SDK Extensions for Azure App Services OrderCloud Team diff --git a/OrderCloud.Integrations.Payment.PayPal/OrderCloud.Integrations.Payment.PayPal.csproj b/OrderCloud.Integrations.Payment.PayPal/OrderCloud.Integrations.Payment.PayPal.csproj index a7a4e34..f85486d 100644 --- a/OrderCloud.Integrations.Payment.PayPal/OrderCloud.Integrations.Payment.PayPal.csproj +++ b/OrderCloud.Integrations.Payment.PayPal/OrderCloud.Integrations.Payment.PayPal.csproj @@ -3,7 +3,7 @@ netstandard2.0 True - 2.4.1 + 2.5.0 OrderCloud.Integrations.Payment.PayPal OrderCloud Payment Integration with PayPal OrderCloud Team