Skip to content

Instantly share code, notes, and snippets.

@mrezentes
Last active September 2, 2016 00:16
Show Gist options
  • Save mrezentes/b48d9355c234b80ddb3434d0d3a2e139 to your computer and use it in GitHub Desktop.
Save mrezentes/b48d9355c234b80ddb3434d0d3a2e139 to your computer and use it in GitHub Desktop.
Testing headers

Conclusion: The request from Spreedly contains the proper header: CONTENT_TYPE = text/xml;charset=utf-8

Spreedly header functionality has been tested as follows:

Create a receiver that uses http:/posttestserver.com.

  curl https://core.spreedly.com/v1/receivers.xml \
  -u 'Your credentials here' \
  -H 'Content-Type: application/xml' \
  -d '<receiver>
        <receiver_type>test</receiver_type>
        <hostnames>http://posttestserver.com</hostnames>
      </receiver>'

Create a test payment method:

curl https://core.spreedly.com/v1/payment_methods.xml \
  -u 'Your credentials here' \
  -H 'Content-Type: application/xml' \
  -d '<payment_method>
        <credit_card>
            <first_name>Joey</first_name>
            <last_name>Jones</last_name>
            <number>5555555555554444</number>
            <verification_value>423</verification_value>
            <month>3</month>
            <year>2032</year>
        </credit_card>
        <retained>true</retained>
        <email>[email protected]</email>
      </payment_method>'

Create a deliver request to the test receiver:

curl https://core.spreedly.com/v1/receivers/NMdzJnyWZJDr2YrPsJwFj9rbDdz/deliver.json \
  -u 'Your credentials here' \
 -H 'Content-Type:application/xml' \
  -d '<delivery>
        <url>http://posttestserver.com/post.php?dir=echo_test</url>
        <headers><![CDATA[Content-Type: text/xml;charset=utf-8]]></headers>
        <body><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]>
</body>
        <payment_method_token>E54fzCN3XgN9bGfohOrkUnei1PP</payment_method_token>
</delivery>'

Check the results on the server by following the link returned in the response. There is a "View it at" section in the response giving a link to view the results. (http://www.posttestserver.com/data/2016/09/01/echo_test/16.36.561909182105)

Transcript:

"[*>] POST to http://posttestserver.com/post.php?dir=echo_test\r\n\r\nUser-Agent: spreedly-agent/Typhoeus 0.6.9\r\nContent-Type: text/xml;charset=utf-8\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\r\n\r\n[<*] Response 200 received in 0s\r\n\r\nDate: Thu, 01 Sep 2016 20:21:40 GMT\r\nServer: Apache\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept\r\nVary: Accept-Encoding\r\nContent-Length: 149\r\nContent-Type: text/html; charset=UTF-8\r\n\r\nSuccessfully dumped 0 post variables.\nView it at http://www.posttestserver.com/data/2016/09/01/echo_test/16.36.561909182105\nPost body was 39 chars long."

Results:

Time: Thu, 01 Sep 16 13:21:40 -0700
Source ip: 24.163.81.134

Headers (Some may be inserted by server)
HTTP_CONNECTION = close
REQUEST_URI = /post.php?dir=echo_test
QUERY_STRING = dir=echo_test
REQUEST_METHOD = POST
GATEWAY_INTERFACE = CGI/1.1
REMOTE_PORT = 50983
REMOTE_ADDR = 24.163.81.134
CONTENT_LENGTH = 39
CONTENT_TYPE = text/xml;charset=utf-8
HTTP_USER_AGENT = spreedly-agent/Typhoeus 0.6.9
HTTP_ACCEPT = */*
HTTP_HOST = posttestserver.com
UNIQUE_ID = V8iN1EBaMGUAADIwfg4AAAAR
REQUEST_TIME_FLOAT = 1472761300.6417
REQUEST_TIME = 1472761300

No Post Params.

== Begin post body ==
<?xml version="1.0" encoding="UTF-8"?>

== End post body ==

Upload contains PUT data:
<?xml version="1.0" encoding="UTF-8"?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment