verifone package¶
Submodules¶
verifone.verifone module¶
Main module.
-
class
verifone.verifone.
Verifone
(agreement_code, RSA_private_key, RSA_verifone_public_key, software_name, version, currency='EUR', interface_version='5', test_mode=0, return_error_dict=0)[source]¶ Bases:
object
Class for Verifone payment API.
- Following packages need to be installed:
- pycryptodome
- pycountry
- requests
Parameters: - agreement_code – merchant agreement code, string with length of 1-36 characters
- RSA_private_key – RSA private key, string
- RSA_verifone_public_key – Verifone’s RSA public key, string
- currency – currency code with three letters, default is EUR, string
- software_name – name of the web shop software, string with length of 1-30 characters
- version – version of the web shop software, string with length of 1-10 characters
- interface_version – version of the payment interface, string with length of 1-11 numeric characters
- test_mode – 1 if use test server, default is 0, boolean
- return_error_dict – if 1 then returns data received from Verifone also when error occurs. If value is 0, then raise an error. Default is 0, boolean
Return type: object
-
build_product_data
(data)[source]¶ Method build and returns product data.
Parameters: data – product items, dictionary - name: name of the basket item, max length is 30 character - pieces: number of units in the item, integer or float - discount: item discount percentage tax with two decimal, float or integer - vat: tax percentage with two decimal, float or integer - amount_gross: item gross amount including tax and discount with two decimal, float or integer - amount_net: item net amount calculated from unit cost times unit count with two decimal, float or integer - unit_cost_gross: unit cost with two decimal, with discount and tax, this must be filled if
unit cost is not filled, otherwise must not be used (optional)- unit_cost: unit cost with two decimal and without tax and discounts, this must be filled if
- unit gross cost is not filled, otherwise must not be used (optional)
Returns: product data, dictionary
-
cancel_payment
(data)[source]¶ Method cancels the payment
Parameters: data – data for cancelling, dictionary - s-f-1-30_payment-method-code: the used payment method code, string - l-f-1-20_transaction-number: transaction number identifying the payment transaction, string - s-t-1-1024_dynamic-feedback: list of parameters to be added to response if available (optional) Returns: status for cancelling, dictionary
-
check_currency
(currency)[source]¶ Method checks that currency is a valid currency code. If not then default currency code is used.
Parameters: currency – new currency code, with three letters Returns: currency code, with three letters
-
check_product_names
(data)[source]¶ Method checks that product name can not be more than 30 character. If it is longer, take only first 30 character.
Parameters: data – data sent to Verifone, dictionary Returns:
-
currency
¶ Method returns currency code.
Returns: currency, numeric ISO 4217 currency code
-
endpoint
¶ Return endpoint.
Returns: endpoint, string
-
endpoint2
¶ Return endpoint (node2). Verifone has 2 production environment URLs so if first one does not answer, this can be used instead.
Returns: endpoint, string
-
format_to_integer
(number)[source]¶ Method formats number: 1.23 > 123.
Parameters: number – float or integer Returns: formatted, integer
-
generate_payment_data
(data)[source]¶ Method generates payment data which can be used in html form for showing payment button.
Parameters: data – data for the new payment, dictionary - order_number: order number, string - locale: locale for the customer. Supported: fi_FI, sv_SE, no_NO, dk_DK, sv_FI and en_GB. Other are redirected to en_GB - amount_gross: total amount including taxes with two decimal - amount_net: total amount without taxes, with two decimal - vat_amount: tax amount with two decimal - first_name: customer’s first name, 1-30 characters, string - last_name: customer’s last name, 1-30 characters, string - email: customer’s email, 1-100 characters, string - phone: customer’s phone number, max length is 30 character (optional) - address: line one of the delivery address, max length is 30 character (optional) - address2: line two of the delivery address, max length is 30 character (optional) - address3: line three of the delivery address, max length is 30 character (optional) - city: city of the delivery address, max length is 30 character (optional) - postal_code: postal code of the delivery address, max length is 30 character (optional) - country: country of the delivery address, with 2 letters or numeric ISO 3166 country code (optional) - style: code for the style sheet used in payment page, max length is 30 character (optional) - cancel_url: return URL if payment is cancelled, max length is 256 characters - error_url: return URL after error, max length is 256 characters - expired_url: return URL after expired situation, max length is 256 characters - rejected_url: return URL if payment is rejected, max length is 256 characters - success_url: return URL after success payment, max length is 256 characters - success_url_server: URL of the delayed success, max length is 256 characters - note: custom parameter reserved for shop system to use, max length is 36 characters (optional) - save_method: is customer’s payment method saved (optional)
0: normal payment. If customer uses credit card, ‘save payment’ button is shown on Verifone’s page. 1: payment method is saved if payment is succesful. If payment method is not given in request, only cards are shown to customer. 2: payment method is only saved, so any payment is not charged. 3: disable save payment options- customer_id: identifier for the customer (optional)
- payment_method: selected payment method (optional)
- saved_payment_method_id: ID of the saved payment method (optional)
- products: product data, there can be 1-50 basket items
- name: name of the basket item, max length is 30 character
- pieces: number of units in the item, integer or float
- discount: item discount percentage tax with two decimal, float or integer
- vat: tax percentage with two decimal, float or integer
- amount_gross: item gross amount including tax and discount with two decimal, float or integer
- amount_net: item net amount calculated from unit cost times unit count with two decimal, float or integer
- unit_cost_gross: unit cost with two decimal, with discount and tax
- unit_cost: unit cost with two decimal and without tax and discounts, this must be filled if
- unit gross cost is not filled, otherwise must not be used (optional)
- payment_timestamp: the payment start time, format is yyyy-MM-dd HH:mm:ss (optional)
- order_timestamp: the orders time from web shop point of view, format is yyyy-MM-dd HH:mm:ss (optional)
- dynamic_feedback: comma separated list of optional parameters to be added to the response if available, string (optional)
Returns: generated payment data, dictionary
-
generate_payment_link
(data)[source]¶ Method generates payment link.
Parameters: data – parameters for request, dictionary - locale-f-2-5_payment-locale: locale for the customer, string - t-f-14-19_order-expiry-timestamp: UTC time when the payment link expires in format yyyy-MM-dd HH:mm:ss, string - s-f-1-36_order-number: order number, length is 1-36 characters, string - t-f-14-19_order-timestamp: UTC time defining orders time in format yyyy-MM-dd HH:mm:ss, string - s-t-1-36_order-note: note, 1-36 characters (optional) - l-f-1-20_order-gross-amount: total amount including taxes and discount with two decimal precision (for example 100 means 1 EUR), integer - l-f-1-20_order-net-amount: amount without discount or taxes, integer - l-f-1-20_order-vat-amount: VAT amount, integer - s-t-1-30_payment-method-code: used payment method, string (optional) - s-t-1-36_payment-link-number: number of the payment link in 1-36 characters, string (optional) - s-f-1-32_payment-link-delivery-mode: delivery mode of the payment link, supported values are sms or email, string - s-f-1-30_buyer-first-name: the first name of the customer with 1-30 characters, string - s-f-1-30_buyer-last-name: the last name of the customer with 1-30 characters, string - s-t-1-30_buyer-phone-number: the phone number of the customer with 1-30 characters, string (optional) - s-f-1-100_buyer-email-address: the email of the customer with 1-100 characters, string - s-t-1-255_buyer-external-id: identifier for the customer with 1-255 characters, string (optional) - s-t-1-30_delivery-address-line-one: delivery address, string (optional) - s-t-1-30_delivery-address-line-two: delivery address, string (optional) - s-t-1-30_delivery-address-line-three: delivery address, string (optional) - s-t-1-30_delivery-address-city: city for the delivery address, string (optional) - s-t-1-30_delivery-address-postal-code: postal code for the delivery address, string (optional) - i-t-1-3_delivery-address-country-code: country code of the delivery address, string with 2 character or numeric ISO 3166 (optional) - l-t-1-20_saved-payment-method-id: ID of the saved payment method with 1-20 characters, string (optional) - i-t-1-1_deferred-payment: is payment deferred payment, integer (optional)
0: Not deferred payment 1: Deferred payment- s-t-1-160_additional-delivery-text: text included in link email or SMS with 1-160 characters, string (optional)
- s-t-1-128_sender-email: This address will be shown as sender in the link email, 1-128 characters, string (optional)
- 0-50 basket items are supported
Returns: payment link information, dictionary - s-t-1-36_payment-link-number: created payment-link-number
-
generate_signature
(data, signature_type)[source]¶ Method generates digital signature from the given values. Algorithm is RSA with SHA1 or RSA with SHA512
Parameters: - data – data for the request, dictionary
- signature_type – signature type, value can be “sha1” or “sha512, string
Returns: signature, 128 byte signature converted to upper case hexadecimal string
-
generate_token
(order_no, payment_timestamp)[source]¶ Method generates token for the payment.
Parameters: - order_no – order number, string
- payment_timestamp – payment time stamp, string
Returns: generated token, string
-
get_endpoint_url
()[source]¶ Method returns endpoint url for server to server calls. Verifone has 2 production environment so check first which one production server is available.
Returns: endpoint url, string
-
get_payment_link_status
(link_number)[source]¶ Method get payment link status.
Parameters: link_number – payment link number with 1-36 characters Returns: payment link information, dictionary - s-t-1-36_payment-link-number: payment link number - s-t-1-36_payment-link-status: payment link status (new, used, expired, canceled) - t-f-14-19_order-expiry-timestamp: expiry time - t-f-14-19_payment-timestamp: payment timestamp when link was used or canceled
-
get_payment_status
(data)[source]¶ Method gets payment status.
Parameters: data – data for status inquiry, dictionary - s-f-1-30_payment-method-code: the used payment method code, string - l-f-1-20_transaction-number: transaction number identifying the payment transaction, string Returns: status for the payment, dictionary
-
get_plaintext
(data)[source]¶ Method creates plaintext from dictionary. Algorithm is RSA with SHA1 or RSA with SHA512
Parameters: data – data for the request, dictionary Returns: plain text, string
-
get_substring
(string, length)[source]¶ Method returns substring from string if string is too length.
Parameters: - string – string which length is checked, string
- length – max length, integer
Returns: substring, string
-
is_available
()[source]¶ Method can be used to test connectivity, signatures and requesting availability status of server interface.
Returns: response from Verifone, dictionary - i-f-1-1_availability: 0 = No access to Server Interface has been granted by Verifone 1 = Express level access to Server Interface 2 = Advanced level access to Server Interface
-
list_payment_methods
()[source]¶ Method gets available payment methods and their amount limits.
Returns: available payment methods, dictionary - s-t-1-30_payment-method-code-<N>: the payment method code - l-t-1-20_payment-method-min-<N>: minimum amount for the payment method - l-t-1-20_payment-method-max-<N>: maximum amount for the payment method - s-t-1-30_payment-method-type-<N>: type of the payment method
-
list_saved_payment_methods
(data)[source]¶ Method gets saved payment methods for given buyer.
Parameters: data – data for search saved payment methods, dictionary - s-f-1-30_buyer-first-name: first name - s-f-1-30_buyer-last-name: last name - s-f-1-100_buyer-email-address: email address - s-t-1-30_buyer-phone-number: phone number (optional) - s-t-1-255_buyer-external-id: buyer’s external id (optional) - s-t-1-30_delivery-address-line-one: street, 1-30 characters (optional) - s-t-1-30_delivery-address-line-two: delivery address extension, 1-30 characters (optional) - s-t-1-30_delivery-address-line-three: delivery address extension, 1-30 characters (optional) - s-t-1-30_delivery-address-city: city, 1-30 characters (optional) - s-t-1-30_delivery-address-postal-code: postal code, 1-30 characters (optional) - i-t-1-3_delivery-address-country-code: country code with 1-3 characters, ISO 3166 (optional) - s-t-1-30_recurring-payment-subscription: subscription code for recurring payment, 1-30 characters (optional) Returns: available payment methods, dictionary - s-t-1-30_payment-method-code-<N>: the payment method code - l-t-1-20_payment-method-id-<N>: payment method id - s-t-1-30_payment-method-title-<N>: title for the payment method - s-t-1-6_card-expected-validity-<N>: card validity
-
list_transaction_numbers
(order_number)[source]¶ Method lists transaction numbers of one order.
Parameters: order_number – order number, string Returns: transaction information, dictionary - l-f-1-20_transaction-number-<N>: transaction number - s-f-1-30_payment-method-code-<N>: payment method code
-
parse_response
(content)[source]¶ Method parses response content returned from Verifone.
Parameters: content – response from Verifone, string Returns: result, result from Verifone in dictionary
-
posturl
¶ Return post url. If production mode is used, then check that endpoint is available. If not use another endpoint.
Returns: post url, string
-
posturl1
¶ Return post url (Verifone node 1).
Returns: post url, string
-
posturl2
¶ Return post url (Verifone node 2).
Returns: post url, string
-
process_payment
(data)[source]¶ Method sends payment data to Verifone.
Parameters: data – data added to payment request, dictionary - locale-f-2-5_payment-locale: locale for the customer, string - t-f-14-19_payment-timestamp: UTC timestamp defining the payment start time, format is yyyy-MM-dd HH:mm:ss, string (optional) - s-f-1-36_order-number: order number, length is 1-36 characters, string - t-f-14-19_order-timestamp: UTC time defining orders time in format yyyy-MM-dd HH:mm:ss, string (optional) - s-t-1-36_order-note: note, 1-36 characters (optional) - l-f-1-20_order-gross-amount: total amount including taxes and discount with two decimal precision (for example 100 means 1 EUR), integer - s-f-1-30_buyer-first-name: the first name of the customer with 1-30 characters, string - s-f-1-30_buyer-last-name: the last name of the customer with 1-30 characters, string - s-t-1-30_buyer-phone-number: the phone number of the customer with 1-30 characters, string (optional) - s-f-1-100_buyer-email-address: the email of the customer with 1-100 characters, string - s-t-1-255_buyer-external-id: identifier for the customer with 1-255 characters, string (optional) - s-t-1-30_delivery-address-line-one: delivery address, string (optional) - s-t-1-30_delivery-address-line-two: delivery address, string (optional) - s-t-1-30_delivery-address-line-three: delivery address, string (optional) - s-t-1-30_delivery-address-city: city for the delivery address, string (optional) - s-t-1-30_delivery-address-postal-code: postal code for the delivery address, string (optional) - i-t-1-3_delivery-address-country-code: country code of the delivery address, string with 2 character or numeric ISO 3166 (optional) - l-t-1-20_saved-payment-method-id: ID of the saved payment method with 1-20 characters, string (optional) - i-t-1-1_recurring-payment: is payment recurring payment, integer (optional)
0: Not recurring payment 1: Recurring payment- i-t-1-1_deferred-payment: is payment deferred payment, integer (optional)
- 0: Not deferred payment 1: Deferred payment
- s-f-1-30_payment-method-code: used payment method, string
- 0-50 basket items are supported
Returns: payment information returned from Verifone, dictionary
-
process_supplementary
(data)[source]¶ Method trigger process supplementary.
Parameters: data – data added request, dictionary - l-f-1-20_original-transaction-number: transaction number for which supplementary will be initiated - s-f-1-30_payment-method-code: payment method code - l-f-1-20_order-gross-amount: amount for which supplementary auth will be triggered - s-t-1-36_order-note: note (optional) Returns: information returned from Verifone, dictionary - l-t-1-20_transaction-number: transaction number - s-t-1-30_payment-method-code: payment method code - i-t-1-3_order-currency-code: currency code - l-t-1-20_order-gross-amount: gross amount including tax with two decimal
-
reactivate_payment_link
(link_number, expiry_date)[source]¶ Method reactivates payment link or changes the expiry date. Note that Verifone sends an email to the payer.
Parameters: - link_number – payment link number with 1-36 characters
- expiry_date – expiration timestamp in format yyyy-MM-dd HH:mm:ss
Returns: payment link information, dictionary - s-t-1-36_payment-link-number: payment link number
-
refund_payment
(data)[source]¶ Method refunds payment. Refund is supported for card, electronic and invoice payments.
Parameters: data – data for refunding, dictionary - l-f-1-20_refund-amount: amount to refund, integer - s-f-1-30_payment-method-code: the used payment method code, string - l-f-1-20_transaction-number: transaction number identifying the payment transaction, string - s-t-1-36_order-note: note for the payment, 1-36 characters (optional) - s-t-1-1024_dynamic-feedback: list of parameters to be added to response if available (optional) Returns: status for refunding, dictionary
-
remove_saved_payment_method
(payment_id)[source]¶ Method removes saved payment method.
Parameters: payment_id – payment method id, integer Returns: status for removing, dictionary - l-t-1-10_removed-count: 0 = Payment method not removed, 1 = Payment method removed
-
send_request
(options)[source]¶ Method sends a request to Verifone and returns response.
Parameters: options – options for the request, dictionary Returns: response from Verifone, dictionary
-
test_mode
¶ Return 1 if client is in test mode.
Returns: 1 if is in test mode, integer
Module contents¶
Top-level package for Verifone.