我开始在一个项目中工作,该项目已经配置了eway的付款。我无法从eway网站上了解如何配置它来进行测试付款。 web.config中的当前设置为:
<appSettings>
<add key="PaymentGateway" value="2"/>
<add key="EwayRedirectUrl" value="http://localhost:54053/#/Memberships"/>
<add key="EwayApiKey" value="60CF3Ce97nRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
<add key="EwayPassword" value="API-P4ss"/>
<add key="EwayEnvironment" value="Sandbox"/>
</appSettings>
eway网站上的以下doc表示使用此测试信用卡:4444333322221111我可以进行虚拟付款。
我无法进行测试付款,因为它是实时网关,而不是测试网关?有人可以帮我支付测试费用吗?
修改
我有一些javascript代码加密卡然后传递给控制器。这是问题吗?也许加密没有正确完成?
function (card, membershipId, autoRenew) {
var encryptCard = angular.copy(card);
if (card !== null && !encryptCard.Token) {
encryptCard.CardNumber = eCrypt.encryptValue(card.CardNumber, key);
encryptCard.Cvv = eCrypt.encryptValue(card.Cvv, key);
}
var defer = $q.defer();
$http.post("/Inbox/ProcessMembershipRenewPayment", parseJsonObj({ card: encryptCard, membershipId: membershipId, autoRenew:autoRenew }))
.then(
function(response) {
var data = response.data;
if (data.Status) {
defer.resolve(data.Message);
} else {
defer.reject(data.Message);
}
},
function(err) {
defer.reject(err);
}
);
return defer.promise;
}
我在'eCrypt'下得到了一些曲折的线条:使用隐式声明的变量'eCrypt'。 在cshtml中,我包含了js文件的链接:
<script src="https://secure.ewaypayments.com/scripts/eCrypt.js"></script>
如果加密不是问题,这是向eway请求付款的方法:
private IRapidClient _ewayClient;
private readonly string _rapidEndpoint = ConfigurationManager.AppSettings["EwayEnvironment"];
public void Initialize(string apiKey, string password)
{
_ewayClient = RapidClientFactory.NewRapidClient(apiKey, password, _rapidEndpoint);
}
public EwayPaymentResponse Pay(EwayPaymentRequest request)
{
var ewayResponse = new EwayPaymentResponse {Status = false};
try
{
Transaction transaction = new Transaction
{
Customer = new Customer()
{
CardDetails = new CardDetails()
{
Name = request.Customer.CardDetails.Name,
Number = request.Customer.CardDetails.Number,
ExpiryMonth = request.Customer.CardDetails.ExpiryMonth,
ExpiryYear = request.Customer.CardDetails.ExpiryYear,
CVN = request.Customer.CardDetails.CVN
}
},
PaymentDetails = new PaymentDetails()
{
CurrencyCode = "AUD",
TotalAmount = Convert.ToInt32(request.Payment.TotalAmount * 100)
},
TransactionType = TransactionTypes.Purchase,
RedirectURL = ConfigurationManager.AppSettings["EwayRedirectUrl"],
};
CreateTransactionResponse response = _ewayClient.Create(PaymentMethod.Direct, transaction);
if (response.TransactionStatus.Status != null && (bool) response.TransactionStatus.Status)
{
ewayResponse.Status = true;
return ewayResponse;
}
if (response.Errors != null)
{
foreach (var errorCode in response.Errors)
{
ewayResponse.ErrorMessages.Add(RapidClientFactory.UserDisplayMessage(errorCode, "EN"));
}
return ewayResponse;
}
ewayResponse.ErrorMessages.Add("Invalid credit card information.");
return ewayResponse;
}
catch (Exception e)
{
ewayResponse.ErrorMessages.Add(e.Message);
return ewayResponse;
}
}
此处的付款方式是直接的。