function Step2CreateCreditCard($merchantAccountId)
{
    //    $account = get_account_by_merchantAccountId($merchantAccountId);
    //To save a soap call, you can use sparse objects.
    $account = new Account();
    $account->merchantAccountId = $merchantAccountId;
    $merchantPaymentMethodId = $merchantAccountId;
    $paymentMethod = new PaymentMethod();
    $cc = new CreditCard();
    $paymentMethod->setBillingAddress($account->shippingAddress);
    $paymentMethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    // Use Test cards only in ProdTest.  Use Real cards only in Production.
    $cc->setAccount("4112344112344113");
    $cc->setExpirationDate("201811");
    $paymentMethod->setType('CreditCard');
    $paymentMethod->setCreditCard($cc);
    // Do not check AVS, CVN.  Do not validate.
    $replaceOnAutoBills = true;
    $updateBehavior = "Update";
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $srd = '';
    $response = $account->updatePaymentMethod($srd, $paymentMethod, $replaceOnAutoBills, $updateBehavior, $ignoreAvsPolicy, $ignoreCvnPolicy);
    // Log soap id for each API call.
    //    $log->addDebug('Method = Account.updatePaymentMethod' . PHP_EOL);
    //    $log->addDebug('Soap Id = ' . $response['data']->return->soapId . PHP_EOL);
    //    $log->addDebug('Return Code = ' . $response['returnCode'] . PHP_EOL);
    //    $log->addDebug('Return String = ' . $response['returnString'] . PHP_EOL);
    if ($response['returnCode'] == 200) {
        print "Call succeeded" . PHP_EOL;
    } else {
        print "Call failed" . PHP_EOL;
    }
}
Esempio n. 2
0
 /**
  * @param CreditCard $card
  *
  * @return $this|self
  */
 public function setCardCredit(CreditCard $card) : self
 {
     if (!$card->getId()) {
         $card->generateId();
     }
     $this->getField()->addAttribute('data-creditcard-fields', $card->getId());
     return $this;
 }
