@@ -1525,94 +1525,6 @@ public static Map<String, Object> processCaptureSplitPayment(DispatchContext dct
1525
1525
}
1526
1526
return ServiceUtil .returnSuccess ();
1527
1527
}
1528
-
1529
- // Deprecated: use captureBillingAccountPayments instead of this.
1530
- public static Map <String , Object > captureBillingAccountPayment (DispatchContext dctx , Map <String , ? extends Object > context ) {
1531
- Delegator delegator = dctx .getDelegator ();
1532
- LocalDispatcher dispatcher = dctx .getDispatcher ();
1533
- GenericValue userLogin = (GenericValue ) context .get ("userLogin" );
1534
- String invoiceId = (String ) context .get ("invoiceId" );
1535
- String billingAccountId = (String ) context .get ("billingAccountId" );
1536
- BigDecimal captureAmount = (BigDecimal ) context .get ("captureAmount" );
1537
- String orderId = (String ) context .get ("orderId" );
1538
- Locale locale = (Locale ) context .get ("locale" );
1539
- Map <String , Object > results = ServiceUtil .returnSuccess ();
1540
-
1541
- try {
1542
- // Note that the partyIdFrom of the Payment should be the partyIdTo of the invoice, since you're receiving a payment from the party you billed
1543
- GenericValue invoice = EntityQuery .use (delegator ).from ("Invoice" ).where ("invoiceId" , invoiceId ).queryOne ();
1544
- Map <String , Object > paymentParams = UtilMisc .<String , Object >toMap ("paymentTypeId" , "CUSTOMER_PAYMENT" , "paymentMethodTypeId" , "EXT_BILLACT" ,
1545
- "partyIdFrom" , invoice .getString ("partyId" ), "partyIdTo" , invoice .getString ("partyIdFrom" ),
1546
- "statusId" , "PMNT_RECEIVED" , "effectiveDate" , UtilDateTime .nowTimestamp ());
1547
- paymentParams .put ("amount" , captureAmount );
1548
- paymentParams .put ("currencyUomId" , invoice .getString ("currencyUomId" ));
1549
- paymentParams .put ("userLogin" , userLogin );
1550
- Map <String , Object > tmpResult = dispatcher .runSync ("createPayment" , paymentParams );
1551
- if (ServiceUtil .isError (tmpResult )) {
1552
- return ServiceUtil .returnError (ServiceUtil .getErrorMessage (tmpResult ));
1553
- }
1554
-
1555
- String paymentId = (String ) tmpResult .get ("paymentId" );
1556
- tmpResult = dispatcher .runSync ("createPaymentApplication" , UtilMisc .<String , Object >toMap ("paymentId" , paymentId , "invoiceId" , invoiceId , "billingAccountId" , billingAccountId ,
1557
- "amountApplied" , captureAmount , "userLogin" , userLogin ));
1558
- if (ServiceUtil .isError (tmpResult )) {
1559
- return ServiceUtil .returnError (ServiceUtil .getErrorMessage (tmpResult ));
1560
- }
1561
- if (paymentId == null ) {
1562
- return ServiceUtil .returnError (UtilProperties .getMessage (resource ,
1563
- "AccountingNoPaymentCreatedForInvoice" ,
1564
- UtilMisc .toMap ("invoiceId" , invoiceId , "billingAccountId" , billingAccountId ), locale ));
1565
- }
1566
- results .put ("paymentId" , paymentId );
1567
-
1568
- if (orderId != null && captureAmount .compareTo (BigDecimal .ZERO ) > 0 ) {
1569
- // Create a paymentGatewayResponse, if necessary
1570
- GenericValue order = EntityQuery .use (delegator ).from ("OrderHeader" ).where ("orderId" , orderId ).queryOne ();
1571
- if (order == null ) {
1572
- return ServiceUtil .returnError (UtilProperties .getMessage (resource ,
1573
- "AccountingNoPaymentGatewayResponseCreatedForInvoice" ,
1574
- UtilMisc .toMap ("invoiceId" , invoiceId , "billingAccountId" , billingAccountId ,
1575
- "orderId" , orderId ), locale ));
1576
- }
1577
- // See if there's an orderPaymentPreference - there should be only one OPP for EXT_BILLACT per order
1578
- GenericValue orderPaymentPreference = EntityQuery .use (delegator ).from ("OrderPaymentPreference" ).where ("orderId" , orderId , "paymentMethodTypeId" , "EXT_BILLACT" ).queryFirst ();
1579
- if (orderPaymentPreference != null ) {
1580
-
1581
- // Check the productStore setting to see if we need to do this explicitly
1582
- GenericValue productStore = order .getRelatedOne ("ProductStore" , false );
1583
- if (productStore .getString ("manualAuthIsCapture" ) == null || (! "Y" .equalsIgnoreCase (productStore .getString ("manualAuthIsCapture" )))) {
1584
- String responseId = delegator .getNextSeqId ("PaymentGatewayResponse" );
1585
- GenericValue pgResponse = delegator .makeValue ("PaymentGatewayResponse" );
1586
- pgResponse .set ("paymentGatewayResponseId" , responseId );
1587
- pgResponse .set ("paymentServiceTypeEnumId" , CAPTURE_SERVICE_TYPE );
1588
- pgResponse .set ("orderPaymentPreferenceId" , orderPaymentPreference .getString ("orderPaymentPreferenceId" ));
1589
- pgResponse .set ("paymentMethodTypeId" , "EXT_BILLACT" );
1590
- pgResponse .set ("transCodeEnumId" , "PGT_CAPTURE" );
1591
- pgResponse .set ("amount" , captureAmount );
1592
- pgResponse .set ("currencyUomId" , invoice .getString ("currencyUomId" ));
1593
- pgResponse .set ("transactionDate" , UtilDateTime .nowTimestamp ());
1594
- // referenceNum holds the relation to the order.
1595
- // todo: Extend PaymentGatewayResponse with a billingAccountId field?
1596
- pgResponse .set ("referenceNum" , billingAccountId );
1597
-
1598
- // save the response
1599
- savePgr (dctx , pgResponse );
1600
-
1601
- // Update the orderPaymentPreference
1602
- orderPaymentPreference .set ("statusId" , "PAYMENT_SETTLED" );
1603
- orderPaymentPreference .store ();
1604
-
1605
- results .put ("paymentGatewayResponseId" , responseId );
1606
- }
1607
- }
1608
- }
1609
- } catch (GenericEntityException | GenericServiceException ex ) {
1610
- return ServiceUtil .returnError (ex .getMessage ());
1611
- }
1612
-
1613
- return results ;
1614
- }
1615
-
1616
1528
public static Map <String , Object > captureBillingAccountPayments (DispatchContext dctx , Map <String , ? extends Object > context ) {
1617
1529
Delegator delegator = dctx .getDelegator ();
1618
1530
String invoiceId = (String ) context .get ("invoiceId" );
0 commit comments