NAME
Business::CPI::Gateway::Base - Father of all gateways
VERSION
version 0.922
ATTRIBUTES
driver_name
The name of the driver for this gateway. This is built automatically, but can be customized.
Example: for Business::CPI::Gateway::TestGateway
, the driver name will be TestGateway
.
log
Provide a logger to the gateway. It's the user's responsibility to configure the logger. By default, nothing is logged. You could set this to a Log::Log4perl object, for instance, to get full logging.
item_class
The class for the items (products) being purchased. Defaults to Business::CPI::${driver_name}::Item if it exists, or Business::CPI::Base::Item otherwise.
cart_class
The class for the shopping cart (the complete order). Defaults to Business::CPI::${driver_name}::Cart if it exists, or Business::CPI::Base::Cart otherwise.
buyer_class
The class for the buyer (the sender). Defaults to Business::CPI::${driver_name}::Buyer if it exists, or Business::CPI::Base::Buyer otherwise.
account_class
The class for the accounts. Defaults to Business::CPI::${driver_name}::Account if it exists, or Business::CPI::Base::Account otherwise.
account_address_class
The class for the addresses for the accounts. Defaults to Business::CPI::${driver_name}::Account::Address if it exists, or Business::CPI::Base::Account::Address otherwise.
account_business_class
The class for the business information of accounts. Defaults to Business::CPI::${driver_name}::Account::Business if it exists, or Business::CPI::Base::Account::Business otherwise.
receiver_id
ID, login or e-mail of the business owner. The way the gateway uniquely identifies the account owner.
currency
Currency code, such as BRL, EUR, USD, etc.
notification_url
The url for the gateway to postback, notifying payment changes.
return_url
The url for the customer to return to, after they finished the payment.
checkout_with_token
Boolean attribute to determine whether the form will hold the entire cart, or it will use the payment token generated for it. Defaults to false.
checkout_url
The url the application will post the form to. Defined by the gateway.
user_agent
User agent object (using LWP::UserAgent's API) to make requests to the gateway.
error
Whenever an exception is thrown, this attribute will also hold the exception object. This is because $@ may be overwritten before the exception is handled.
So one can use:
try {
# do something that will trigger an exception
$cpi->get_cart('something that doesnt exist');
}
catch {
if ($cpi->error->type eq 'resource_not_found') {
warn "Oops, it doesn't exist.";
}
# $cpi->error is the same as $_ and $_[0], unless someone messed up
# with $@, e.g., using $SIG{__DIE__} or something nasty like that. In
# that case, $_ is lost, but $cpi->error is safe.
}
most_recent_request
Whenever a request is made to the gateway, this attribute will hold the HTTP::Response object returned by the request.
Note: this is meant to be used for custom logging in the application. Usually, it's better to keep all the request-related details handled by Business::CPI, and abstract all the low-level details to the user. That includes logging, for the most part. The object returned by each method implemented by Business::CPI should be enough in most cases.
If you find yourself having to use this attribute too much, it probably means that gateway's Business::CPI driver is not doing what it should.
METHODS
new_cart
Creates a new Business::CPI::Role::Cart connected to this gateway.
new_account
Creates a new instance of an account. In general, you shouldn't need to use this, except for testing. Use create_account
, instead, if your driver provides it.
get_checkout_code
Generates a payment token for a given cart. Do not call this method directly. Instead, see "get_checkout_code" in Business::CPI::Role::Cart.
get_notification_details
Get the payment notification (such as PayPal's IPN), and return a hashref with the details.
query_transactions
Search past transactions.
get_transaction_details
Get more details about a given transaction.
notify
This is supposed to be called when the gateway sends a notification about a payment status change to the application. Receives the request as a parameter (in a CGI-compatible format), and returns data about the payment. The format is still under discussion, and is soon to be documented.
map_object
Helper method for get_hidden_inputs to translate between Business::CPI and the gateway, using methods like checkout_form_items_map, checkout_form_buyer_map, etc.
AUTHOR
André Walker <andre@andrewalker.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by André Walker.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.