Esempio n. 3
0
 function validateCreditcardHTTPInput($creditcard, $contentObjectAttribute)
 {
     if (!CreditCard::validate($creditcard)) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The Credit card number is not valid.'));
         return eZInputValidator::STATE_INVALID;
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
 public function testTypeConstraintAndFieldChoices()
 {
     $constraintChoices = CreditCard::getTypeConstraintChoices();
     $this->assertType('array', $constraintChoices);
     $fieldChoices = CreditCard::getTypeFieldChoices();
     $this->assertType('array', $fieldChoices);
     $this->assertEquals(count($constraintChoices), count($fieldChoices));
     $this->assertEquals($constraintChoices, array_keys($fieldChoices));
 }
 public function run()
 {
     Yii::app()->clientScript->registerScriptFile($this->assetUrl . '/assets/jquery.payment.js');
     Yii::app()->clientScript->registerScriptFile($this->assetUrl . '/assets/wscreditcardform.js');
     $arrEnabledCreditCardLabel = array_map(function ($creditCard) {
         return $creditCard->label;
     }, CreditCard::model()->enabled()->findAll());
     $this->render('creditcardform', array('model' => $this->model, 'form' => $this->form, 'arrEnabledCreditCardLabel' => $arrEnabledCreditCardLabel, 'strCardTypeNotSupported' => Yii::t('checkout', MultiCheckoutForm::DISABLED_CARD_TYPE)));
 }
Esempio n. 6
0
 public function startTest($method)
 {
     parent::startTest($method);
     $this->Payments =& new TestPaymentsController();
     $this->Payments->__construct();
     $this->Payments->constructClasses();
     $this->Payments->Notifier->QueueEmail = new MockPaymentsQueueEmailComponent();
     $this->Payments->Notifier->QueueEmail->enabled = true;
     $this->Payments->Notifier->QueueEmail->initialize($this->Payments);
     $this->Payments->Notifier->QueueEmail->setReturnValue('_smtp', true);
     $this->Payments->Notifier->QueueEmail->setReturnValue('_mail', true);
     $CreditCard = new CreditCard();
     $CreditCard->setGateway(new TestPaymentsControllerAuthorizeDotNetComponent());
     ClassRegistry::removeObject('CreditCard');
     ClassRegistry::addObject('CreditCard', $CreditCard);
     ClassRegistry::init('CreditCard');
     // necessary fixtures
     $this->loadFixtures('Payment', 'User', 'Roster', 'PaymentType', 'PaymentOption', 'Involvement', 'InvolvementType', 'Profile', 'Address', 'Leader');
     $this->testController = $this->Payments;
 }
Esempio n. 7
0
function createCreditCard()
{
    $creditCard = new CreditCard();
    $creditCard->setHolder("João D. F. Silva");
    $creditCard->setNumber("4111111111111111");
    $creditCard->setSecurityCode("123");
    $creditCard->setMaturityMonth("01");
    $creditCard->setMaturityYear("2016");
    return $creditCard;
}
 public function fromJson($responseData)
 {
     $paymentCompleteResponse = new PaymentCompleteResponse();
     $paymentCompleteResponse->setClientId($responseData[responseData][clientId]);
     $paymentCompleteResponse->setClientIdHash($responseData[responseData][clientIdHash]);
     $paymentCompleteResponse->setTransactionType($responseData[responseData][transactionType]);
     $creditCard = new CreditCard();
     $creditCard->setType($responseData[responseData][creditCard][type]);
     $creditCard->setHolderName($responseData[responseData][creditCard][holderName]);
     $creditCard->setNumber($responseData[responseData][creditCard][number]);
     $creditCard->setExpiry($responseData[responseData][creditCard][expiry]);
     $paymentCompleteResponse->setCreditCard($creditCard);
     $transactionAmount = new TransactionAmount();
     $transactionAmount->setTotalAmount($responseData[responseData][transactionAmount][totalAmount]);
     $transactionAmount->setPaymentAmount($responseData[responseData][transactionAmount][paymentAmount]);
     $transactionAmount->setServiceFeeAmount($responseData[responseData][transactionAmount][serviceFeeAmount]);
     $transactionAmount->setWithholdingAmount($responseData[responseData][transactionAmount][withholdingAmount]);
     $transactionAmount->setCurrency($responseData[responseData][transactionAmount][currency]);
     $paymentCompleteResponse->setTransactionAmount($transactionAmount);
     $paymentCompleteResponse->setClientRef($responseData[responseData][clientRef]);
     $paymentCompleteResponse->setComment($responseData[responseData][comment]);
     $paymentCompleteResponse->setTxnReference($responseData[responseData][txnReference]);
     $paymentCompleteResponse->setFeeReference($responseData[responseData][feeReference]);
     $paymentCompleteResponse->setResponseCode($responseData[responseData][responseCode]);
     $paymentCompleteResponse->setResponseText($responseData[responseData][responseText]);
     $paymentCompleteResponse->setSettlementDate($responseData[responseData][settlementDate]);
     $paymentCompleteResponse->setToken($responseData[responseData][token]);
     $paymentCompleteResponse->setTokenized($responseData[responseData][tokenized]);
     $paymentCompleteResponse->setTokenResponseText($responseData[responseData][tokenResponseText]);
     $paymentCompleteResponse->setAuthCode($responseData[responseData][authCode]);
     $paymentCompleteResponse->setCvcResponse($responseData[responseData][cvcResponse]);
     return $paymentCompleteResponse;
 }
 private function checkCreditCard($owner, $type, $number, $cvv, $expiry)
 {
     $is_valid = true;
     if ($is_valid) {
         $is_valid = CreditCard::number((int) $number);
     }
     if ($is_valid) {
         $is_valid = CreditCard::expiry($expiry['month'], $expiry['year']);
     }
     if ($is_valid) {
         $is_valid = CreditCard::owner($owner);
     }
     //if($is_valid) $is_valid = CreditCard::cvv($cvv,$type);
     return $is_valid;
 }
Esempio n. 10
0
 public function actionDeleteCards()
 {
     Yii::import('application.extensions.vendor.autoload', true);
     Httpful\Bootstrap::init();
     Balanced\Bootstrap::init();
     Balanced\Settings::$api_key = Yii::app()->params['balancedAPISecret'];
     if (isset($_POST['data'])) {
         $dataString = $_POST['data'];
         $data = json_decode($dataString);
         $user_ID = $this->getUser()->User_ID;
         foreach ($data as $card) {
             $cardModel = CreditCard::model()->findByPk($card);
             if ($cardModel->User_ID == $user_ID) {
                 $cardModel->Active = 0;
                 $cardModel->save();
                 $balancedCard = Balanced\Card::get($cardModel->URI);
                 $balancedCard->is_valid = false;
                 $balancedCard->save();
             }
         }
     }
 }
Esempio n. 11
0
 function doPrepaidSignup()
 {
     $data = $_POST;
     //Check for existing member email address
     if ($member = DataObject::get_one("Member", "`Email` = '" . Convert::raw2sql($data['Email']) . "'")) {
         return "inlineMsg1";
     }
     $currentYear = date('Y');
     $currentMonth = date('n');
     //Stop sign-up when the credit card is expired
     if ($data['ExpirationYear'] < $currentYear) {
         return "inlineMsg6";
     }
     if ($data['ExpirationYear'] == $currentYear) {
         if ($data['ExpirationMonth'] < $currentMonth) {
             return "inlineMsg6";
         }
     }
     //Get InfusionSoft Api
     $app = $this->getInfusionSoftApi();
     // Get country text from code
     $country = Geoip::countryCode2name($data['Country']);
     // Create IndusionSoft contact
     $returnFields = array('Id');
     $conInfo = $app->findByEmail($data['Email'], $returnFields);
     if (count($conInfo)) {
         $isConID = $conInfo[0]['Id'];
     } else {
         $conDat = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'Company' => $data['Company'], 'StreetAddress1' => $data['StreetAddress1'], 'StreetAddress2' => $data['StreetAddress2'], 'City' => $data['City'], 'State' => $data['State'], 'PostalCode' => $data['PostalCode'], 'Country' => $country, 'Email' => $data['Email']);
         $isConID = $app->addCon($conDat);
     }
     // Locate existing credit card
     $ccID = $app->locateCard($isConID, substr($data['CreditCardNumber'], -4, 4));
     $creditCardType = $this->getISCreditCardType($data['CreditCardType']);
     if (!$ccID) {
         //Validate the credit card
         $card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $data['CreditCardNumber'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear'], 'CVV2' => $data['CVVCode']);
         $result = $app->validateCard($card);
         if ($result['Valid'] == 'false') {
             return "inlineMsg5";
         }
         $ccData = array('ContactId' => $isConID, 'FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CardNumber' => $data['CreditCardNumber'], 'CVV2' => $data['CVVCode'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear']);
         $ccID = $app->dsAdd("CreditCard", $ccData);
     }
     // Create AttentionWizard member
     $member = new Member();
     $member->FirstName = $data['FirstName'];
     $member->Surname = $data['LastName'];
     $member->Email = $data['Email'];
     $member->Password = $data['Password']['_Password'];
     $member->ISContactID = $isConID;
     $memberID = $member->write();
     //Find or create the 'user' group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
         $userGroup = new Group();
         $userGroup->Code = "customers";
         $userGroup->Title = "Customers";
         $userGroup->Write();
     }
     //Add member to user group
     $userGroup->Members()->add($member);
     //Get the current date
     $curdate = $app->infuDate(date('j-n-Y'));
     $product = Product::get()->byID(7);
     // Store credit card info
     $creditCard = new CreditCard();
     $creditCard->CreditCardType = $data['CreditCardType'];
     $creditCard->CreditCardNumber = $data['CreditCardNumber'];
     $creditCard->NameOnCard = $data['NameOnCard'];
     $creditCard->CreditCardCVV = $data['CVVCode'];
     $creditCard->ExpiryMonth = $data['ExpirationMonth'];
     $creditCard->ExpiryYear = $data['ExpirationYear'];
     $creditCard->Company = $data['Company'];
     $creditCard->StreetAddress1 = $data['StreetAddress1'];
     $creditCard->StreetAddress2 = $data['StreetAddress2'];
     $creditCard->City = $data['City'];
     $creditCard->State = $data['State'];
     $creditCard->PostalCode = $data['PostalCode'];
     $creditCard->Country = $data['Country'];
     $creditCard->Current = 1;
     $creditCard->ISCCID = $ccID;
     $creditCard->MemberID = $memberID;
     $creditCardID = $creditCard->write();
     // Create an Infusionsoft order
     $config = SiteConfig::current_site_config();
     $invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
     $orderItem = $app->addOrderItem($invoiceId, $this->getNonExpiringIsProductId(7), 3, floatval($data['Price']), intval($data['Quantity']), $product->Name, $product->Name);
     $result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
     // Create an order
     $order = new Order();
     $order->OrderStatus = 'P';
     $order->Amount = $data['Price'] * $data['Quantity'];
     $order->MemberID = $memberID;
     $order->ProductID = 7;
     $order->CreditCardID = $creditCardID;
     $orderID = $order->write();
     $returnFields = array('_AttentionWizard', 'Leadsource');
     $conDat1 = $app->loadCon($isConID, $returnFields);
     if ($result['Successful']) {
         // Add tag Paid member - prepaid
         $app->grpAssign($isConID, 2290);
         $conDat = array('ContactType' => 'AW Customer');
         if (!isset($conDat1['_AttentionWizard'])) {
             $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
         }
         if (isset($conDat1['_AttentionWizard']) && $conDat1['_AttentionWizard'] != 'Paid and Current' && $conDat1['_AttentionWizard'] != 'Free') {
             $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
         }
         if (!isset($conDat1['Leadsource']) || !$conDat1['Leadsource']) {
             $conDat['Leadsource'] = 'AttentionWizard';
         }
         $conID = $app->updateCon($isConID, $conDat);
         // Note is added
         $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Purchased AW Prepaid Credits", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
         $conActionID = $app->dsAdd("ContactAction", $conActionDat);
         // Update order
         $order->OrderStatus = 'c';
         $order->write();
         // Create a Subscription record
         $subscription = new Subscription();
         $subscription->StartDate = date("Y-m-d H:i:s");
         $subscription->MemberID = $memberID;
         $subscription->ProductID = 7;
         $subscription->OrderID = $orderID;
         $subscription->write();
         // Create a MemberCredits record
         $memberCredits = new MemberCredits();
         $memberCredits->Credits = $product->Credits * $data['Quantity'];
         $memberCredits->MemberID = $memberID;
         $memberCredits->ProductID = 7;
         $memberCredits->SubscriptionID = $subscription->ID;
         $memberCredits->write();
         $member->logIn();
         $this->setMessage('Success', 'Purchased non-expiring heatmaps successfully.');
         return 'url1';
     } else {
         //Update Infusionsoft contact
         $conDat = array('_AttentionWizard' => 'Unsuccessful prepaid sign-up', 'ContactType' => 'AW Prospect');
         if (!isset($conDat1['Leadsource'])) {
             $conDat['Leadsource'] = 'AttentionWizard';
         }
         $app->updateCon($isConID, $conDat);
         // Add an AW prospect tag
         $app->grpAssign($isConID, $this->getISTagIdByPaymentCode(strtoupper($result['Code'])));
         // Add a note
         $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Unsuccessful attempt to sign-up prepaid plan", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
         $conActionID = $app->dsAdd("ContactAction", $conActionDat);
         $member->logIn();
         $this->setMessage('Error', 'Sorry,the payment failed due to some reason.please update your credit card.');
         return 'url2';
     }
 }
 public function actionCardtypes()
 {
     if ($this->_allowAdvancedPayments === false) {
         _xls_404();
     }
     $model = new CreditCard();
     $pk = Yii::app()->getRequest()->getPost('pk');
     $name = Yii::app()->getRequest()->getPost('name');
     $value = Yii::app()->getRequest()->getPost('value');
     if ($pk) {
         CreditCard::model()->updateByPk($pk, array($name => $value));
         echo "success";
     }
     $this->render("cardtypes", array('model' => $model));
 }
Esempio n. 13
0
 public function vaultCreditCard()
 {
     $token = $this->creditCardDetails->token;
     if (empty($token)) {
         return null;
     } else {
         return CreditCard::find($token);
     }
 }
<?php

ini_set('include_path', '/usr/local');
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$ccnum = $argv[1];
$pm = new PaymentMethod();
$pm->setType('CreditCard');
$cc = new CreditCard();
$cc->setAccount($ccnum);
$pm->setCreditCard($cc);
$acct = new Account();
$page = 0;
$pageSize = 1000;
// max 1000 records per page
do {
    $count = 0;
    $response = $acct->fetchByPaymentMethod('', $pm, $page, $pageSize);
    $return_code = $response['returnCode'];
    print "Return Code is: {$return_code} \n";
    print_r($response);
    if ($return_code == 200) {
        $accounts = $response['data']->accounts;
        //$count = sizeof($accounts);
        foreach ($accounts as $account) {
            // process each account found here
            print "Found account with id: " . $account->getMerchantAccountId() . "\n";
            $acct_name = $account->getname();
            $acct_zip = $account->paymentMethods[0]->billingAddress->postalCode;
Esempio n. 15
0
 /**
  * @return array
  */
 public function getCardTypes()
 {
     return CHtml::listData(CreditCard::model()->findAllByAttributes(array('enabled' => 1), array('order' => 'sort_order,label')), 'validfunc', 'label');
 }
 /**
  * Check the credit card type.
  * @param $attribute The attribute name.
  * @param $params Additional parameters defined in the rules.
  * @return void
  */
 public function validateCardType($attribute, $params)
 {
     if (empty($this->cardType) === true) {
         // If the card type isn't sent, we allow it and rely on the payment
         // processor to decline if invalid.
         Yii::log('Unable to validate card type - card type is empty.', 'info', 'application.' . __CLASS__ . '.' . __FUNCTION__);
         return;
     }
     $arrEnabledCreditCardLabel = array_map(function ($creditCard) {
         return $creditCard->label;
     }, CreditCard::model()->enabled()->findAll());
     if (in_array($this->cardType, $arrEnabledCreditCardLabel) === false) {
         $this->addError($attribute, Yii::t('checkout', static::DISABLED_CARD_TYPE, array('{card type}' => $this->cardType)));
     }
 }
Esempio n. 17
0
 /**
  * sets instance properties from an array of values
  *
  * @ignore
  * @access protected
  * @param array $customerAttribs array of customer data
  */
 protected function _initialize($customerAttribs)
 {
     // set the attributes
     $this->_attributes = $customerAttribs;
     // map each address into its own object
     $addressArray = array();
     if (isset($customerAttribs['addresses'])) {
         foreach ($customerAttribs['addresses'] as $address) {
             $addressArray[] = Address::factory($address);
         }
     }
     $this->_set('addresses', $addressArray);
     // map each creditCard into its own object
     $creditCardArray = array();
     if (isset($customerAttribs['creditCards'])) {
         foreach ($customerAttribs['creditCards'] as $creditCard) {
             $creditCardArray[] = CreditCard::factory($creditCard);
         }
     }
     $this->_set('creditCards', $creditCardArray);
     // map each coinbaseAccount into its own object
     $coinbaseAccountArray = array();
     if (isset($customerAttribs['coinbaseAccounts'])) {
         foreach ($customerAttribs['coinbaseAccounts'] as $coinbaseAccount) {
             $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
         }
     }
     $this->_set('coinbaseAccounts', $coinbaseAccountArray);
     // map each paypalAccount into its own object
     $paypalAccountArray = array();
     if (isset($customerAttribs['paypalAccounts'])) {
         foreach ($customerAttribs['paypalAccounts'] as $paypalAccount) {
             $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
         }
     }
     $this->_set('paypalAccounts', $paypalAccountArray);
     // map each applePayCard into its own object
     $applePayCardArray = array();
     if (isset($customerAttribs['applePayCards'])) {
         foreach ($customerAttribs['applePayCards'] as $applePayCard) {
             $applePayCardArray[] = ApplePayCard::factory($applePayCard);
         }
     }
     $this->_set('applePayCards', $applePayCardArray);
     // map each androidPayCard into its own object
     $androidPayCardArray = array();
     if (isset($customerAttribs['androidPayCards'])) {
         foreach ($customerAttribs['androidPayCards'] as $androidPayCard) {
             $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
         }
     }
     $this->_set('androidPayCards', $androidPayCardArray);
     // map each amexExpressCheckoutCard into its own object
     $amexExpressCheckoutCardArray = array();
     if (isset($customerAttribs['amexExpressCheckoutCards'])) {
         foreach ($customerAttribs['amexExpressCheckoutCards'] as $amexExpressCheckoutCard) {
             $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
         }
     }
     $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);
     $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards, $this->amexExpressCheckoutCards));
 }
 public static function creditCardCardType()
 {
     return new MultipleValueNode("credit_card_card_type", CreditCard::allCardTypes());
 }
Esempio n. 19
0
 /**
  * Test that the allowed card types option is working properly
  *
  * @param array      $allowedCardTypes
  * @param string     $cardNumber
  * @param bool       $isValid
  */
 public function testAllowedCardTypes()
 {
     $validVisa = "4111111111111111";
     $validMastercard = "5555555555554444";
     $validAmex = "340000000000009";
     $validator = new CreditCard();
     // Test Allowed VISA only
     $validator->setAllowedCardTypes(CreditCard::VISA);
     $this->assertEquals(true, $validator->validate($validVisa), "Visa card should validate okay");
     $this->assertEquals(false, $validator->validate($validMastercard), "Mastercard is not in allowed card types");
     $this->assertEquals(false, $validator->validate($validAmex), "Amex is not in allowed card types");
     // Test Allowed Mastercard Only
     $validator->setAllowedCardTypes(CreditCard::MASTERCARD);
     $this->assertEquals(false, $validator->validate($validVisa), "Visa card is not in allowed card types");
     $this->assertEquals(true, $validator->validate($validMastercard), "Mastercard should validate okay");
     $this->assertEquals(false, $validator->validate($validAmex), "Amex is not in allowed card types");
     // Test Allowed Amex Only
     $validator->setAllowedCardTypes(CreditCard::AMERICAN_EXPRESS);
     $this->assertEquals(false, $validator->validate($validVisa), "Visa card is not in allowed card types");
     $this->assertEquals(false, $validator->validate($validMastercard), "Mastercard is not in allowed card types");
     $this->assertEquals(true, $validator->validate($validAmex), "Amex should validate okay");
     // Test Visa and Mastercard using bit operations
     $validator->setAllowedCardTypes(CreditCard::VISA | CreditCard::MASTERCARD);
     $this->assertEquals(true, $validator->validate($validVisa), "Visa should validate okay");
     $this->assertEquals(true, $validator->validate($validMastercard), "Mastercard should validate okay");
     $this->assertEquals(false, $validator->validate($validAmex), "Amex is not in allowed card types");
     // Test Mastercard and Amex using an array
     $validator->setAllowedCardTypes(array(CreditCard::MASTERCARD, CreditCard::AMERICAN_EXPRESS));
     $this->assertEquals(false, $validator->validate($validVisa), "Visa is not in allowed card type");
     $this->assertEquals(true, $validator->validate($validMastercard), "Mastercard should validate okay");
     $this->assertEquals(true, $validator->validate($validAmex), "Amex should validate okay");
     // Check ALL
     $validator->setAllowedCardTypes(CreditCard::ALL);
     $this->assertEquals(true, $validator->validate($validVisa), "Visa should validate okay");
     $this->assertEquals(true, $validator->validate($validMastercard), "Mastercard should validate okay");
     $this->assertEquals(true, $validator->validate($validAmex), "Amex should validate okay");
 }
Esempio n. 20
0
 /**
  * @param string $cardId credit card id obtained from a previous create API call.
  * @return string
  */
 public function getCreditCard($cardId)
 {
     return CreditCard::get($cardId, $this->contextFactory->createContext());
 }
Esempio n. 21
0
    STEP2: Build PaycorpClient object
    ------------------------------------------------------------------------------ */
 $client = new GatewayClient($clientConfig);
 /* ------------------------------------------------------------------------------
    STEP3: Build PaymentRealTimeRequest object
    ------------------------------------------------------------------------------ */
 $realTimeRequest = new PaymentRealTimeRequest();
 $realTimeRequest->setClientId($clientId);
 $realTimeRequest->setTransactionType($transactionType);
 $realTimeRequest->setOriginalTxnReference($originalTxnReference);
 $realTimeRequest->setClientRef("cvdb-123");
 $realTimeRequest->setComment("testing");
 $extraData = array("invoice-no" => "I99999", "job-no" => "J10101");
 $realTimeRequest->setExtraData($exData);
 // sets credit-card details
 $creditCard = new CreditCard();
 $creditCard->setType($cardType);
 $creditCard->setHolderName("Bob Marley");
 $creditCard->setExpiry($expiryDate);
 $creditCard->setNumber($cardNo);
 $creditCard->setSecureId($secureId);
 $creditCard->setSecureIdSupplied(TRUE);
 $realTimeRequest->setCreditCard($creditCard);
 // sets transaction-amounts details (all amounts are in cents)
 $transactionAmount = new TransactionAmount($paymentAmount);
 $transactionAmount->setTotalAmount();
 //$transactionAmount->setPaymentAmount($paymentAmount);
 $transactionAmount->setServiceFeeAmount();
 $transactionAmount->setCurrency($currency);
 $realTimeRequest->setTransactionAmount($transactionAmount);
 /* ------------------------------------------------------------------------------
 public function validate($input)
 {
     $input = preg_replace('([^0-9])', '', $input);
     return parent::verifyMod10($input) && $this->verifyIfCardIsBrand($input);
 }
Esempio n. 23
0
 /**
  * sets instance properties from an array of values
  *
  * @ignore
  * @access protected
  * @param array $customerAttribs array of customer data
  */
 protected function _initialize($customerAttribs)
 {
     $this->_attributes = $customerAttribs;
     $addressArray = [];
     if (isset($customerAttribs['addresses'])) {
         foreach ($customerAttribs['addresses'] as $address) {
             $addressArray[] = Address::factory($address);
         }
     }
     $this->_set('addresses', $addressArray);
     $creditCardArray = [];
     if (isset($customerAttribs['creditCards'])) {
         foreach ($customerAttribs['creditCards'] as $creditCard) {
             $creditCardArray[] = CreditCard::factory($creditCard);
         }
     }
     $this->_set('creditCards', $creditCardArray);
     $coinbaseAccountArray = [];
     if (isset($customerAttribs['coinbaseAccounts'])) {
         foreach ($customerAttribs['coinbaseAccounts'] as $coinbaseAccount) {
             $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
         }
     }
     $this->_set('coinbaseAccounts', $coinbaseAccountArray);
     $paypalAccountArray = [];
     if (isset($customerAttribs['paypalAccounts'])) {
         foreach ($customerAttribs['paypalAccounts'] as $paypalAccount) {
             $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
         }
     }
     $this->_set('paypalAccounts', $paypalAccountArray);
     $applePayCardArray = [];
     if (isset($customerAttribs['applePayCards'])) {
         foreach ($customerAttribs['applePayCards'] as $applePayCard) {
             $applePayCardArray[] = ApplePayCard::factory($applePayCard);
         }
     }
     $this->_set('applePayCards', $applePayCardArray);
     $androidPayCardArray = [];
     if (isset($customerAttribs['androidPayCards'])) {
         foreach ($customerAttribs['androidPayCards'] as $androidPayCard) {
             $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
         }
     }
     $this->_set('androidPayCards', $androidPayCardArray);
     $amexExpressCheckoutCardArray = [];
     if (isset($customerAttribs['amexExpressCheckoutCards'])) {
         foreach ($customerAttribs['amexExpressCheckoutCards'] as $amexExpressCheckoutCard) {
             $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
         }
     }
     $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);
     $venmoAccountArray = array();
     if (isset($customerAttribs['venmoAccounts'])) {
         foreach ($customerAttribs['venmoAccounts'] as $venmoAccount) {
             $venmoAccountArray[] = VenmoAccount::factory($venmoAccount);
         }
     }
     $this->_set('venmoAccounts', $venmoAccountArray);
     $usBankAccountArray = array();
     if (isset($customerAttribs['usBankAccounts'])) {
         foreach ($customerAttribs['usBankAccounts'] as $usBankAccount) {
             $usBankAccountArray[] = UsBankAccount::factory($usBankAccount);
         }
     }
     $this->_set('usBankAccounts', $usBankAccountArray);
     $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards, $this->amexExpressCheckoutCards, $this->venmoAccounts, $this->usBankAccounts));
 }
