コード例 #1
0
ファイル: merchant.php プロジェクト: camigreen/ttop
 public function createProfile($profile)
 {
     $this->loadCreds();
     $request = new AuthorizeNetCIM();
     $profile = $request->createCustomerProfile($profile)->xml->profile->customerProfileID;
     return $profile;
 }
コード例 #2
0
ファイル: transaction.php プロジェクト: mehulsbhatt/volcano
 /**
  * Creates a new instance.
  *
  * @param $data New instance data.
  *
  * @return bool
  */
 public function create(array $data)
 {
     $customer_gateway_id = Service_Customer_Gateway::external_id($this->driver->customer, $this->driver->gateway);
     if (!$customer_gateway_id) {
         return false;
     }
     if (!($payment_method = Arr::get($data, 'payment_method'))) {
         return false;
     }
     if (!($amount = Arr::get($data, 'amount'))) {
         return false;
     }
     $request = new AuthorizeNetCIM();
     $transaction = new AuthorizeNetTransaction();
     $transaction->amount = $amount;
     $transaction->customerProfileId = $customer_gateway_id;
     $transaction->customerPaymentProfileId = $payment_method->external_id;
     // AuthOnly or AuthCapture
     $response = $request->createCustomerProfileTransaction('AuthCapture', $transaction);
     if (!$response->isOk()) {
         Log::error('Unable to create Authorize.net transaction.');
         return false;
     }
     $response = $response->getTransactionResponse();
     if (empty($response->transaction_id)) {
         return false;
     }
     return $response->transaction_id;
 }
コード例 #3
0
 /**
  * @param   array   $data   maps to properties as $key => $value
  */
 public function __construct($data = array())
 {
     parent::__construct();
     foreach ($data as $key => $value) {
         $this->{$key} = $value;
     }
 }
コード例 #4
0
ファイル: customer.php プロジェクト: mehulsbhatt/volcano
 /**
  * Creates the customer profile.
  *
  * @param array $data The data to us to create the profile.
  *
  * @return bool
  */
 public function create(array $data)
 {
     if (!($customer = Arr::get($data, 'customer'))) {
         return false;
     }
     if (!($contact = Arr::get($data, 'contact'))) {
         return false;
     }
     $request = new AuthorizeNetCIM();
     $profile = new AuthorizeNetCustomer();
     $profile->merchantCustomerId = $customer->id;
     $profile->email = $contact->email;
     $response = $request->createCustomerProfile($profile);
     if (!$response->isOk()) {
         preg_match('/A duplicate record with ID ([0-9]+) already exists./i', $response->getMessageText(), $matches);
         if (isset($matches[1])) {
             return $matches[1];
         }
         Log::error('Unable to create Authorize.net customer profile.');
         return false;
     }
     return $response->getCustomerProfileId();
 }
コード例 #5
0
 public function testGetCustomerProfileIds()
 {
   // Create new customer profile
   $request = new AuthorizeNetCIM;
   $customerProfile = new AuthorizeNetCustomer;
   $customerProfile->description = "Description of customer";
   $customerProfile->merchantCustomerId = time().rand(1,10);
   $customerProfile->email = "*****@*****.**";
   $response = $request->createCustomerProfile($customerProfile);
   $this->assertTrue($response->isOk());
   $customerProfileId = $response->getCustomerProfileId();
   
   $response = $request->getCustomerProfileIds();
   $this->assertTrue($response->isOk());
   $this->assertTrue(in_array($customerProfileId, $response->getCustomerProfileIds()));
   
   
 }
コード例 #6
0
 function deleteShip($id)
 {
     $tmpcim = new AuthorizeNetCIM();
     $response = $tmpcim->deleteCustomerShippingAddress($this->CIM_ID, $id);
     if ($response->isOk) {
         return false;
     } else {
         return $response->getErrorMessage();
     }
 }
