public void ParseCallbackParameters()
        {
            // Make call to reserve fixed amount
            var parameters = new Dictionary <string, object>();

            parameters.Add("terminal", GatewayConstants.terminal);
            parameters.Add("shop_orderid", Guid.NewGuid().ToString());
            parameters.Add("amount", "123.45");
            parameters.Add("currency", Currency.DKK.GetNumericString());

            parameters.Add("cardnum", "12345");
            parameters.Add("emonth", "10");
            parameters.Add("eyear", "2020");
            parameters.Add("cvc", "123");

            string        reservationResponseStr = CallApi("reservationOfFixedAmount", parameters);
            ReserveResult paymentResult          = _api.ParsePostBackXmlResponse(reservationResponseStr) as ReserveResult;

            Assert.IsNotNull(paymentResult);
            Assert.AreEqual(Result.Success, paymentResult.Result);
        }
예제 #2
0
        public void HandleNotification(NameValueCollection postParameters, IMerchantApi merchantApi)
        {
            PaymentResult paymentResult = merchantApi.ParsePostBackXmlResponse(postParameters["xml"]) as PaymentResult;

            //
            // the posted data contains a "status" field, which is where you can see what kind of notification this is
            //
            if (postParameters["status"].Equals("ChargebackEvent"))
            {
                //
                // something chargeback related happened
                // could be the chargeback itself, a dispute etc
                //
                foreach (ChargebackEvent cbe in paymentResult.Payment.ChargebackEvents)
                {
                    // do whatever you need to do
                }
            }

            else
            {
                //
                // payment status changed
                //

                // check the amounts against what you expect them to be and act accordingly
                var reservedAmount = paymentResult.Payment.ReservedAmount;
                var capturedAmount = paymentResult.Payment.CapturedAmount;
                var refundedAmount = paymentResult.Payment.RefundedAmount;

                // or even better... check the ReconciliationIdentifiers, which
                // contains information on captures and refunds (nothing else)
                foreach (ReconciliationIdentifier refundOrCapture in paymentResult.Payment.ReconciliationIdentifiers)
                {
                }
            }
        }