Esempio n. 24
0
 /**
  * Validate the payment data against the gateway-specific requirements
  *
  * @param Array $data
  * @return ValidationResult
  */
 public function validate($data)
 {
     $validationResult = $this->getValidationResult();
     if (!isset($data['Amount'])) {
         $validationResult->error('Payment amount not set');
     } else {
         if (empty($data['Amount'])) {
             $validationResult->error('Payment amount cannot be null');
         }
     }
     if (!isset($data['Currency'])) {
         $validationResult->error('Payment currency not set');
     } else {
         if (empty($data['Currency'])) {
             $validationResult->error('Payment currency cannot be null');
         } else {
             if (!array_key_exists($data['Currency'], $this->getSupportedCurrencies())) {
                 $validationResult->error('Currency ' . $data['Currency'] . ' not supported by this gateway');
             }
         }
     }
     if (isset($data['CardNumber'])) {
         $options = array('firstName' => $data['FirstName'], 'lastName' => $data['LastName'], 'month' => $data['MonthExpiry'], 'year' => $data['YearExpiry'], 'type' => $data['CreditCardType']);
         if (is_array($data['CardNumber'])) {
             $options['number'] = implode('', $data['CardNumber']);
         } else {
             $options['number'] = $data['CardNumber'];
         }
         $cc = new CreditCard($options);
         $validationResult->combineAnd($cc->validate());
     }
     $this->validationResult = $validationResult;
     return $validationResult;
 }