コード例 #7
0
 $fldAmount = $db->f('fldAmount');
 $fldPaymentProfileId = $db->f('fldPaymentProfileId');
 // gets the customer profile Id
 $query = "SELECT fldFirstName,fldLastName," . "fldANetCustomerProfileId,fldEmail FROM " . TBL_COLLEGE_COACH_REGISTER . " WHERE fldId={$fldCoach}";
 $db1->query($query);
 $db1->next_record();
 $fldFirstName = $db1->f('fldFirstName');
 $fldLastName = $db1->f('fldLastName');
 $fldCustomerProfileId = $db1->f('fldANetCustomerProfileId');
 $fldEmail = $db1->f('fldEmail');
 // attempts to charge the user for the subscription
 $transaction = new AuthorizeNetTransaction();
 $transaction->amount = $fldAmount;
 $transaction->customerProfileId = $fldCustomerProfileId;
 $transaction->customerPaymentProfileId = $fldPaymentProfileId;
 $request = new AuthorizeNetCIM();
 $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction);
 // if the transaction fails, cancel the subscription
 if (ANet_Response_getResultCode($response) == 'Error') {
     $data = array('fldActive' => 0, 'fldCancelDate' => $today, 'fldCancelReasonOther' => 'Automatic renewal failed (' . ANet_Response_getMessageCode($response) . ': ' . ANet_Response_getMessageText($response) . ')');
     $db1->updateRec(TBL_COLLEGE_SUBSCRIPTION, $data, 'fldId=' . $fldId);
     // gets the active number of subscriptions for the current coach
     $query = "SELECT COUNT(*) AS subsCount FROM " . TBL_COLLEGE_SUBSCRIPTION . " WHERE fldActive=1 AND fldCoach=" . $fldCoach;
     $db1->query($query);
     $db1->next_record();
     $subsCount = $db1->f('subsCount');
     // increments the coach's cancel count by 1. If the
     // coach has no subscriptions now that this subscription
     // is canceled, set fldSubscribe to 0
     $query = "SELECT fldCancelCount FROM " . TBL_COLLEGE_COACH_REGISTER . " WHERE fldId=" . $fldCoach;
     $db1->query($query);
コード例 #8
0
ファイル: anet.class.php プロジェクト: badtux/pmg
 public static function doTransaction($type, $transactionData = array())
 {
     $request = new AuthorizeNetCIM();
     $requestAim = new AuthorizeNetAIM();
     Log::write(__METHOD__ . ' sandbox ' . (int) SANDBOX_MODE);
     $request->setSandbox(SANDBOX_MODE);
     $transaction = new AuthorizeNetTransaction();
     $libAnetResponse = new Lib_Anet_Response();
     switch ($type) {
         case self::$TRANS_AUTHONLY:
             $amount = $customer_profile_id = $payment_profile_id = $invoice_id = null;
             extract($transactionData, EXTR_OVERWRITE);
             Log::write(__METHOD__ . ' cp :' . $customer_profile_id . ' pp :' . $payment_profile_id . ' inv :' . $invoice_id . ' amt :' . $amount);
             $cps = Lib_Anet::getCardProfiles($customer_profile_id);
             $transaction->amount = $amount;
             $transaction->customerProfileId = $customer_profile_id;
             $transaction->customerPaymentProfileId = $payment_profile_id;
             $transaction->order->invoiceNumber = $invoice_id;
             $response = $request->createCustomerProfileTransaction(self::$TRANS_AUTHONLY, $transaction);
             //	$request->createCustomerProfileTransaction($transactionType, $transaction);
             if ($response->isOk()) {
                 Log::write(__METHOD__ . ' ok');
                 $transactionResponse = $response->getTransactionResponse();
                 $libAnetResponse->state = true;
                 $libAnetResponse->transaction_id = $transactionResponse->transaction_id;
                 $libAnetResponse->authorization_code = $transactionResponse->authorization_code;
                 $libAnetResponse->message = $transactionResponse->response_reason_text;
                 $libAnetResponse->text = $response->getMessageText();
                 $libAnetResponse->code = $response->getMessageCode();
                 $libAnetResponse->last_digit = trim(str_replace('X', '', $transactionResponse->account_number));
             }
             if ($response->isError()) {
                 Log::write(__METHOD__ . ' err');
                 $libAnetResponse->state = false;
                 $libAnetResponse->text = $response->getMessageText();
                 $libAnetResponse->code = $response->getMessageCode();
             }
             Log::write(__METHOD__ . ' ' . $response->getMessageCode() . ' ' . $response->getMessageText());
             Log::write(__METHOD__ . ' ' . json_encode($libAnetResponse));
             if ($libAnetResponse->text == 'A duplicate transaction has been submitted.') {
                 $libAnetResponse->text = 'Try again in 2 minutes';
             }
             return $libAnetResponse;
             break;
         case self::$TRANS_PRIORAUTHCAPTURE:
             $transaction_id = $amount = null;
             extract($transactionData, EXTR_OVERWRITE);
             $transaction->transId = $transaction_id;
             $transaction->amount = $amount;
             $response = $request->createCustomerProfileTransaction(self::$TRANS_PRIORAUTHCAPTURE, $transaction);
             if ($response->isOk()) {
                 $transactionResponse = $response->getTransactionResponse();
                 $libAnetResponse->state = true;
                 $libAnetResponse->transaction_id = $transactionResponse->transaction_id;
                 $libAnetResponse->authorization_code = $transactionResponse->authorization_code;
                 $libAnetResponse->message = $transactionResponse->response_reason_text;
                 $libAnetResponse->text = $response->getMessageText();
                 $libAnetResponse->code = $response->getMessageCode();
             }
             if ($response->isError()) {
                 $libAnetResponse->state = false;
                 /*$returnResponse->message = $transactionResponse->response_reason_text;*/
                 $libAnetResponse->text = $response->getMessageText();
                 $libAnetResponse->code = $response->getMessageCode();
             }
             return $libAnetResponse;
             break;
         case self::$TRANS_AUTHCAPTURE:
             $amount = $customer_profile_id = $payment_profile_id = null;
             extract($transactionData, EXTR_OVERWRITE);
             $transaction->amount = $amount;
             $transaction->customerProfileId = $customer_profile_id;
             $transaction->customerPaymentProfileId = $payment_profile_id;
             $response = $request->createCustomerProfileTransaction(self::$TRANS_AUTHCAPTURE, $transaction);
             if ($response->isOk()) {
                 $transactionResponse = $response->getTransactionResponse();
                 $libAnetResponse->state = true;
                 $libAnetResponse->transaction_id = $transactionResponse->transaction_id;
                 $libAnetResponse->authorization_code = $transactionResponse->authorization_code;
                 $libAnetResponse->message = $transactionResponse->response_reason_text;
                 $libAnetResponse->text = $response->getMessageText();
                 $libAnetResponse->code = $response->getMessageCode();
                 $libAnetResponse->last_digit = trim(str_replace('X', '', $transactionResponse->account_number));
             }
             if ($response->isError()) {
                 $libAnetResponse->state = false;
                 $libAnetResponse->text = $response->getMessageText();
                 $libAnetResponse->code = $response->getMessageCode();
             }
             return $libAnetResponse;
             break;
         case self::$TRANS_CREDIT:
             $amount = $customerProfileId = $paymentProfileId = null;
             $transaction->amount = $transactionData->amount;
             $requestAim->setSandbox(SANDBOX_MODE);
             $response = $requestAim->credit($transactionData->id, $transactionData->amount, $transactionData->lfor);
             return true;
             if (!$response->error) {
                 return true;
             } else {
                 throw new Exception($response->response_reason_text, 512);
             }
             break;
         case self::$TRANS_VOID:
             $amount = $customer_profile_id = $payment_profile_id = $invoice_id = null;
             extract($transactionData, EXTR_OVERWRITE);
             $transaction->amount = $amount;
             $transaction->customerProfileId = $customer_profile_id;
             $transaction->customerPaymentProfileId = $payment_profile_id;
             $transaction->order->invoiceNumber = $invoice_id;
             $response = $request->createCustomerProfileTransaction(self::$TRANS_AUTHONLY, $transaction);
             break;
     }
 }
コード例 #9
0
    $response = $request->createCustomerProfile($customerProfile);
    if (ANet_Response_getResultCode($response) == 'Error') {
        $e = ANet_Response_getMessageCode($response) . ': ' . ANet_Response_getMessageText($response);
        throw new Exception($e);
    }
    // gets the customer profile ID and payment profile ID from the response
    $customerProfileId = $response->getCustomerProfileId();
    $paymentProfileId = $response->getCustomerPaymentProfileIds();
    // updates the database with the new Authorize.net customer profile ID
    $tbl = TBL_COLLEGE_COACH_REGISTER;
    $data = array('fldANetCustomerProfileId' => $customerProfileId);
    $where = 'fldId=' . $fldId;
    $affectedRows = $db1->updateRec($tbl, $data, $where);
} else {
    // gets all existing payment profiles associated with the customer profile
    $request = new AuthorizeNetCIM();
    $response = $request->getCustomerProfile($customerProfileId);
    if (ANet_Response_getResultCode($response) == 'Error') {
        $e = ANet_Response_getMessageCode($response) . ': ' . ANet_Response_getMessageText($response);
        throw new Exception($e);
    }
    $paymentProfiles = $response->xml->profile->paymentProfiles;
    // gets the last four digits of the provided card number
    $subLastFour = substr($subCardnumber, -4);
    // compares the last four digits of the provided card number against all
    // card numbers associated with the customer profile. If match is found,
    // the matched payment profile is used for the transaction
    $isMatch = false;
    foreach ($paymentProfiles as $paymentProfile) {
        $profileCard = (string) $paymentProfile->payment->creditCard->cardNumber;
        if ($subLastFour == substr($profileCard, -4)) {
コード例 #10
0
 public function testGetCustomerProfileIds()
 {
     // A valid response should be received when a merchant has zero customer profiles...
     // Hence, first testing using specific credentials for a merchant which has zero customer profiles...
     $request = new AuthorizeNetCIM('5KP3u95bQpv', '4Ktq966gC55GAX7S');
     $response = $request->getCustomerProfileIds();
     // Create new customer profile
     $request = new AuthorizeNetCIM();
     $customerProfile = new AuthorizeNetCustomer();
     $customerProfile->description = "Description of customer";
     $customerProfile->merchantCustomerId = time() . rand(1, 100);
     $customerProfile->email = "*****@*****.**";
     $response = $request->createCustomerProfile($customerProfile);
     $this->assertTrue($response->isOk());
     $customerProfileId = $response->getCustomerProfileId();
     $response = $request->getCustomerProfileIds();
     $this->assertTrue($response->isOk());
     $this->assertTrue(in_array($customerProfileId, $response->getCustomerProfileIds()));
 }
コード例 #11
0
ファイル: paymentmethod.php プロジェクト: mehulsbhatt/volcano
 /**
  * Deletes a payment method.
  *
  * @return bool
  */
 public function delete()
 {
     if (!($id = $this->id())) {
         return false;
     }
     if (!($customer_gateway_id = $this->data('customer_id'))) {
         return false;
     }
     $request = new AuthorizeNetCIM();
     $response = $request->deleteCustomerPaymentProfile($customer_gateway_id, $id);
     if (!$response->isOk()) {
         Log::error('Unable to delete Authorize.net payment method.');
         return false;
     }
     return true;
 }
コード例 #12
0
ファイル: Authorize.php プロジェクト: vilmark/vilmark_main
 /**
  * Returns the instance of AuthorizeNetCIM class.
  *
  * @since     3.5
  *
  * @access    protected
  * @staticvar AuthorizeNetCIM $cim The instance of AuthorizeNetCIM class.
  * @return AuthorizeNetCIM The instance of AuthorizeNetCIM class.
  */
 protected function _get_cim()
 {
     static $cim = null;
     if (!is_null($cim)) {
         return $cim;
     }
     require_once MEMBERSHIP_ABSPATH . '/classes/Authorize.net/AuthorizeNet.php';
     // merchant information
     $login_id = $this->_get_option('api_user');
     $transaction_key = $this->_get_option('api_key');
     $mode = $this->_get_option('mode', self::MODE_SANDBOX);
     $cim = new AuthorizeNetCIM($login_id, $transaction_key);
     $cim->setSandbox($mode != self::MODE_LIVE);
     if (defined('MEMBERSHIP_AUTHORIZE_LOGFILE')) {
         $cim->setLogFile(MEMBERSHIP_AUTHORIZE_LOGFILE);
     }
     return $cim;
 }
コード例 #13
0
<?php

require_once 'anet_php_sdk/AuthorizeNet.php';
require_once 'AuthorizeNetMerchantAccount.php';
// gets the Authorize.net payment profile ID created
// for the subscription from the database
$queryString = "SELECT `%s` FROM `%s` WHERE fldId='%s'";
$query = sprintf($queryString, 'fldPaymentProfileId', TBL_COLLEGE_SUBSCRIPTION, $subId);
$db1->query($query);
$db1->next_record();
$paymentProfileId = $db1->f('fldPaymentProfileId');
// updates the payment profile with the new information
$paymentProfile = new AuthorizeNetPaymentProfile();
$paymentProfile->payment->creditCard->cardNumber = $subCardnumber;
$paymentProfile->payment->creditCard->expirationDate = $subCardExpDate;
$paymentProfile->billTo->firstName = $subFName;
$paymentProfile->billTo->lastName = $subLName;
$paymentProfile->billTo->address = $subAddress;
$paymentProfile->billTo->city = $subCity;
$paymentProfile->billTo->state = $subState;
$paymentProfile->billTo->zip = $subZip;
$request = new AuthorizeNetCIM();
$response = $request->updateCustomerPaymentProfile($customerProfileId, $paymentProfileId, $paymentProfile);
if (ANet_Response_getResultCode($response) == 'Error') {
    $e = ANet_Response_getMessageCode($response) . ': ' . ANet_Response_getMessageText($response);
    throw new Exception($e);
}