Skip to content

Commit 9336849

Browse files
committed
Updated Fraud Management Samples
1 parent f729a6f commit 9336849

5 files changed

Lines changed: 91 additions & 19 deletions

File tree

PaymentTransactions/UpdateHeldTransaction.cs renamed to FraudManagement/ApproveOrDeclineHeldTransaction.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
using AuthorizeNet;
77
using AuthorizeNet.Api.Controllers;
88
using AuthorizeNet.Api.Contracts.V1;
9-
using AuthorizeNet.Api.Controllers.Bases;
10-
11-
namespace net.authorize.sample.PaymentTransactions
12-
{
13-
class UpdateHeldTransaction
14-
{
9+
using AuthorizeNet.Api.Controllers.Bases;
10+
11+
namespace net.authorize.sample.PaymentTransactions
12+
{
13+
class ApproveOrDeclineHeldTransaction
14+
{
1515
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
1616
{
17-
Console.WriteLine("Update held transaction sample");
17+
Console.WriteLine("Approve held transaction sample");
1818

1919
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
2020
// define the merchant information (authentication / transaction id)
@@ -28,8 +28,8 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
2828
var request = new updateHeldTransactionRequest();
2929
request.heldTransactionRequest = new heldTransactionRequestType
3030
{
31-
action = afdsTransactionEnum.approve,
32-
refTransId = "12345"
31+
action = afdsTransactionEnum.approve,
32+
refTransId = "60012192922"
3333
};
3434

3535
// instantiate the controller that will call the service
@@ -40,7 +40,7 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
4040
var response = controller.GetApiResponse();
4141
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
4242
{
43-
Console.WriteLine(response.ToString());
43+
Console.WriteLine("Transaction Approved: "+response.transactionResponse.transId);
4444
}
4545
else if (response != null)
4646
{
@@ -49,6 +49,6 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
4949
}
5050

5151
return response;
52-
}
53-
}
54-
}
52+
}
53+
}
54+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using AuthorizeNet;
7+
using AuthorizeNet.Api.Controllers;
8+
using AuthorizeNet.Api.Contracts.V1;
9+
using AuthorizeNet.Api.Controllers.Bases;
10+
11+
namespace net.authorize.sample
12+
{
13+
public class GetHeldTransactionList
14+
{
15+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
16+
{
17+
Console.WriteLine("Get suspicious transaction list sample");
18+
19+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
20+
// define the merchant information (authentication / transaction id)
21+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
22+
{
23+
name = ApiLoginID,
24+
ItemElementName = ItemChoiceType.transactionKey,
25+
Item = ApiTransactionKey,
26+
};
27+
28+
var request = new getUnsettledTransactionListRequest();
29+
request.status = TransactionGroupStatusEnum.pendingApproval;
30+
request.statusSpecified = true;
31+
request.paging = new Paging
32+
{
33+
limit = 10,
34+
offset = 1
35+
};
36+
request.sorting = new TransactionListSorting
37+
{
38+
orderBy = TransactionListOrderFieldEnum.id,
39+
orderDescending = true
40+
};
41+
// instantiate the controller that will call the service
42+
var controller = new getUnsettledTransactionListController(request);
43+
controller.Execute();
44+
45+
// get the response from the service (errors contained if any)
46+
var response = controller.GetApiResponse();
47+
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
48+
{
49+
if (response.transactions == null)
50+
return response;
51+
52+
foreach (var item in response.transactions)
53+
{
54+
Console.WriteLine("Transaction Id: {0} was submitted on {1}", item.transId,
55+
item.submitTimeLocal);
56+
}
57+
}
58+
else if(response != null)
59+
{
60+
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
61+
response.messages.message[0].text);
62+
}
63+
64+
return response;
65+
}
66+
}
67+
}

SampleCode.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ private static void ShowMethods()
124124
Console.WriteLine(" GetTransactionDetails");
125125
Console.WriteLine(" GetTransactionList");
126126
Console.WriteLine(" UpdateSplitTenderGroup");
127-
Console.WriteLine(" UpdateHeldTransaction");
127+
Console.WriteLine(" GetHeldTransactionList");
128+
Console.WriteLine(" ApproveOrDeclineHeldTransaction");
128129
Console.WriteLine(" GetMerchantDetails");
129130
Console.WriteLine(" GetHostedPaymentPage");
130131
}
@@ -317,8 +318,11 @@ private static void RunMethod(String methodName)
317318
case "UpdateSplitTenderGroup":
318319
UpdateSplitTenderGroup.Run(apiLoginId, transactionKey);
319320
break;
320-
case "UpdateHeldTransaction":
321-
UpdateHeldTransaction.Run(apiLoginId, transactionKey);
321+
case "GetHeldTransactionList":
322+
GetHeldTransactionList.Run(apiLoginId, transactionKey);
323+
break;
324+
case "ApproveOrDeclineHeldTransaction":
325+
ApproveOrDeclineHeldTransaction.Run(apiLoginId, transactionKey);
322326
break;
323327
case "GetMerchantDetails":
324328
GetMerchantDetails.Run(apiLoginId, transactionKey);

SampleCode.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
<Compile Include="CustomerProfiles\UpdateCustomerProfile.cs" />
6666
<Compile Include="CustomerProfiles\UpdateCustomerShippingAddress.cs" />
6767
<Compile Include="CustomerProfiles\ValidateCustomerPaymentProfile.cs" />
68+
<Compile Include="FraudManagement\GetHeldTransactionList.cs" />
69+
<Compile Include="FraudManagement\ApproveOrDeclineHeldTransaction.cs" />
6870
<Compile Include="PaymentTransactions\AuthorizeCreditCard.cs" />
6971
<Compile Include="PaymentTransactions\CaptureFundsAuthorizedThroughAnotherChannel.cs" />
7072
<Compile Include="PaymentTransactions\CapturePreviouslyAuthorizedAmount.cs" />
@@ -76,7 +78,6 @@
7678
<Compile Include="PaymentTransactions\CreditBankAccount.cs" />
7779
<Compile Include="PaymentTransactions\DebitBankAccount.cs" />
7880
<Compile Include="PaymentTransactions\RefundTransaction.cs" />
79-
<Compile Include="PaymentTransactions\UpdateHeldTransaction.cs" />
8081
<Compile Include="PaymentTransactions\UpdateSplitTenderGroup.cs" />
8182
<Compile Include="PaymentTransactions\VoidTransaction.cs" />
8283
<Compile Include="PaypalExpressCheckout\AuthorizationAndCapture.cs" />
@@ -118,4 +119,4 @@
118119
<Target Name="AfterBuild">
119120
</Target>
120121
-->
121-
</Project>
122+
</Project>

TransactionReporting/GetUnsettledTransactionList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
2626
};
2727

2828
var request = new getUnsettledTransactionListRequest();
29-
request.status = TransactionGroupStatusEnum.pendingApproval;
29+
request.status = TransactionGroupStatusEnum.any;
3030
request.statusSpecified = true;
3131
request.paging = new Paging
3232
{

0 commit comments

Comments
 (0)