Package: dps-pxpy
This package provides a Python low-level client for theDPS Payment ExpressAPI’s.
Clients for bothPxPostandPxFusionare available.Installationpip install dps-pxpyUsagePxPostPxPost allows merchants to handle the entire lifecycle of payment transactions using HTTPS POST requests.For a complete documentation of the PxPost API:https://www.paymentexpress.com/Technical_Resources/Ecommerce_NonHosted/PxPost.aspxClientInstantiate a client with your PxPost username and password:from dps.pxpost import PxPostClient

client = PxPostClient("username", "password")PxPostClient relies on the popularrequests.AuthorizeTo issue an authorization on a credit or debit card:response = client.authorize(amount="10.01",
                            input_currency="NZD",
                            card_number="4111111111111111",
                            card_holder_name="Holder Name",
                            date_expiry="1114",
                            cvc2="123")You can also use a DPS billing token:response = client.authorize(amount="10.01",
                            input_currency="NZD",
                            dps_billing_id="billingtoken")Or, a custom billing token:response = client.authorize(amount="10.01",
                            input_currency="NZD",
                            billing_id="custombillingtoken")CompleteTo complete an authorization and transfer funds:response = client.complete(dps_txn_ref="reference")Purchasepurchaseis similar toauthorize, but funds are transferred immediately:response = client.purchase(amount="10.01",
                           input_currency="NZD",
                           card_number="4111111111111111",
                           card_holder_name="Holder Name",
                           date_expiry="1114",
                           cvc2="123")You can also use a DPS or custom billing token.RefundTo perform a complete or partial refund, use the dps transaction id returned bypurchaseorcomplete:response = client.refund(dps_txn_ref="reference",
                         amount="5.01",
                         merchant_reference="reason for refund")StatusTo query the status of a transaction, use your merchant transaction id (authorizeandpurchasecan take an optionaltxn_idused as a unique merchant reference):response = client.status(txn_id="inv1234")PxFusionPxFusion allows merchants to accept credit card details within a form on their own web page. The form posts sensitive data directly to DPS, which processes the transaction and redirects the user’s browser to the merchant’s website in a way that is totally transparent to the cardholder.For a complete documentation of the PxFusion API:https://www.paymentexpress.com/Technical_Resources/Ecommerce_NonHosted/PxFusion.aspxClientInstantiate a client with your PxFusion username and password:from dps.pxfusion import PxFusionClient

client = PxFusionClient("username", "password")PxFusionClient relies onsuds-jurkofor SOAP requests and ships withsuds_requeststo take advantage of requests.TransactionTo retrieve a session ID where funds are transferred immediately:response = client.purchase(amount="10.01",
                           currency="NZD",
                           return_url="https://yourdomain.com/pxfusion-callback",
                           txn_ref="ref")You can also issue authorizations:response = client.authorize(amount="10.01",
                            currency="NZD",
                            return_url="https://yourdomain.com/pxfusion-callback",
                            txn_ref="ref")Note that completing an authorization transaction must be done via PxPost’scomplete.After posting the payment details and session ID to the PxFusion endpoint (https://sec.paymentexpress.com/pxmi3/pxfusionauth), DPS redirects your customer toreturn_urlwith the session ID in the query string.StatusTo check the outcome of a transaction:response = client.status(transaction_id="sessionid")CancellationTo prevent a transaction from taking place:response = client.cancel(transaction_id="sessionid")Running TestsGet a copy of the repository:git clone git@github.com:OohlaLabs/dps-pxpy.git .Installtox:pip install toxRun the tests:toxContributionsAll contributions and comments are welcome.Change Logv0.2.1Switch to Semantic VersioningFix issue with parse_requirements for newer versions of pip (>=6.0.0)v0.2Fix setup.py for distributionv0.1Initial