[asp][bibit]

Pagina: 1
Acties:
  • 44 views sinds 30-01-2008

  • TeeDee
  • Registratie: Februari 2001
  • Laatst online: 15:52
Hoi,

ik ben bezig om bibit te "implementeren". Ik weet dat dit XML gestuurd is. Nu is normaal de persoon die XML afhandelt bij ons voor een lange tijd op vakantie, en nu is mij gevraagd om er verder aan te werken. (Ben nu al ongeveer 1 hele week bezig om het werkend te krijgen).

Ik werk op basis van hun ASP voorbeeldje:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<%
'------------------------------------------------------------------------------
' mod 010628 - a3

sUser   = "YOUR MERCHANTCODE"
sPass   = "PASSWORD"
sURL    = "https://secure-test.bibit.com/jsp/merchant/xml/paymentService.jsp"
sXML     = makeXMLorder("37482")        ' 37482 is the orderID in the database
call XML2Bibit(sXML)

'================================================================================

sub XML2Bibit(sXML)

'Response.Write "sending XML " & server.HTMLEncode(sXML) & "<HR>" ' check what you're sending
'Send the XML--------------------------------------------------------------
    Set xmlhttp =  Server.CreateObject("Msxml2.ServerXMLHTTP") ' the MS parser HTTP component
    ' use ServerXMLHTTP - Check http://support.microsoft.com/support/kb/articles/Q237/9/06.ASP
    ' if you get 'Err = Access is denied.' then try Msxml2.XMLHTTP (less reliable)
        
    xmlhttp.Open "POST",sURL, false, sUser, sPass
    xmlhttp.setRequestHeader "Content-Type", "text/xml"

    on error resume next
    xmlhttp.Send(sXML)

    if err then
        Response.Write "Err = " & err.description & "<BR>"
        Response.Write "Send Status : " & xmlhttp.status & "<BR>"
        Response.End
    end if
        
    Response.Write "Send Status (200 = OK) : " & xmlhttp.status & "<BR>Response : <BR>" ' Display the Response
    'Response.write "Headers :" & "<BR>" & xmlhttp.getAllResponseHeaders
    
    sUrl = ParseResponse(xmlhttp.responseText)
    if instr(sUrl,"ERROR") then 
        Response.Write sURL
    else
        Response.Write "<BR>Redirect URL : <A HREF=" & sUrl & ">" & sUrl & "</A>" 
        'Response.redirect url ' go to BIBIT payment selection page 
    end if  
        
end sub
'------------------------------------------------------------------------------

function ParseResponse(sXML)
    Set xmldoc = CreateObject("msxml2.domdocument")
    xmldoc.async = False : xmldoc.validateOnParse = true
    xmldoc.setProperty "ServerHTTPRequest", true ' may not be needed - see http://support.microsoft.com/support/kb/articles/Q281/1/42.ASP

    If Not xmldoc.loadxml(sXML) Then
        tmp =        "ERROR - XML load failed ! <BR>" 
        tmp = tmp & "errorcode : " & xmldoc.parseError.errorcode & ", " & xmldoc.parseError.reason & "<BR>"
        tmp = tmp & "srctext : " & xmldoc.parseError.srctext & "<BR>"
        tmp = tmp & "url : " &xmldoc.parseError.url & "<BR><BR>"
        tmp = tmp & "XML received : " & Server.HTMLEncode(sXML)
        ParseResponse = tmp
    else
        Set oCurrNode = xmldoc.documentElement.selectSingleNode("/paymentService/reply/orderStatus/reference")
        if oCurrNode is nothing then
            ParseResponse = "ERROR - no URL found"
        else
            ParseResponse = oCurrNode.text
        end if
    end if
end function
'------------------------------------------------------------------------------

function makeXMLorder(orderid) ' Read Record from a (very simple) example Access DB 
' DB record : id, prodid, desc, price, nr, cardnr, exp, cardname 
' of course you can also change this function and hardcode the order details 
' but don't forget to generate a unique ordercode each time
    
    'create ADO connection and recordset Set 
    Set cnOrders = Server.CreateObject("ADODB.Connection") 
    cnOrders.Open "ProductsDB" 
    
    Set rs = cnOrders.Execute("select * from orders where prodid = '" & orderid & "'")
    if Not rs.EOF then 
        xml = "<?xml version='1.0'?>" & vbcrlf 
        xml = xml & "<!DOCTYPE paymentService PUBLIC '-//Bibit/DTD Bibit PaymentService v1//EN' 'http://dtd.bibit.com/paymentService_v1.dtd'>" & vbCRLF     
        xml = xml & "<paymentService version='1.0' merchantCode='" &  sUser & "'>"  & vbcrlf
        xml = xml & "<submit>"  & vbcrlf
        xml = xml & "<order  orderCode = 'A" & "-" & datepart("s",now) & "'>" & vbCRLF
        xml = xml & "<description>" & rs("desc") & "</description>" & vbCRLF
        xml = xml & "<amount exponent='2' currencyCode = 'NLG' value = '" & rs("price") & "'/>" & vbCRLF
        xml = xml & "<orderContent>" &rs("prodid")& "</orderContent>" & vbCRLF
        xml = xml & "<paymentMethodMask><include code='ALL'/></paymentMethodMask>" & vbCRLF 
        xml = xml & "</order>" & vbCRLF 
        xml = xml & "</submit>"  & vbcrlf
        xml = xml & "</paymentService>" 
    else 'record not found 
        Response.Write "No record found"
    end if 
        
    rs.close : cnOrders.close 'close and release DB objects 
    makeXMLorder = xml 
end function 
%>

Nu ben ik eindelijk zover dat ik:
- verbinding heb met Bibit
- een order bij hun in het (test)systeem kan zetten
- de pagina krijg waarop de gebruiker zijn credit card gegevens kan invoeren

En nu komt het: er moet een redirect komen naar ons systeem terug. Alleen dat werkt dus niet...

Kan iemand mij (die meer met bibit gewerkt heeft) vertellen waar ik de "redirect" in bovenstaand voorbeeldje moet plaatsen? Ik heb namelijk veel met bibit gemaild en na 1 week erachter gekomen dat ze
a: geen support op "zelfgemaakte" dingen leveren
b: geen asp programmeurs voorhanden hebben

Dus dacht ik, als laatste redmiddel, laat ik het hier eens proberen...

Heart..pumps blood.Has nothing to do with emotion! Bored


  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

dubbel
[topic=442691/1/25]

Doet iets met Cloud (MS/IBM)


Dit topic is gesloten.