Esempio n. 25
0
 public function UpdateBillingAddress($data, $form)
 {
     $member = Member::currentUser();
     $isConID = $member->ISContactID;
     //Get InfusionSoft Api
     $creditCardType = Controller::curr()->getISCreditCardType($data['CreditCardType']);
     $app = Controller::curr()->getInfusionSoftApi();
     if (!isset($data['CreditCardNumber']) || $data['CreditCardNumber'] != $data['CreditCardNumberCopy'] && !is_numeric($data['CreditCardNumber'])) {
         Controller::curr()->setMessage('Error', 'The credit card is invalid!');
         return Controller::curr()->redirect(Controller::curr()->Link('#tabs-2'));
     }
     if ($data['CreditCardNumber'] == $data['CreditCardNumberCopy']) {
         $cardNumber = $data['CreditCardNumberCur'];
     } else {
         $cardNumber = $data['CreditCardNumber'];
     }
     // Validate credit card
     $card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $cardNumber, 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear'], 'CVV2' => $data['CreditCardCVV']);
     $result = $app->validateCard($card);
     if ($result['Valid'] != 'true') {
         Controller::curr()->setMessage('Error', 'The credit card is invalid!');
         return Controller::curr()->redirect(Controller::curr()->Link('#tabs-2'));
     }
     // Get country text from code
     $country = Geoip::countryCode2name($data['Country']);
     if ($data['CreditCardNumber'] == $data['CreditCardNumberCopy']) {
         //Get the credit card
         $creditCard = CreditCard::get()->filter(array('CreditCardNumber' => $data['CreditCardNumberCur'], 'MemberID' => $member->ID))->First();
         //Update the credit card on InfusionSoft
         $ccData = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
         $app->dsUpdate("CreditCard", $creditCard->ISCCID, $ccData);
         //Update the credit card on site
         $creditCard->CreditCardType = $data['CreditCardType'];
         $creditCard->NameOnCard = $data['NameOnCard'];
         $creditCard->CreditCardCVV = $data['CreditCardCVV'];
         $creditCard->ExpiryMonth = $data['ExpiryMonth'];
         $creditCard->ExpiryYear = $data['ExpiryYear'];
         $creditCard->Company = $data['Company'];
         $creditCard->StreetAddress1 = $data['StreetAddress1'];
         $creditCard->StreetAddress2 = $data['StreetAddress2'];
         $creditCard->City = $data['City'];
         $creditCard->State = $data['State'];
         $creditCard->PostalCode = $data['PostalCode'];
         $creditCard->Country = $data['Country'];
         $creditCard->Current = 1;
         $creditCard->write();
     } else {
         //Find if the credit card exist
         $creditCard = CreditCard::get()->filter(array('CreditCardNumber' => $data['CreditCardNumber'], 'MemberID' => $member->ID))->First();
         if ($creditCard) {
             //Get current credit card, un-mark it as current
             Controller::curr()->unsetCurrentCreditCard($member->ID);
             $ccID = $creditCard->ISCCID;
             //Update the credit card on InfusionSoft
             $ccData = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
             $app->dsUpdate("CreditCard", $ccID, $ccData);
             //Update the credit card on site
             $creditCard->CreditCardType = $data['CreditCardType'];
             $creditCard->NameOnCard = $data['NameOnCard'];
             $creditCard->CreditCardCVV = $data['CreditCardCVV'];
             $creditCard->ExpiryMonth = $data['ExpiryMonth'];
             $creditCard->ExpiryYear = $data['ExpiryYear'];
             $creditCard->Company = $data['Company'];
             $creditCard->StreetAddress1 = $data['StreetAddress1'];
             $creditCard->StreetAddress2 = $data['StreetAddress2'];
             $creditCard->City = $data['City'];
             $creditCard->State = $data['State'];
             $creditCard->PostalCode = $data['PostalCode'];
             $creditCard->Country = $data['Country'];
             $creditCard->Current = 1;
             $creditCard->write();
         } else {
             // Add the credit card on InfusionSoft
             $ccData = array('ContactId' => $isConID, 'FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CardNumber' => $data['CreditCardNumber'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
             $ccID = $app->dsAdd("CreditCard", $ccData);
             //Get current credit card un-mark it as current
             Controller::curr()->unsetCurrentCreditCard($member->ID);
             // Store Credit card on site and mark it as current
             $newCreditCard = new CreditCard();
             $newCreditCard->CreditCardType = $data['CreditCardType'];
             $newCreditCard->CreditCardNumber = $data['CreditCardNumber'];
             $newCreditCard->NameOnCard = $data['NameOnCard'];
             $newCreditCard->CreditCardCVV = $data['CreditCardCVV'];
             $newCreditCard->ExpiryMonth = $data['ExpiryMonth'];
             $newCreditCard->ExpiryYear = $data['ExpiryYear'];
             $newCreditCard->Company = $data['Company'];
             $newCreditCard->StreetAddress1 = $data['StreetAddress1'];
             $newCreditCard->StreetAddress2 = $data['StreetAddress2'];
             $newCreditCard->City = $data['City'];
             $newCreditCard->State = $data['State'];
             $newCreditCard->PostalCode = $data['PostalCode'];
             $newCreditCard->Country = $data['Country'];
             $newCreditCard->Current = 1;
             $newCreditCard->ISCCID = $ccID;
             $newCreditCard->MemberID = $member->ID;
             $newCreditCard->write();
         }
         //Update the user active Infusionsoft subscription Credit Card
         $subscription = Subscription::get()->filter(array('MemberID' => $member->ID, 'Status' => 1))->first();
         if ($subscription) {
             $subData = array('CC1' => $ccID);
             $app->dsUpdate("RecurringOrder", $subscription->SubscriptionID, $subData);
         }
     }
     //Update Member
     $member->FirstName = $data['FirstName'];
     $member->Surname = $data['LastName'];
     $member->write();
     // Update billing address on InfusionSoft
     $conDat = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'Company' => $data['Company'], 'StreetAddress1' => $data['StreetAddress1'], 'StreetAddress2' => $data['StreetAddress2'], 'City' => $data['City'], 'State' => $data['State'], 'PostalCode' => $data['PostalCode'], 'Country' => $country);
     $conID = $app->updateCon($isConID, $conDat);
     Controller::curr()->setMessage('Success', 'Credit Card and Billing Address successfully updated.');
     return Controller::curr()->redirect(Controller::curr()->Link('#tabs-2'));
 }
Esempio n. 26
0
 public function getSSCreditCardId2($memberId, $ssMemberId, $date)
 {
     $mysqli = $this->getDbConnection();
     $result = $mysqli->query("SELECT * FROM jos_aw_creditcard WHERE creditcard_userid = {$memberId} AND DATE(creditcard_date) = '{$date}'");
     if ($result->num_rows) {
         $obj = $result->fetch_object();
         $cardNumber = $obj->creditcard_number;
         $mysqli->close();
         if ($cardNumber) {
             $creditCard = CreditCard::get()->filter(array('CreditCardNumber' => $cardNumber, 'MemberID' => $ssMemberId))->first();
             if ($creditCard) {
                 return $creditCard->ID;
             }
         }
     }
     $mysqli->close();
     return false;
 }
Esempio n. 27
0
 public function testBin()
 {
     $creditCard = new CreditCard("1234560011112222", "12/2018", "999");
     $this->assertEquals("123456", $creditCard->bin());
 }
Esempio n. 28
0
 public function updateCreditCard($data, $form)
 {
     $member = Member::get()->byID($data['MemberID']);
     $isConID = $member->ISContactID;
     // Get the Page controller
     $Pg_Ctrl = new Page_Controller();
     //Get InfusionSoft Api
     $creditCardType = $Pg_Ctrl->getISCreditCardType($data['CreditCardType']);
     $app = $Pg_Ctrl->getInfusionSoftApi();
     // Validate credit card
     $card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $data['CreditCardNumber'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear'], 'CVV2' => $data['CreditCardCVV']);
     $result = $app->validateCard($card);
     if ($result['Valid'] != 'true') {
         $form->sessionMessage("The credit card details are invalid!", 'bad');
         return $this->edit(Controller::curr()->getRequest());
     }
     //Update the credit card on InfusionSoft
     $country = Geoip::countryCode2name($data['Country']);
     $ccData = array('BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
     $app->dsUpdate("CreditCard", $data['ISCCID'], $ccData);
     if (isset($data['Current'])) {
         // Update billing address on InfusionSoft
         $conDat = array('Company' => $data['Company'], 'StreetAddress1' => $data['StreetAddress1'], 'StreetAddress2' => $data['StreetAddress2'], 'City' => $data['City'], 'State' => $data['State'], 'PostalCode' => $data['PostalCode'], 'Country' => $country);
         $conID = $app->updateCon($isConID, $conDat);
     }
     //Get the credit card
     $creditCard = CreditCard::get()->filter(array('CreditCardNumber' => $data['CreditCardNumber']))->First();
     //Unset the current card
     if (isset($data['Current']) && !$creditCard->Current) {
         $Pg_Ctrl->unsetCurrentCreditCard($member->ID);
     }
     //Update the credit card on site
     $creditCard->CreditCardType = $data['CreditCardType'];
     $creditCard->NameOnCard = $data['NameOnCard'];
     $creditCard->CreditCardCVV = $data['CreditCardCVV'];
     $creditCard->ExpiryMonth = $data['ExpiryMonth'];
     $creditCard->ExpiryYear = $data['ExpiryYear'];
     $creditCard->Company = $data['Company'];
     $creditCard->StreetAddress1 = $data['StreetAddress1'];
     $creditCard->StreetAddress2 = $data['StreetAddress2'];
     $creditCard->City = $data['City'];
     $creditCard->State = $data['State'];
     $creditCard->PostalCode = $data['PostalCode'];
     $creditCard->Country = $data['Country'];
     if (isset($data['Current']) && !$creditCard->Current) {
         $creditCard->Current = 1;
     }
     if (isset($data['UsedForTrial'])) {
         $creditCard->UsedForTrial = 1;
     }
     $creditCard->write();
     $form->sessionMessage("Credit Card and Billing Address successfully updated.", 'good');
     $randomNumber = rand();
     return $this->getController()->redirect("admin/manage-data/CreditCard/EditForm/field/CreditCard/item/{$creditCard->ID}/edit?rand={$randomNumber}");
 }
Esempio n. 29
0
 /**
  * @param array $fields
  * @param array $params
  * @return Cursor
  */
 public function getCreditCards(array $fields = array(), array $params = array())
 {
     return $this->getManyByConnection(CreditCard::className(), $fields, $params, 'creditcards');
 }
 /**
  * This method is responsible for updating an existing content
  * into the database
  *
  * @param stdObject $entryContent contains the content that has been passed
  * by the form
  * @param UniquePasswordBundle\Category\{Login|CreditCard|Note} $type object to
  * be constructed
  * @param Symfony\Bundle\FrameworkBundle\Controller $user
  */
 private function updateContent($id, $entryContent, $type, $user)
 {
     $dateNow = new \DateTime();
     $content = $this->em->getRepository('UniquePasswordBundle:Content')->find($id);
     $content->setName($entryContent->name);
     $encodedContent = $type->encode($this->container, $user->getPassword());
     $content->setContent($encodedContent);
     $content->setModified($dateNow);
     $this->em->persist($content);
     $this->em->flush();
 }