Ejemplo n.º 1
0
        public void TestConfigWriteRead()
        {
            // neue Config Datei erzeugen
            TPaySecupayConfig config = new TPaySecupayConfig
            {
                ApiKey = "133cb4492ced4f3f95a0b8e2823e301d", 
                ConnectionString = "data source=localhost;initial catalog=Secupay;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework",
                UrlSuccess = "http://www.ihre-shop-domain.de/success.aspx",
                UrlFailure = "http://www.ihre-shop-domain.de/failure.aspx",
                UrlPush = "http://www.ihre-shop-domain.de/push.aspx",
                Demo = 1,
                SendDeliveryAddress = true,
                Username = "******"
            };

            // Datei speichern 
            config.WriteToFile("secupay.xml");

            // Config Datei mit Dateinamen einlesen
            TPaySecupayConfig config2 = TPaySecupayConfig.LoadFromFile("secupay.xml");
            Assert.IsNotNull(config2);

            // Config Datei mit Default Dateinamen einlesen
            TPaySecupayConfig config3 = TPaySecupayConfig.LoadFromFile();
            Assert.IsNotNull(config3);
        }
Ejemplo n.º 2
0
        public void TestConfigWriteRead()
        {
            // neue Config Datei erzeugen
            TPaySecupayConfig config = new TPaySecupayConfig
            {
                ApiKey              = "133cb4492ced4f3f95a0b8e2823e301d",
                ConnectionString    = "data source=localhost;initial catalog=Secupay;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework",
                UrlSuccess          = "http://www.ihre-shop-domain.de/success.aspx",
                UrlFailure          = "http://www.ihre-shop-domain.de/failure.aspx",
                UrlPush             = "http://www.ihre-shop-domain.de/push.aspx",
                Demo                = 1,
                SendDeliveryAddress = true,
                Username            = "******"
            };

            // Datei speichern
            config.WriteToFile("secupay.xml");

            // Config Datei mit Dateinamen einlesen
            TPaySecupayConfig config2 = TPaySecupayConfig.LoadFromFile("secupay.xml");

            Assert.IsNotNull(config2);

            // Config Datei mit Default Dateinamen einlesen
            TPaySecupayConfig config3 = TPaySecupayConfig.LoadFromFile();

            Assert.IsNotNull(config3);
        }
Ejemplo n.º 3
0
        public void TestManagerGetTypes()
        {
            TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(ConfigFileName);

            var man = new TPaySecupayManager(config);
            PaySecupayGetTypes ret = man.GetPaymentTypes();

            Assert.AreEqual(ret.ResponseStatus, "ok");
        }
Ejemplo n.º 4
0
        public void TestManagerStatus()
        {
            TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(ConfigFileName);

            // TODO: insert hashcode here
            PaySecupayStatus secupayStatus = new TPayFactory(config).CreateSecupayStatus("hashcode");
            var man = new TPaySecupayManager(config);

            man.StatusPayment(secupayStatus);
        }
Ejemplo n.º 5
0
        public void TestCreateDb()
        {
            TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(ConfigFileName);

            var    context          = new PaySecupayContext(config.ConnectionString, config.Username);
            string dbCreationScript = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript();

            File.WriteAllText("secupay-db-create.sql", dbCreationScript);
            Process.Start("secupay-db-create.sql");
        }
Ejemplo n.º 6
0
    protected void btnOK_OnClick(object sender, EventArgs e)
    {
        TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(Server.MapPath("~/app_data/" + ConfigFileName));

        // Zahlungsobjekt erzeugen
        PaySecupayInit secupayInit = new TPayFactory(config).CreateSecupayInit(Convert.ToDecimal(txtBetrag.Text));

        // Daten in Zahlungsobjekt übergeben
        secupayInit.Firstname     = "Karl";
        secupayInit.Lastname      = "Mustermann";
        secupayInit.Langauge      = "DE";
        secupayInit.Street        = "Hauptstrasse";
        secupayInit.Housenumber   = "12";
        secupayInit.Zip           = "50000";
        secupayInit.City          = "Köln";
        secupayInit.Telephone     = "";
        secupayInit.Email         = "";
        secupayInit.PaymentAction = EnumPaymentAction.sale.ToString();
        secupayInit.PaymentType   = drpType.SelectedValue;

        // Artikel übergeben
        secupayInit.Basket.Add(new PaySecupayBasket
        {
            Name          = "Item",
            ArticleNumber = "01-1111",
            Ean           = "111111111111111111",
            Model         = "Model",
            Price         = "100",
            Quantity      = "1",
            Tax           = "19",
            Total         = "100",
        }.SetNew(config.Username));

        // Lieferadresse übergeben
        secupayInit.DeliveryAddress = new PaySecupayDeliveryAddress
        {
            Firstname   = secupayInit.Firstname,
            Lastname    = secupayInit.Lastname,
            Company     = secupayInit.Company,
            Street      = secupayInit.Street,
            Housenumber = secupayInit.Housenumber,
            Zip         = secupayInit.Zip,
            City        = secupayInit.City,
            Country     = secupayInit.Country
        }.SetNew(config.Username);

        // Bezahlung am Gateway anmelden und IFrameUrl generieren
        TPaySecupayManager man = new TPaySecupayManager(config);

        man.InitPayment(secupayInit);

        // Objekt wird im Beispiel in Session gesichert und auf Bezahlseite weitergeleitet
        Session["secupayInit"] = secupayInit;
        Response.Redirect("payment.aspx");
    }
