Пример #1
0
 public void AcceptProcessResult(Payment payment, ProcessPaymentResult result)
 {
     if (result.PaymentStatus == PaymentStatus.Success)
     {
         ChangeStatus(payment, PaymentStatus.Success);
     }
 }
        public ProcessPaymentResult Process(PaymentProcessingContext context)
        {
            var settings = context.ProcessorConfig as AuthorizeNetConfig;

            var authRequest = CreateGatewayRequest(settings, context);
            var gateway = new Gateway(settings.LoginId, settings.TransactionKey, settings.SandboxMode);
            var response = gateway.Send(authRequest, context.Payment.Description);

            var result = new ProcessPaymentResult();

            if (response.Approved)
            {
                result.PaymentStatus = PaymentStatus.Success;
            }
            else
            {
                result.PaymentStatus = PaymentStatus.Failed;
                result.Message = response.ResponseCode + ": " + response.Message;
            }

            result.ThirdPartyTransactionId = response.TransactionID;

            return result;
        }