コード例 #1
0
ファイル: Payments.php プロジェクト: jkinner/ringside
 public static function getGateway()
 {
     return Api_Dao_Payments::getGateway();
 }
コード例 #2
0
ファイル: Subscriptions.php プロジェクト: jkinner/ringside
 /**
  * FIXME NID and AID are never used, but are in the parameter list
  *
  * @param unknown_type $uid
  * @param unknown_type $nid
  * @param unknown_type $aid
  * @param unknown_type $planid
  * @param unknown_type $ccn
  * @param unknown_type $cctype
  * @param unknown_type $expdate
  * @param unknown_type $firstname
  * @param unknown_type $lastname
  * @param unknown_type $email
  * @param unknown_type $phone
  * @return unknown
  */
 private static function subscribeViaGateway($uid, $nid, $aid, $planid, $ccn, $cctype, $expdate, $firstname = null, $lastname = null, $email = null, $phone = null)
 {
     $response = array();
     $result = Api_Dao_Payments::getGateway();
     $response['gateway'] = $result;
     //        error_log( 'response: ' . print_r( $response, true ) );
     $options = array('action' => 'subscribe');
     $type = $response['gateway'][0]['type'];
     $processor = Payment_Process::factory($type, $options);
     if (!PEAR::isError($processor)) {
         $processor->login = $response['gateway'][0]['subject'];
         $processor->password = $response['gateway'][0]['password'];
         $processor->amount = self::calculateAmount($planid);
         $card = Payment_Process_Type::factory('CreditCard');
         $card->type = $cctype;
         if (!isset($firstname) || !isset($lastname)) {
             throw new Exception('First name or last name is not set; can not process payment.');
         }
         $card->firstName = $firstname;
         $card->lastName = $lastname;
         $card->cardNumber = $ccn;
         $card->expDate = $expdate;
         $processor->setPayment($card);
         $processor->refId = 'refid-' . time();
         $processor->subscriptionName = 'sub-' . time();
         $processor->intervalLength = 1;
         $processor->intervalUnit = 'months';
         $dateArray = getdate();
         $dateStr = date('Y-m-d', $dateArray[0]);
         $processor->startDate = $dateStr;
         $processor->totalOccurrences = '9999';
         mt_srand(time());
         $rand = mt_rand();
         $processor->invoiceNumber = $uid . '-' . $rand;
         if (isset($email)) {
             $processor->email = $email;
         }
         if (isset($phone)) {
             $processor->phoneNumber = $phone;
         }
         $result = $processor->process();
         if (PEAR::isError($result)) {
             throw new OpenFBAPIException($result->getMessage());
         }
         return $result;
     }
 }