1 package Business::OnlinePayment::FirstDataGlobalGateway;
2 use base qw( Business::OnlinePayment );
7 use Business::CreditCard;
8 use SOAP::Lite +trace => 'all';
9 #SOAP::Lite->import(+trace=>'debug');
11 our $VERSION = '0.01';
12 $VERSION = eval $VERSION; # modperlstyle: convert the string into a number
14 our @alpha = ( 'a'..'z', 'A'..'Z', '0'..'9' );
18 'info_compat' => '0.01',
19 'gateway_name' => 'First Data Global Gateway e4',
20 'gateway_url' => 'https://www.firstdata.com/en_us/products/merchants/ecommerce/online-payment-processing.html',
21 'module_version' => $VERSION,
22 'supported_types' => [ 'CC' ], #, 'ECHECK' ],
23 #'token_support' => 1,
24 #'test_transaction' => 1,
26 'supported_actions' => [ 'Normal Authorization',
36 #$self->build_subs(qw( order_number avs_code cvv2_response
37 # response_page response_code response_headers
40 $self->build_subs(qw( avs_code ));
47 my %content = $self->content();
50 my %types = ( 'visa' => 'CC',
52 'american express' => 'CC',
56 $content{'type'} = $types{lc($content{'type'})} || $content{'type'};
57 $self->transaction_type($content{'type'});
60 my $action = lc($content{'action'});
62 ( 'normal authorization' => '00', # Purchase
63 'authorization_only' => '01', #
64 'post authorization' => '02', # Pre-Authorization Completion
65 # '' => '03', # Forced Post
66 'credit' => '04', # Refund
67 # '' => '05', # Pre-Authorization Only
68 'void' => '13', # Void
69 #'reverse authorization' => '',
71 # '' => '07', # PayPal Order
72 # '' => '32', # Tagged Pre-Authorization Completion
73 # '' => '33', # Tagged Void
74 # '' => '34', # Tagged Refund
75 # '' => '83', # CashOut (ValueLink, v9 or higher end point only)
76 # '' => '85', # Activation (ValueLink, v9 or higher end point only)
77 # '' => '86', # Balance Inquiry (ValueLink, v9 or higher end point only)
78 # '' => '88', # Reload (ValueLink, v9 or higher end point only)
79 # '' => '89', # Deactivation (ValueLink, v9 or higher end point only)
82 $content{'action'} = $actions{$action} || $action;
84 # stuff it back into %content
85 $self->content(%content);
92 my %content = $self->content();
94 $content{$map{$_}} = $content{$_};
96 $self->content(%content);
105 'login' => 'ExactID',
106 'password' => 'Password',
108 'action' => 'TransactionType',
110 'amount' => 'DollarAmount',
111 'currency' => 'Currency',
112 'card_number' => 'Card_Number',
113 'track1' => 'Track1',
114 'track2' => 'Track2',
115 'expiration' => 'Expiry_Date',
116 'name' => 'CardHoldersName',
117 'cvv2' => 'VerificationStr2',
119 'authorization' => 'Authorization_Num',
120 'order_number' => 'Reference_No',
123 'tax' => 'Tax1Amount',
124 'customer_id' => 'Customer_Ref',
125 'customer_ip' => 'Client_IP',
126 'email' => 'Client_Email',
128 #account_type => 'accountType',
132 my %content = $self->content();
134 #$content{'mop'} = $mop{ cardtype($content{creditCardNum}) }
135 # if $content{'type'} eq 'CC';
137 #if ( $self->test_transaction ) {
138 # $content{agentCode} = 'TEST88';
139 # $content{password} = 'TEST88';
142 $content{Expiry_Date} =~ s/\///;
144 $content{country} ||= 'US';
146 $content{VerificationStr1} =
147 join('|', map $content{$_}, qw( address zip city state country ));
148 $content{VerificationStr1} .= '|'. $content{'phone'}
149 if $content{'type'} eq 'ECHECK';
151 $content{CVD_Presence_Ind} = '1' if length($content{VerificationStr2});
153 $content{'Reference_No'} ||= join('', map $alpha[int(rand(62))], (1..20) );
155 #XXX this should be exposed as a standard B:OP field, not just recurring/no
156 if ( defined($content{'recurring_billing'})
157 && $content{'recurring_billing'} =~ /^[y1]/ ) {
158 $content{'Ecommerce_Flag'} = '2';
160 #$content{'Ecommerce_Flag'} = '1'; 7? if there's an IP?
164 if ( $self->test_transaction ) {
166 'https://api.demo.globalgatewaye4.firstdata.com/transaction';
169 'https://api.globalgatewaye4.firstdata.com/vplug-in/transaction';
172 my $proxy = "$base_uri/v11";
173 my $uri = "$base_uri/rpc-enc";
175 my %transaction = map { $_ => $content{$_} } (qw(
176 ExactID Password Transaction_Type DollarAmount Card_Number Transaction_Tag
177 Track1 Track2 Authorization_Num Expiry_Date CardHoldersName
178 VerificationStr1 VerificationStr2 CVD_Presence_Ind Reference_No ZipCode
179 Tax1Amount Tax1Number Tax2Amount Tax2Number Customer_Ref Reference_3
180 Language Client_IP Client_Email user_name Currency PartialRedemption
181 CAVV XID Ecommerce_Flag
183 #TransarmorToken CardType EAN VirtualCard CardCost FraudSuspected
184 #CheckNumber CheckType BankAccountNumber BankRoutingNumber CustomerName
185 #CustomerIDType CustomerID
187 #my @opts = map { SOAP::Data->name($_)->value( $data{$_} ) }
190 my $result = SOAP::Lite
193 ->default_ns($base_uri)
196 ->on_action( sub { join '/', @_ } )
197 #->on_action( sub { join '', @_ } )
198 #->on_action(sub { qq("$_[0]") }) #? https://firstdata.zendesk.com/entries/407569-First-Data-Global-Gateway-e4-Web-Service-API-Sample-Code-Perl
204 ->SendAndCommit( SOAP::Data->name('Transaction')->value( \%transaction ) )
210 die Dumper($result->result) if $result->fault;
211 #die $result->fault->faultstring if $result->fault;
216 #$self->authorization
218 #$self->error_message
220 ##$self->failure_status
230 Business::OnlinePayment::FirstDataGlobalGateway - First Data Global Gateway e4 backend for Business::OnlinePayment
234 use Business::OnlinePayment;
237 new Business::OnlinePayment( 'FirstDataGlobalGateway' );
240 login => 'TEST88', # ExactID
241 password => 'TEST88', #password
244 action => 'Normal Authorization',
247 first_name => 'Tofu',
248 last_name => 'Beast',
249 address => '123 Anystreet',
254 card_number => '4111111111111111',
255 expiration => '09/20',
259 customer_ip => '1.2.3.4',
263 if($tx->is_success()) {
264 print "Card processed successfully: ".$tx->authorization."\n";
266 print "Card was rejected: ".$tx->error_message."\n";
269 =head1 SUPPORTED TRANSACTION TYPES
271 =head2 CC, Visa, MasterCard, American Express, Discover
273 Content required: type, login, action, amount, card_number, expiration.
275 =head2 (NOT YET) Check
277 Content required: type, login, action, amount, name, account_number, routing_code.
281 For detailed information see L<Business::OnlinePayment>.
283 =head1 METHODS AND FUNCTIONS
285 See L<Business::OnlinePayment> for the complete list. The following methods either override the methods in L<Business::OnlinePayment> or provide additional functions.
289 Returns the response error code.
293 Returns the response error number.
297 The following actions are valid
307 Business::OnlinePayment::FirstDataGlobalGateway uses the v11 version of the API
312 Ivan Kohler <ivan-firstdataglobalgateway@freeside.biz>
316 perl(1). L<Business::OnlinePayment>.