Пример #1
0
 function bill_checkout($amount, $invoice, $currency_iso, $acct_fields, $total_recurring = false, $recurr_bill_arr = false)
 {
     # Validate currency
     if (!$this->validate_currency($currency_iso)) {
         return false;
     }
     $ret = false;
     if (!$this->validate_card_details($ret)) {
         return false;
     }
     # Get the country
     $country = $this->getCountry('name', $this->account["country_id"]);
     # Test Transaction
     if ($this->cfg['mode'] = "0") {
         $host = 'test-payflow.verisign.com';
     } else {
         $host = 'payflow.verisign.com';
     }
     # Set the post vars:
     $vars = array('TENDER' => "C", 'TRXTYPE' => $this->cfg['type'], 'USER' => $this->cfg['user'], 'PWD' => $this->cfg['password'], 'PARTNER' => $this->cfg['partner'], 'AMT' => $amount, 'ACCT' => $this->billing["cc_no"], 'EXPDATE' => $this->billing["exp_month"] . '' . $this->billing["exp_year"], 'CCV2' => $this->billing["ccv"], 'STREET' => preg_replace("/'/", "", $this->account["address1"] . ' ' . $this->account["address2"]), 'CITY' => $this->account["city"], 'STATE' => $this->account["state"], 'ZIP' => $this->account["zip"], 'INVNUM' => $invoice, 'COMMENT1' => "AB Invoice # {$invoice} for {$this->account["first_name"]} {$this->account["last_name"]}", 'FIRSTNAME' => $this->account["first_name"], 'LASTNAME' => $this->account["last_name"], 'NAME' => $this->account["first_name"] . ' ' . $this->account["last_name"], 'EMAIL' => $acct_fields["email"]);
     # Create the SSL connection & get response from the gateway:
     pfpro_init();
     $response = pfpro_process($vars, $host);
     pfpro_cleanup();
     # Transaction Status:
     if ($response['RESULT'] == '0') {
         $ret['status'] = 1;
     } else {
         $ret['status'] = 0;
     }
     # Transaction ID:
     @($ret['transaction_id'] = $response['PNREF']);
     @($ret['authorization_id'] = $response['AUTHCODE']);
     # Message:
     $ret['msg'] = $response['RESPMSG'];
     # AVS Details:
     $ret['avs'] = 'avs_na';
     if ($ret['status'] == 1) {
         return $ret;
     } else {
         global $VAR;
         @($VAR['msg'] = $ret["msg"]);
         return false;
     }
 }
Пример #2
0
 public function process()
 {
     if ($this->servermode == A_CART_PAYMENT_PFPRO_SERVER_NONE) {
         $this->response['RESULT'] = 0;
         $this->response['RESPMSG'] = 'Did not connect to credit card processor (A_CART_PAYMENT_PFPRO_SERVER_NONE). ';
     } else {
         $this->response = pfpro_process($this->transaction, $this->server);
     }
     return $this->response;
 }
