HPP Reference

The HPP (Hosted Payment Page) generates JSON requests and receives the information from the selected transaction. Later, the JavaScript library provided by AddonPayments will manage the requests and answers. For more information about HPP, please visit the HPP reference from Addon Payments developer hub.

Then we will see the steps to follow to generate JSON requests for each type of transaction.

Note

There are mandatory fields that are auto-generated by the SDK generation utilities

  • sha1hash: The SDK automatically generates a SHA-1 digital signature for each JSON requests.
  • order_id: The transaction ID can be defined by user or auto-generated by the SDK.
  • timestamp: The transaction timestamp can be defined by user or auto-generated by the SDK.

HPP

All JSON are generated with HPP class. HPP carries out the following actions:

  • Generate security hash
  • Validates inputs
  • Base64 encodes inputs
  • Serialises request object to JSON
from addonpayments.hpp.hpp import Hpp

# create request/response handler
hpp = Hpp('my_secrect')
# parse request object to json object
json_request = hpp.request_to_json(req)

Process a Payment

For more detailed information, please see the section Process a Payment into Addon Payments developer hub.

  1. Create the Payment request.
  2. Auto-generation of the fields and transformation to JSON.
from addonpayments.hpp.payment.requests import PaymentRequest
from addonpayments.hpp.hpp import Hpp

# create request to send
request = PaymentRequest(
    merchant_id='my_merchant_id',
    amount=100,
    currency='EUR',
    auto_settle_flag=True
)
# create request/response handler
hpp = Hpp('my_secrect')
# parse request object to json object
json_request = hpp.request_to_json(req)

Card storage

Please see the Card storage section into Addon Payments developer hub.

Create a payer and store card

For more detailed information, please see the section Create a payer and store card (Card storage) into Addon Payments developer hub.

  1. Create the Card storage request:
    • if payer reference (payer_ref) and payment reference (pmt_ref) are empty, these references are internally generates by AddonPayments.
  2. Auto-generation of the fields and transformation to JSON.
from addonpayments.hpp.card_storage.requests import CardStorageRequest
from addonpayments.hpp.hpp import Hpp

# create request to send
request = CardStorageRequest(
    merchant_id='my_merchant_id',
    amount=100,
    currency='EUR',
    auto_settle_flag=True,
    card_storage_enable=True,
    offer_save_card=True,
    payer_exists=False,
    payer_ref='payer_ref',
    pmt_ref='pmt_ref'
)
# create request/response handler
hpp = Hpp('my_secrect')
# parse request object to json object
json_request = hpp.request_to_json(req)

Display stored cards to the customer

For more detailed information, please see the section Display stored cards to the customer (Card storage) into Addon Payments developer hub.

  1. Create the Display stored cards request.
  2. Auto-generation of the fields and transformation to JSON.
from addonpayments.hpp.card_storage.requests import DisplayCardsRequest
from addonpayments.hpp.hpp import Hpp

# create request to send
request = DisplayCardsRequest(
    merchant_id='my_merchant_id',
    amount=100,
    currency='EUR',
    auto_settle_flag=True,
    hpp_select_stored_card='payer_ref',
    payer_exists=True,
    offer_save_card=True,
)
# create request/response handler
hpp = Hpp('my_secrect')
# parse request object to json object
json_request = hpp.request_to_json(req)

Recurring

For more detailed information, please see the section Recurring (Card storage) into Addon Payments developer hub.

  1. Create the Recurring request.
  2. Auto-generation of the fields and transformation to JSON.
from addonpayments.hpp.card_storage.requests import RecurringPaymentRequest
from addonpayments.hpp.hpp import Hpp

# create request to send
request = RecurringPaymentRequest(
    merchant_id='my_merchant_id',
    amount=100,
    currency='EUR',
    auto_settle_flag=True,
    card_storage_enable=True,
    offer_save_card=True,
    payer_exists=True,
    payer_ref='payer_ref',
    pmt_ref='pmt_ref'
)
# create request/response handler
hpp = Hpp('my_secrect')
# parse request object to json object
json_request = hpp.request_to_json(req)