Skip to content

Commit

Permalink
Updated Fraud Management Samples
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmc committed Dec 8, 2016
1 parent f729a6f commit 9336849
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
using AuthorizeNet;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers.Bases;

namespace net.authorize.sample.PaymentTransactions
{
class UpdateHeldTransaction
{
using AuthorizeNet.Api.Controllers.Bases;

namespace net.authorize.sample.PaymentTransactions
{
class ApproveOrDeclineHeldTransaction
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Update held transaction sample");
Console.WriteLine("Approve held transaction sample");

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

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

return response;
}
}
}
}
}
}
67 changes: 67 additions & 0 deletions FraudManagement/GetHeldTransactionList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AuthorizeNet;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers.Bases;

namespace net.authorize.sample
{
public class GetHeldTransactionList
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Get suspicious transaction list sample");

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};

var request = new getUnsettledTransactionListRequest();
request.status = TransactionGroupStatusEnum.pendingApproval;
request.statusSpecified = true;
request.paging = new Paging
{
limit = 10,
offset = 1
};
request.sorting = new TransactionListSorting
{
orderBy = TransactionListOrderFieldEnum.id,
orderDescending = true
};
// instantiate the controller that will call the service
var controller = new getUnsettledTransactionListController(request);
controller.Execute();

// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transactions == null)
return response;

foreach (var item in response.transactions)
{
Console.WriteLine("Transaction Id: {0} was submitted on {1}", item.transId,
item.submitTimeLocal);
}
}
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}

return response;
}
}
}
10 changes: 7 additions & 3 deletions SampleCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ private static void ShowMethods()
Console.WriteLine(" GetTransactionDetails");
Console.WriteLine(" GetTransactionList");
Console.WriteLine(" UpdateSplitTenderGroup");
Console.WriteLine(" UpdateHeldTransaction");
Console.WriteLine(" GetHeldTransactionList");
Console.WriteLine(" ApproveOrDeclineHeldTransaction");
Console.WriteLine(" GetMerchantDetails");
Console.WriteLine(" GetHostedPaymentPage");
}
Expand Down Expand Up @@ -317,8 +318,11 @@ private static void RunMethod(String methodName)
case "UpdateSplitTenderGroup":
UpdateSplitTenderGroup.Run(apiLoginId, transactionKey);
break;
case "UpdateHeldTransaction":
UpdateHeldTransaction.Run(apiLoginId, transactionKey);
case "GetHeldTransactionList":
GetHeldTransactionList.Run(apiLoginId, transactionKey);
break;
case "ApproveOrDeclineHeldTransaction":
ApproveOrDeclineHeldTransaction.Run(apiLoginId, transactionKey);
break;
case "GetMerchantDetails":
GetMerchantDetails.Run(apiLoginId, transactionKey);
Expand Down
5 changes: 3 additions & 2 deletions SampleCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<Compile Include="CustomerProfiles\UpdateCustomerProfile.cs" />
<Compile Include="CustomerProfiles\UpdateCustomerShippingAddress.cs" />
<Compile Include="CustomerProfiles\ValidateCustomerPaymentProfile.cs" />
<Compile Include="FraudManagement\GetHeldTransactionList.cs" />
<Compile Include="FraudManagement\ApproveOrDeclineHeldTransaction.cs" />
<Compile Include="PaymentTransactions\AuthorizeCreditCard.cs" />
<Compile Include="PaymentTransactions\CaptureFundsAuthorizedThroughAnotherChannel.cs" />
<Compile Include="PaymentTransactions\CapturePreviouslyAuthorizedAmount.cs" />
Expand All @@ -76,7 +78,6 @@
<Compile Include="PaymentTransactions\CreditBankAccount.cs" />
<Compile Include="PaymentTransactions\DebitBankAccount.cs" />
<Compile Include="PaymentTransactions\RefundTransaction.cs" />
<Compile Include="PaymentTransactions\UpdateHeldTransaction.cs" />
<Compile Include="PaymentTransactions\UpdateSplitTenderGroup.cs" />
<Compile Include="PaymentTransactions\VoidTransaction.cs" />
<Compile Include="PaypalExpressCheckout\AuthorizationAndCapture.cs" />
Expand Down Expand Up @@ -118,4 +119,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
2 changes: 1 addition & 1 deletion TransactionReporting/GetUnsettledTransactionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
};

var request = new getUnsettledTransactionListRequest();
request.status = TransactionGroupStatusEnum.pendingApproval;
request.status = TransactionGroupStatusEnum.any;
request.statusSpecified = true;
request.paging = new Paging
{
Expand Down

0 comments on commit 9336849

Please sign in to comment.