Пример #3
0
 function submit()
 {
     static $parameter_map = array('ACCT' => 'card_number', 'AMT' => 'amount', 'AUTHCODE' => 'auth_code', 'CITY' => 'city', 'COMMENT1' => 'description', 'COMMENT2' => 'invoice_number', 'COMPANYNAME' => 'company', 'COUNTRY' => 'country', 'EMAIL' => 'email', 'EXPDATE' => 'expiration', 'FIRSTNAME' => 'first_name', 'LASTNAME' => 'last_name', 'NAME' => 'name', 'PARTNER' => 'partner', 'PONUM' => 'po_number', 'DESC' => 'description', 'DESC1' => 'description1', 'DESC2' => 'description2', 'DESC3' => 'description3', 'DESC4' => 'description4', 'PWD' => 'password', 'STATE' => 'state', 'STREET' => 'address', 'USER' => 'login', 'VENDOR' => 'login', 'ZIP' => 'zip', 'MICR' => 'micr', 'CHKNUM' => 'check_number');
     static $required_fields = array('AMT', 'USER', 'VENDOR', 'PARTNER', 'PWD', 'TRXTYPE', 'TENDER', 'ACCT', 'EXPDATE');
     /// \todo implement:
     static $required_fields_cc = array('ACCT', 'EXPDATE');
     static $required_fields_echeck = array('CHKNUM', 'MICR', 'NAME', 'DL', 'CITY', 'EMAIL', 'STATE', 'STREET', 'ZIP');
     static $required_fields_ach = array('ABA', 'ACCT', 'ACCTTYPE', 'NAME');
     $fields = $this->_fields;
     //fbDebug::dump($fields, 	'$fields');
     if ($this->_test_mode) {
         if ($this->_test_card_type) {
             switch ($this->_test_card_type) {
                 case FB_PAYMENT_CREDIT_CARD_TYPE_VISA:
                     switch ($this->_test_response_type) {
                         case FB_PAYMENT_RESPONSE_TYPE_APPROVED:
                             $fields['card_number'] = '4111111111111111';
                             break;
                         default:
                             $fields['card_number'] = '4242424242424242';
                             // always declines
                             break;
                     }
                     break;
                 case FB_PAYMENT_CREDIT_CARD_TYPE_MASTERCARD:
                     $fields['card_number'] = '5105105105105100';
                     //$fields['card_number'] = '5555555555551111'; // Invalid account number
                     break;
                 case FB_PAYMENT_CREDIT_CARD_TYPE_AMERICAN_EXPRESS:
                     $fields['card_number'] = '378282246310005';
                     break;
                 case FB_PAYMENT_CREDIT_CARD_TYPE_DISCOVER:
                     $fields['card_number'] = '6011111111111117';
                     break;
                 default:
                     trigger_error(sprintf("Invalid card type: '%s'", $this->_test_card_type));
                     return false;
             }
         }
         if (!isset($fields['expiration']) || !$fields['expiration']) {
             $fields['expiration'] = strftime('%m%y', time());
         }
         if ($this->_test_response_type) {
             switch ($this->_test_response_type) {
                 case FB_PAYMENT_RESPONSE_TYPE_APPROVED:
                     $fields['amount'] = 1.0;
                     break;
                 case FB_PAYMENT_RESPONSE_TYPE_DECLINED:
                     $fields['amount'] = 1000.01;
                     break;
                 case FB_PAYMENT_RESPONSE_TYPE_REFERRAL:
                     $fields['amount'] = 100.01;
                     break;
                 case FB_PAYMENT_RESPONSE_TYPE_BAD_EXPIRATION:
                     $fields['expiration'] = '9999';
                     break;
                 default:
                     trigger_error(sprintf("Invalid response type: '%s'", $this->_test_response_type));
                     return false;
             }
         }
         if ($this->_test_transaction_type && (!isset($this->_fields['action']) || !$this->_fields['action'])) {
             $this->_fields['action'] = $this->_test_transaction_type;
         }
     }
     // if ($this->_test_mode)
     if (isset($fields['expiration']) && is_int($fields['expiration'])) {
         // assume numeric expiration's are a UNIX timestamp
         // convert UNIX timestamp to MMYY
         $fields['expiration'] = strftime('%m%y', $fields['expiration']);
     }
     $parameter_flipped = array_flip($parameter_map);
     $parameters = array();
     $fields = $fields;
     foreach ($fields as $key => $value) {
         if (array_key_exists($key, $parameter_flipped)) {
             $key = $parameter_flipped[$key];
         }
         $parameters[$key] = $value;
     }
     foreach ($parameter_map as $key => $value) {
         if (array_key_exists($value, $fields)) {
             $parameters[$key] = $fields[$value];
         }
     }
     if (isset($fields['type']) && $fields['type']) {
         switch ($fields['type']) {
             case FB_PAYMENT_METHOD_TYPE_CREDIT_CARD:
                 $parameters['TENDER'] = 'C';
                 break;
             case FB_PAYMENT_METHOD_TYPE_ELECTRONIC_CHECK:
                 $parameters['TENDER'] = 'K';
                 break;
             case FB_PAYMENT_METHOD_TYPE_ACH_TRANSACTION:
                 $parameters['TENDER'] = 'A';
                 break;
             default:
                 trigger_error(sprintf("Unknown payment method type: '%s'", $fields['type']));
                 return false;
         }
     }
     if (isset($fields['action']) && $fields['action']) {
         switch ($fields['action']) {
             case FB_PAYMENT_TRANSACTION_TYPE_SALE:
                 $parameters['TRXTYPE'] = 'S';
                 break;
             case FB_PAYMENT_TRANSACTION_TYPE_AUTHORIZATION:
                 $parameters['TRXTYPE'] = 'A';
                 break;
             case FB_PAYMENT_TRANSACTION_TYPE_CREDIT:
                 $parameters['TRXTYPE'] = 'C';
                 break;
             case FB_PAYMENT_TRANSACTION_TYPE_POST_AUTHORIZATION:
                 $parameters['TRXTYPE'] = 'D';
                 // Delayed Capture
                 break;
             case FB_PAYMENT_TRANSACTION_TYPE_POST_VOID:
                 $parameters['TRXTYPE'] = 'V';
                 break;
             case FB_PAYMENT_TRANSACTION_TYPE_INQUIRY:
                 $parameters['TRXTYPE'] = 'I';
                 break;
             default:
                 trigger_error(sprintf("Unknown payment method type: '%s'", $fields['type']));
                 return false;
         }
     }
     unset($parameters['type']);
     unset($parameters['action']);
     if (!isset($parameters['PARTNER']) || !$parameters['PARTNER']) {
         $parameters['PARTNER'] = 'Verisign';
     }
     if (!isset($parameters['TRXTYPE']) || !$parameters['TRXTYPE']) {
         $parameters['TRXTYPE'] = 'S';
         // Sale
     }
     if (!isset($parameters['TENDER']) || !$parameters['TENDER']) {
         $parameters['TENDER'] = 'C';
         // Credit card
     }
     // check for all required fields
     $errors = '';
     foreach ($required_fields as $required_field) {
         if (!isset($parameters[$required_field]) || !$parameters[$required_field]) {
             $errors .= sprintf("Required field '%s' ('%s') not found in field list.\n", $parameter_map[$required_field], $required_field);
         }
     }
     if ($errors) {
         //fbDebug::dump($fields, 	'$fields');
         //fbDebug::dump($parameters, '$parameters');
         trigger_error($errors);
         return false;
     }
     $parameters['AMT'] = sprintf("%.2f", floatval($parameters['AMT']));
     //fbDebug::dump($parameters, '$parameters');
     if ($this->proxy_password and strlen($this->proxy_password)) {
         $response = pfpro_process($parameters, $this->_server, $this->_port, $this->timeout, $this->proxy, $this->proxy_port, $this->proxy_user, $this->proxy_password);
     } elseif ($this->proxy_user and strlen($this->proxy_user)) {
         $response = pfpro_process($parameters, $this->_server, $this->_port, $this->timeout, $this->proxy, $this->proxy_port, $this->proxy_user);
     } elseif ($this->proxy_port and strlen($this->proxy_port)) {
         $response = pfpro_process($parameters, $this->_server, $this->_port, $this->timeout, $this->proxy, $this->proxy_port);
     } elseif ($this->proxy and strlen($this->proxy)) {
         $response = pfpro_process($parameters, $this->_server, $this->_port, $this->timeout, $this->proxy);
     } elseif ($this->timeout and strlen($this->timeout)) {
         $response = pfpro_process($parameters, $this->_server, $this->_port, $this->timeout);
     } elseif ($this->_port and strlen($this->_port)) {
         $response = pfpro_process($parameters, $this->_server, $this->_port);
     } elseif ($this->_server and strlen($this->_server)) {
         $response = pfpro_process($parameters, $this->_server);
     } else {
         $response = pfpro_process($parameters);
     }
     //fbDebug::dump($response, 	'$response');
     $this->_response = $response;
     if (!$response) {
         trigger_error('No response received from credit card payment processor!', E_USER_WARNING);
         return false;
     }
     if (!is_array($response)) {
         trigger_error(sprintf('Invalid response received from credit card payment processor: \'%s\'', $response), E_USER_WARNING);
         return false;
     }
     $this->_transaction_id = isset($response['PNREF']) ? $response['PNREF'] : '';
     $this->_result_code = isset($response['RESULT']) ? intval($response['RESULT']) : FB_PAYMENT_AUTHORIZE_NET_NO_RESULT;
     $this->_approved = $this->_result_code == 0;
     $this->_declined = $this->_result_code == 12;
     // 'Declined. Check the credit card number and transaction information to make sure they were entered correctly. If this does not resolve the problem, have the customer call the credit card issuer to resolve.',
     if (isset($response['RESPMSG'])) {
         $this->_result_message = $response['RESPMSG'];
     } else {
         $result_messages = $this->result_messages();
         $this->_result_message = isset($result_messages[$this->_result_code]) ? $result_messages[$this->_result_code] : sprintf('Unknown error %d', $this->_result_code);
     }
     $this->_authorization = isset($response['AUTHCODE']) ? $response['AUTHCODE'] : '';
     $this->_avs_address = isset($response['AVSADDR']) ? $response['AVSADDR'] : '';
     $this->_avs_zip = isset($response['AVSZIP']) ? $response['AVSZIP'] : '';
     return true;
 }
Пример #4
0
<?php

if (!extension_loaded('pfpro')) {
    die("pfpro module is not compiled in PHP\n");
}
echo "<pre>\n\n";
echo "Payflow Pro library is version " . pfpro_version() . "\n";
pfpro_init();
$transaction = array(USER => 'mylogin', PWD => 'mypassword', TRXTYPE => 'S', TENDER => 'C', AMT => 1.5, ACCT => '4111111111111111', EXPDATE => '0900');
$response = pfpro_process($transaction);
if (!$response) {
    die("Couldn't establish link to signio software.\n");
}
echo "Signio response code was " . $response[RESULT];
echo ", which means: " . $response[RESPMSG] . "\n";
echo "\nDump of the transaction request ";
print_r($transaction);
echo "\nDump of the response ";
print_r($response);
pfpro_cleanup();