django-oscar / django-oscar-docdata

Docdata Payments Gateway integration for django-oscar
Apache License 2.0
22 stars 11 forks source link

Attribute 'numberOfDays' must appear on element 'ns1:period2' #19

Closed jedie closed 5 years ago

jedie commented 5 years ago

Found another bug:

"XML request does not match XSD. The data is: cvc-complex-type.4: Attribute 'numberOfDays' must appear on element 'ns1:period2'..", DocdataCreateError(XML request does not match XSD. The data is: cvc-complex-type.4: Attribute 'numberOfDays' must appear on element 'ns1:period2'..,

From xsd1-1_2.xsd:

    <complexType name="exhortationPeriod">
        <attribute name="numberOfDays" type="int" use="required">
            <annotation>
                <documentation>
                    The number of days after communication to the
                    shopper
                    the exhortation period will be initiated.
                </documentation>
            </annotation>
        </attribute>
        <attribute name="profile" type="ddp:string50" use="optional">
            <annotation>
                <documentation>The profile that is used to determine the payment
                    methods for this order during this exhortation period.
                </documentation>
            </annotation>
        </attribute>
    </complexType>

It seems that exhortationPeriod and numberOfDays is completely missing from code base, isn't it?

jedie commented 5 years ago

I just tried to implement it in the same way as "paymentPreferences": https://github.com/wearehoods/django-oscar-docdata/commit/fb36555c2f9c9256745869effadf834450c28b95

But it doesn't work, because of: create() got an unexpected keyword argument 'exhortationPeriod'

jedie commented 5 years ago
2019-02-01 11:40:48,632    DEBUG .../python3.6/site-packages/suds/transport/http.py:80  sending:
URL: https://test.docdatapayments.com:443/ps/services/paymentservice/1_2
HEADERS: {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': b'"create"', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': b'"create"'}
MESSAGE:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.docdatapayments.com/services/paymentservice/1_2/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns1:createRequest version="1.2">
         <ns1:merchant name="foobar-foobar" password="foobar"/>
         <ns1:merchantOrderReference>100005</ns1:merchantOrderReference>
         <ns1:paymentPreferences>
            <ns1:profile>test</ns1:profile>
            <ns1:numberOfDaysToPay>7</ns1:numberOfDaysToPay>
            <ns1:exhortation>
               <ns1:period1/>
               <ns1:period2/>
            </ns1:exhortation>
         </ns1:paymentPreferences>
         <ns1:menuPreferences>
            <ns1:css id="1"/>
         </ns1:menuPreferences>
         <ns1:shopper id="87">
            <ns1:name>
               <ns1:first>Mr. foobar</ns1:first>
               <ns1:last>No. 1</ns1:last>
            </ns1:name>
            <ns1:email>foobar_1@test.tld</ns1:email>
            <ns1:language code="en"/>
            <ns1:gender>U</ns1:gender>
         </ns1:shopper>
         <ns1:totalGrossAmount currency="EUR">500</ns1:totalGrossAmount>
         <ns1:billTo>
            <ns1:name>
               <ns1:first>Mr. foobar</ns1:first>
               <ns1:last>No. 1</ns1:last>
            </ns1:name>
            <ns1:address>
               <ns1:street>billing address</ns1:street>
               <ns1:houseNumber>N/A</ns1:houseNumber>
               <ns1:postalCode>billingzip</ns1:postalCode>
               <ns1:city>billing city</ns1:city>
               <ns1:country code="JM"/>
            </ns1:address>
         </ns1:billTo>
         <ns1:description>User-ID: 87, 1x1x foo</ns1:description>
         <ns1:includeCosts>false</ns1:includeCosts>
         <ns1:invoice>
            <ns1:totalNetAmount currency="EUR">500</ns1:totalNetAmount>
            <ddp:totalVatAmount xmlns:ddp="http://www.docdatapayments.com/services/paymentservice/1_2/" rate="0" currency="EUR">0</ddp:totalVatAmount>
            <ns1:item number="4">
               <ns1:name>1x foo</ns1:name>
               <ns1:code>1_credits</ns1:code>
               <ddp:quantity xmlns:ddp="http://www.docdatapayments.com/services/paymentservice/1_2/" unitOfMeasure="PCS">1</ddp:quantity>
               <ns1:description>-</ns1:description>
               <ns1:netAmount currency="EUR">500</ns1:netAmount>
               <ns1:grossAmount currency="EUR">500</ns1:grossAmount>
               <ns1:vat rate="0">
                  <ns1:amount currency="EUR">0</ns1:amount>
               </ns1:vat>
               <ns1:totalNetAmount currency="EUR">500</ns1:totalNetAmount>
               <ns1:totalGrossAmount currency="EUR">500</ns1:totalGrossAmount>
               <ns1:totalVat rate="0">
                  <ns1:amount currency="EUR">0</ns1:amount>
               </ns1:totalVat>
            </ns1:item>
            <ns1:shipTo>
               <ns1:name>
                  <ns1:first>Mr. foobar</ns1:first>
                  <ns1:last>No. 1</ns1:last>
               </ns1:name>
               <ns1:address>
                  <ns1:street>billing address</ns1:street>
                  <ns1:houseNumber>N/A</ns1:houseNumber>
                  <ns1:postalCode>billingzip</ns1:postalCode>
                  <ns1:city>billing city</ns1:city>
                  <ns1:country code="JM"/>
               </ns1:address>
            </ns1:shipTo>
         </ns1:invoice>
         <ns1:integrationInfo>
            <ns1:webshopPlugin>django-oscar-docdata</ns1:webshopPlugin>
            <ns1:webshopPluginVersion>1.2.13.pre0</ns1:webshopPluginVersion>
            <ns1:programmingLanguage>Python</ns1:programmingLanguage>
         </ns1:integrationInfo>
      </ns1:createRequest>
   </ns0:Body>
</SOAP-ENV:Envelope>

2019-02-01 11:40:48,734    DEBUG .../python3.6/site-packages/suds/transport/http.py:87  received:
CODE: HTTPStatus.OK
HEADERS: Date: Fri, 01 Feb 2019 11:40:48 GMT
Server: Apache
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/xml;charset=utf-8
Set-Cookie: SESSPERSIST=10|XFQwQ; path=/; HttpOnly; Secure

MESSAGE:
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><createResponse xmlns="http://www.docdatapayments.com/services/paymentservice/1_2/"><createError><error code="REQUEST_DATA_INCORRECT">XML request does not match XSD. The data is: cvc-complex-type.4: Attribute 'numberOfDays' must appear on element 'ns1:period2'..</error></createError></createResponse></S:Body></S:Envelope>
jedie commented 5 years ago

Only happening with "suds-community" but not with "suds-jurko", see also: https://github.com/django-oscar/django-oscar-docdata/issues/15

So, i close this issues.