Coder Social home page Coder Social logo

authorizenet-objects's People

Contributors

judgej avatar ptuchik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

authorizenet-objects's Issues

Protect sensitive information from var_dump

The authentication object and the credit card object (at least) need their data to be protected from var_dump() and probably serialize(), to avoid accidental exposure during debugging or logging.

Remove resultCode from Messages

The Authorize.Net response put the overall result, resultCode, into the messages entity. I've simply followed that same structure in Academe\AuthorizeNet\Response\Collections\Messages.

Instead, the list of top level messages should be unbound from the resultCode so the user does not have to handle the messages at all in order to look at the result.

Reference the API XSD Schema

There is a schema that gives us most of what we need to know about the objects:

https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd

It does not cover webhooks. If we are not auto-generating code from this schema, then we could at least use it to generate validation rules or tests.

The name "authorizenet-schema" feels like it would have been a better name than "authorizenet-objects" too.

Support BOM removal

This is a bit messy. The JSON response from Authorize.Net includes a BOM sequence at the start. This is invisible to the human eye, but causes json_decode() to throw a wobbly. It simply cannot decode the JSON with the BOM.

This is suggested in many places to remove the BOM:

preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json_string);

I would probably be a little more specific by looking at only the first (up to) three characters:

preg_replace('/^[\x00-\x1F\x80-\xFF]{1,3}/', '', $json_string);

There is also a plugin for Guzzle that removes the BOM, but that appears to be for older Guzzle versions. Not sure about the latest.

Anyway, it has not really got anything to do with these messages, because it's not a part of the data, but if we are not aware of it, it will certainly come to bite us when not dealt with at the transport level.

Support cardToken for opaque data

Allow the opaque data to be passed in as a single cardToken, with the descriptor and value separated by a colon (for now, can revise if other string formats are more suitable).

CHECKME: JSON arrays

The documentation gives example XML arrays like this:

    <lineItems>
      <lineItem>
        <itemId>1</itemId>
        <name>vase</name>
        <description>Cannes logo </description>
        <quantity>18</quantity>
        <unitPrice>45.00</unitPrice>
      </lineItem>
    </lineItems>

then the JSON form looks like this in some places (with no arrays or unique properties, so could never work if there were more than one lineItem):

            "lineItems": {
                "lineItem": {
                    "itemId": "1",
                    "name": "vase",
                    "description": "Cannes logo",
                    "quantity": "18",
                    "unitPrice": "45.00"
                }
            },

and in other places it looks like this:

            "userFields": {
                "userField": [
                    {
                        "name": "MerchantDefinedFieldName1",
                        "value": "MerchantDefinedFieldValue1"
                    },
                    {
                        "name": "favorite_color",
                        "value": "blue"
                    }
                ]
            }

Now, this may be how it works, but looks wrong. It could be that a single lineItem is sent as an object, and multiple lineItems are sent as an array of objects, but it makes more sense to me if the same datatype is used in all cases (instead of a lineItem being sometimes an object and sometimes an array), i.e. an array of objects, even if only one. If always sending an array, then it it makes sense to drop the userField object in the structure. This is how I have assumed it works, for now:

            "userFields": [
                    {
                        "name": "MerchantDefinedFieldName1",
                        "value": "MerchantDefinedFieldValue1"
                    },
                    {
                        "name": "favorite_color",
                        "value": "blue"
                    }
            ]

This ticket will remain open until I know which is correct.

Support the Notify handler (webhooks)

Authorize.Net supports "webhooks" that allow it to feed all authorisation results direct to the merchant site as a server-to-server request. It looks like this needs to be registered with the account and is not something enabled by default in the API (so testing webhooks with the sandbox may not be possible).

On return to the merchant site from the Hosted Payment Page, a GET is performed with the given return URL and NO further details. This means that if a web hook is not used to record the result, then the merchant site must explicitly fetch the transaction details, so an request is needed for that too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.