Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paypal mapper bug fixes #136

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OrderCloud.Catalyst/OrderCloud.Catalyst.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<PackageId>ordercloud-dotnet-catalyst</PackageId>
<Title>OrderCloud SDK Extensions for Azure App Services</Title>
<Authors>OrderCloud Team</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json.Linq;
using OrderCloud.Catalyst;
using OrderCloud.Integrations.Payment.PayPal.Models;

Expand Down Expand Up @@ -47,7 +48,7 @@ public List<PurchaseUnit> MapToPurchaseUnit(AuthorizeCCTransaction transaction,
},
description = transaction?.OrderWorksheet?.Order?.Comments,
reference_id = Guid.NewGuid().ToString(),
invoice_id = Guid.NewGuid().ToString(),
invoice_id = transaction?.OrderID,
};
if (address != null)
{
Expand All @@ -61,23 +62,25 @@ public List<PurchaseUnit> MapToPurchaseUnit(AuthorizeCCTransaction transaction,
}
});
}

var unit = new PurchaseUnit()
{
amount = new Amount()
{
currency_code = transaction.Currency,
value = transaction.Amount.ToString(CultureInfo.InvariantCulture) ?? null
}
};
if (address != null)
else
{
unit.shipping = new Shipping()
var unit = new PurchaseUnit()
{
address = address
amount = new Amount()
{
currency_code = transaction.Currency,
value = transaction.Amount.ToString(CultureInfo.InvariantCulture) ?? null
erincdustin marked this conversation as resolved.
Show resolved Hide resolved
}
};
if (address != null)
{
unit.shipping = new Shipping()
{
address = address
};
}
purchaseUnits.Add(unit);
}
purchaseUnits.Add(unit);

return purchaseUnits;
}
Expand Down Expand Up @@ -105,13 +108,13 @@ public CCTransactionResult MapAuthorizedPaymentToCCTransactionResult(PayPalOrder
var allPaymentsSucceeded = innerTransactions.All(t => t.Succeeded);
var ccTransaction = new CCTransactionResult
{
Succeeded = authorizedOrder.status.ToLowerInvariant() == "completed" && allPaymentsSucceeded,
Succeeded = authorizedOrder?.status.ToLowerInvariant() == "completed" && allPaymentsSucceeded,
TransactionID = authorizationId, // Default to purchase_unit.TransactionID if only one merchant, else null
ResponseCode = authorizedOrder.processor_response.response_code,
ResponseCode = authorizedOrder?.processor_response?.response_code,
AuthorizationCode = null,
AVSResponseCode = authorizedOrder.processor_response.avs_code,
AVSResponseCode = authorizedOrder?.processor_response?.avs_code,
Message = null,
Amount = authorizedOrder.purchase_units.Sum(unit => ConvertStringAmountToDecimal(unit.amount.value)),
Amount = authorizedOrder?.purchase_units != null ? authorizedOrder.purchase_units.Sum(unit => ConvertStringAmountToDecimal(unit.amount.value)) : Convert.ToDecimal(0, CultureInfo.InvariantCulture),
InnerTransactions = innerTransactions // Include all merchant transaction details as nested values
};
return ccTransaction;
Expand Down Expand Up @@ -141,12 +144,12 @@ public CCTransactionResult MapCapturedPaymentToCCTransactionResult(PayPalOrder c
return new CCTransactionResult
{
TransactionID = captureId, // Default to purchase_unit.TransactionID if only one merchant, else null
ResponseCode = capturedOrder.processor_response.response_code,
ResponseCode = capturedOrder?.processor_response?.response_code,
AuthorizationCode = null,
AVSResponseCode = capturedOrder.processor_response.avs_code,
AVSResponseCode = capturedOrder?.processor_response?.avs_code,
Message = null,
Succeeded = capturedOrder.status.ToLowerInvariant() == "completed" && allPaymentsSucceeded,
Amount = capturedOrder.purchase_units.Sum(unit => ConvertStringAmountToDecimal(unit.amount.value)),
Succeeded = capturedOrder?.status.ToLowerInvariant() == "completed" && allPaymentsSucceeded,
Amount = capturedOrder?.purchase_units != null ? capturedOrder.purchase_units.Sum(unit => ConvertStringAmountToDecimal(unit.amount.value)) : Convert.ToDecimal(0, CultureInfo.InvariantCulture),
InnerTransactions = innerTransactions // Include all merchant transaction details as nested values
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<PackageId>OrderCloud.Integrations.Payment.PayPal</PackageId>
<Title>OrderCloud Payment Integration with PayPal</Title>
<Authors>OrderCloud Team</Authors>
Expand Down
Loading