Ejemplo n.º 7
0
        public void TestManagerInit()
        {
// config einladen
            TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(ConfigFileName);

// Über Factory paySecupayInit Objekt erzeugen
            PaySecupayInit secupayInit = new TPayFactory(config).CreateSecupayInit(1.23m);

// Daten aus Verkauf übertragen
            secupayInit.Firstname     = "Karl";
            secupayInit.Lastname      = "Mustermann";
            secupayInit.Langauge      = "DE";
            secupayInit.Street        = "Hauptstrasse";
            secupayInit.Housenumber   = "12";
            secupayInit.Zip           = "50000";
            secupayInit.City          = "Köln";
            secupayInit.Telephone     = "000-111222555";
            secupayInit.Email         = "";
            secupayInit.PaymentAction = EnumPaymentAction.sale.ToString();
            secupayInit.PaymentType   = EnumPaymentType.creditcard.ToString();


// Inhalt des Warenkorbs anfügen
            secupayInit.Basket.Add(new PaySecupayBasket
            {
                Name          = "Item1",
                ArticleNumber = "01-1111",
                Ean           = "11111111111111111",
                Model         = "Model",
                Price         = "1.23",
                Quantity      = "1",
                Tax           = "19",
                Total         = "100",
            }.SetNew(config.Username));

// Lieferadresse übergeben
            secupayInit.DeliveryAddress = new PaySecupayDeliveryAddress
            {
                Firstname   = secupayInit.Firstname,
                Lastname    = secupayInit.Lastname,
                Company     = secupayInit.Company,
                Street      = secupayInit.Street,
                Housenumber = secupayInit.Housenumber,
                Zip         = secupayInit.Zip,
                City        = secupayInit.City,
                Country     = secupayInit.Country
            }.SetNew(config.Username);

// Payment beim Gateway anfordern --> Hash und IFrame Url werden geliefert
            var man = new TPaySecupayManager(config);

            man.InitPayment(secupayInit);

            Process.Start(secupayInit.ResponseIFrameUrl);
        }
Ejemplo n.º 8
0
        public void TestManagerPush()
        {
            TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(ConfigFileName);

            var man = new TPaySecupayManager(config);

            // Der zu testenden String aus der Push Antwort vom Gateway
            const string q =
                @"hash=hhhhhhh&status_id=6&status_description=abgeschlossen&changed=1391605747&payment_status=accepted&apikey=133cb4492ced4f3f95a0b8e2823e301d&hint=";

            // Url Parameter werden in Name Value Collection gewandelt
            NameValueCollection form = HttpUtility.ParseQueryString(q);

            // Beispiel für eine Einbindung im ASHX Handler. Die Formulardatean werden mit der Seite und dem Referrer übergeben.
            man.ProcessPush(form, "/pay.secupay.web/push.ashx", "https://api-dist.secupay-ag.de/");
        }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Das Anfrageobjekt wird aus der Session genommen. Alternativ geht auch eine Datenbank
        var secupayInit = Session["secupayInit"] as PaySecupayInit;

        // Konfiguration laden
        TPaySecupayConfig config = TPaySecupayConfig.LoadFromFile(Server.MapPath("~/app_data/" + ConfigFileName));

        TPaySecupayManager man = new TPaySecupayManager(config);

        // Statusanfrage erstellen, um sicher zu sein, ob Zahlung erfolgreich ist.
        PaySecupayStatus secupayStatus = new TPayFactory(config).CreateSecupayStatus(secupayInit.ResponseHash);

        // Statusanfrage senden
        man.StatusPayment(secupayStatus);

        // Antwort auswerten
        // TODO: Hier muss im SHOP ein Prozess gestartet werden
        status.InnerHtml = secupayStatus.JsonOut + "<br />" + secupayStatus.JsonIn;
    }