Solitude API Client

lib.solitude.api.client

An instantiated SolitudeAPI object using settings.SOLITUDE_URL

class lib.solitude.api.BangoProvider(slumber)

Bango payment provider

class lib.solitude.api.BokuProvider(*args, **kw)

The Boku payment provider.

exception TransactionError

Error relating to a Boku transaction.

exception lib.solitude.api.BuyerNotConfigured

The buyer has not yet been configured for the payment.

class lib.solitude.api.PayProvider(slumber)

Abstract payment provider

This encapsulates some API logic specific to payment providers such as configuring a new payment, creating products, etc.

create_product(generic_product, provider_seller, external_id, product_name)

Creates and returns a provider-specific product object from Solitude.

create_transaction(generic_buyer, generic_seller, generic_product, provider_product, provider_seller_uuid, product_name, transaction_uuid, prices, user_uuid, application_size, source, icon_url, mcc=None, mnc=None)

Create a provider specific transaction and a generic Solitude transaction.

Return the provider a tuple of:

(transaction ID, payment start URL)

get_notification_data(request)

Given a provider-specific GET/POST request, return a dict of notification data that can be used for verification.

For example, a provider might notify Webpay of a successful transaction. That request might include a signature that can be used to verify authenticity.

get_product(generic_seller, generic_product)

Returns the provider specific product object from Solitude.

get_seller(generic_seller, provider_seller_uuid)

Returns a provider-specific seller object from Solitude.

transaction_from_notice(parsed_qs)

Get the Solitude transaction ID from the query string on a notification URL.

verify_notification(data)

Verify provider notification using params from get_notification_data().

This will raise an exception on any kind of verification error. This will also raise an exception if the transaction has already been processed.

Returns the Solitude transaction UUID.

class lib.solitude.api.ProviderHelper(name, slumber=None)

A common interface to all payment providers.

create_product(external_id, product_name, generic_seller, provider_seller_uuid, generic_product=None)

Creates a generic product and provider product on the fly.

This is for scenarios like adhoc in-app payments where the system might be selling a product for the first time.

server_notification(request)

Handles the server to server notification that is sent after a transaction is completed.

Returns the Solitude transaction UUID.

start_transaction(transaction_uuid, generic_seller_uuid, provider_seller_uuid, product_id, product_name, prices, icon_url, user_uuid, application_size, source='unknown', mcc=None, mnc=None)

Start a payment provider transaction to begin the purchase flow.

classmethod supported_providers(mcc=None, mnc=None)

Given the user’s mobile network (when available) return a list of all suitable provider helper objects in order of preference.

Keyword arguments:

mcc
The user’s mobile carrier code, if known.
mnc
The user’s mobile network code, if known.
class lib.solitude.api.ReferenceProvider(slumber)

A reference payment provider

Our current reference implementation is known as Zippy.

This is our ideal API. If possible, other payment providers should follow this API.

If this provider is fully compliant it probably shouldn’t need to override any of the inherited methods.

exception lib.solitude.api.SellerNotConfigured

The seller has not yet been configued for the payment.

class lib.solitude.api.SolitudeAPI(*args, **kw)

A Solitude facade that works with a payment provider or the generic Solitude API.

Parameters:url – URL of the solitude endpoint.
change_pin(uuid, pin, etag='', pin_confirmed=False, clear_was_locked=False)

Changes the pin of a buyer, for use with buyers who exist without pins.

Parameters:
  • integer (buyer_id) – ID of the buyer you’d like to change the PIN for.
  • pin – PIN the user would like to change to.
  • pin_confirmed – Boolean to set if the PIN was already confirmed in the UI.
  • clear_was_locked – Boolean to clear the pin_was_locked_out state if the PIN was changed by the user.
Return type:

dictionary

confirm_pin(uuid, pin)

Confirms the buyer’s pin, marking it at confirmed in solitude

Parameters:
  • uuid – String to identify the buyer by.
  • pin – PIN to confirm
Return type:

boolean

create_buyer(uuid, email, pin=None, pin_confirmed=False)

Creates a buyer with an optional PIN in solitude.

Parameters:
  • uuid – String to identify the buyer by.
  • pin – Optional PIN that will be hashed.
  • pin_confirmed – Optional boolean to set if the PIN was already confirmed in the UI.
Return type:

dictionary

get_active_product(public_id)

Retrieves a an active seller product by its public_id.

Parameters:public_id – Product public_id.
Return type:dictionary
get_buyer(uuid, use_etags=True)

Retrieves a buyer by their uuid.

Parameters:uuid – String to identify the buyer by.
Return type:dictionary
reset_confirm_pin(uuid, pin)

Confirms the buyer’s pin, marking it at confirmed in solitude

Parameters:
  • uuid – String to identify the buyer by.
  • pin – PIN to confirm
Return type:

boolean

set_new_pin(uuid, new_pin, etag='')

Sets the new_pin for use with a buyer that is resetting their pin.

Parameters:
  • integer (buyer_id) – ID of the buyer you’d like to change the PIN for.
  • pin – PIN the user would like to change to.
Return type:

dictionary

update_buyer(uuid, etag='', **kwargs)

Updates a buyer identified by their uuid.

Parameters:uuid – String to identify the buyer by.
Return type:dictionary
verify_pin(uuid, pin)

Checks the buyer’s PIN against what is stored in solitude.

Parameters:
  • uuid – String to identify the buyer by.
  • pin – PIN to check
Return type:

dictionary