11using System ;
2+ using System . Linq ;
23using System . Text ;
34using OffAmazonPaymentsService ;
45using OffAmazonPaymentsService . Model ;
6+ using SmartStore . AmazonPay . Extensions ;
7+ using SmartStore . AmazonPay . Services ;
8+ using SmartStore . Core . Data ;
9+ using SmartStore . Core . Domain . Orders ;
510using SmartStore . Services . Directory ;
611using SmartStore . Services . Localization ;
7- using SmartStore . AmazonPay . Extensions ;
812
913namespace SmartStore . AmazonPay . Api
1014{
@@ -193,5 +197,27 @@ public static void ToAddress(this OrderReferenceDetails details, SmartStore.Core
193197 details . Destination . PhysicalDestination . ToAddress ( address , countryService , stateProvinceService , out countryAllowsShipping , out countryAllowsBilling ) ;
194198 }
195199 }
200+
201+ public static Order GetOrderByAmazonId ( this IRepository < Order > orderRepository , string amazonId )
202+ {
203+ // S02-9777218-8608106 OrderReferenceId
204+ // S02-9777218-8608106-A088344 Auth ID
205+ // S02-9777218-8608106-C088344 Capture ID
206+
207+ if ( amazonId . HasValue ( ) )
208+ {
209+ string amazonOrderReferenceId = amazonId . Substring ( 0 , amazonId . LastIndexOf ( '-' ) ) ;
210+ if ( amazonOrderReferenceId . HasValue ( ) )
211+ {
212+ var orders = orderRepository . Table
213+ . Where ( x => x . PaymentMethodSystemName == AmazonPayCore . SystemName && x . AuthorizationTransactionId . StartsWith ( amazonOrderReferenceId ) )
214+ . ToList ( ) ;
215+
216+ if ( orders . Count ( ) == 1 )
217+ return orders . FirstOrDefault ( ) ;
218+ }
219+ }
220+ return null ;
221+ }
196222 }
197223}
0 commit comments