This class defines and abstracts all of the credit card types used throughout the Omnipay system.
 public function testGetData()
 {
     $card = new CreditCard($this->getValidCard());
     $card->setStartMonth(1);
     $card->setStartYear(2000);
     $this->request->setCard($card);
     $this->request->setTransactionId('abc123');
     $this->request->setDescription('Sheep');
     $this->request->setClientIp('127.0.0.1');
     $data = $this->request->getData();
     $this->assertSame('DoDirectPayment', $data['METHOD']);
     $this->assertSame('Authorization', $data['PAYMENTACTION']);
     $this->assertSame('10.00', $data['AMT']);
     $this->assertSame('USD', $data['CURRENCYCODE']);
     $this->assertSame('abc123', $data['INVNUM']);
     $this->assertSame('Sheep', $data['DESC']);
     $this->assertSame('127.0.0.1', $data['IPADDRESS']);
     $this->assertSame($card->getNumber(), $data['ACCT']);
     $this->assertSame($card->getBrand(), $data['CREDITCARDTYPE']);
     $this->assertSame($card->getExpiryDate('mY'), $data['EXPDATE']);
     $this->assertSame('012000', $data['STARTDATE']);
     $this->assertSame($card->getCvv(), $data['CVV2']);
     $this->assertSame($card->getIssueNumber(), $data['ISSUENUMBER']);
     $this->assertSame($card->getFirstName(), $data['FIRSTNAME']);
     $this->assertSame($card->getLastName(), $data['LASTNAME']);
     $this->assertSame($card->getEmail(), $data['EMAIL']);
     $this->assertSame($card->getAddress1(), $data['STREET']);
     $this->assertSame($card->getAddress2(), $data['STREET2']);
     $this->assertSame($card->getCity(), $data['CITY']);
     $this->assertSame($card->getState(), $data['STATE']);
     $this->assertSame($card->getPostcode(), $data['ZIP']);
     $this->assertSame($card->getCountry(), $data['COUNTRYCODE']);
 }
 public function testGetDataWithCard()
 {
     $card = new CreditCard($this->getValidCard());
     $card->setStartMonth(1);
     $card->setStartYear(2000);
     $this->request->setCard($card);
     $this->request->setTransactionId('abc123');
     $this->request->setDescription('Sheep');
     $this->request->setClientIp('127.0.0.1');
     $data = $this->request->getData();
     $this->assertSame('authorize', $data['intent']);
     $this->assertSame('credit_card', $data['payer']['payment_method']);
     $this->assertSame('10.00', $data['transactions'][0]['amount']['total']);
     $this->assertSame('USD', $data['transactions'][0]['amount']['currency']);
     $this->assertSame('abc123 : Sheep', $data['transactions'][0]['description']);
     $this->assertSame($card->getNumber(), $data['payer']['funding_instruments'][0]['credit_card']['number']);
     $this->assertSame($card->getBrand(), $data['payer']['funding_instruments'][0]['credit_card']['type']);
     $this->assertSame($card->getExpiryMonth(), $data['payer']['funding_instruments'][0]['credit_card']['expire_month']);
     $this->assertSame($card->getExpiryYear(), $data['payer']['funding_instruments'][0]['credit_card']['expire_year']);
     $this->assertSame($card->getCvv(), $data['payer']['funding_instruments'][0]['credit_card']['cvv2']);
     $this->assertSame($card->getFirstName(), $data['payer']['funding_instruments'][0]['credit_card']['first_name']);
     $this->assertSame($card->getLastName(), $data['payer']['funding_instruments'][0]['credit_card']['last_name']);
     $this->assertSame($card->getAddress1(), $data['payer']['funding_instruments'][0]['credit_card']['billing_address']['line1']);
     $this->assertSame($card->getAddress2(), $data['payer']['funding_instruments'][0]['credit_card']['billing_address']['line2']);
     $this->assertSame($card->getCity(), $data['payer']['funding_instruments'][0]['credit_card']['billing_address']['city']);
     $this->assertSame($card->getState(), $data['payer']['funding_instruments'][0]['credit_card']['billing_address']['state']);
     $this->assertSame($card->getPostcode(), $data['payer']['funding_instruments'][0]['credit_card']['billing_address']['postal_code']);
     $this->assertSame($card->getCountry(), $data['payer']['funding_instruments'][0]['credit_card']['billing_address']['country_code']);
 }
 /**
  * {@inheritdoc}
  */
 public function getConfigTreeBuilder()
 {
     $builder = new TreeBuilder();
     $rootNode = $builder->root('sylius_omnipay');
     $gateways = GatewayFactory::find();
     $omnipayCc = new CreditCard();
     $ccTypes = array_keys($omnipayCc->getSupportedBrands());
     $rootNode->children()->arrayNode('gateways')->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('type')->validate()->ifTrue(function ($type) use($gateways) {
         if (empty($type)) {
             return true;
         }
         if (0 !== strpos($type, '\\') && !in_array($type, $gateways)) {
             return true;
         }
         return false;
     })->thenInvalid(sprintf('Unknown payment gateway selected. Valid gateways are: %s.', implode(", ", $gateways)))->end()->end()->scalarNode('label')->cannotBeEmpty()->end()->booleanNode('mode')->defaultFalse()->end()->booleanNode('active')->defaultTrue()->end()->arrayNode('cc_types')->prototype('scalar')->validate()->ifTrue(function ($ccType) use($ccTypes) {
         if (empty($ccType)) {
             return true;
         }
         if (!in_array($ccType, $ccTypes)) {
             return true;
         }
         return false;
     })->thenInvalid(sprintf('Unknown credit card type selected. Valid credit card types are: %s.', implode(", ", $ccTypes)))->end()->end()->end()->arrayNode('options')->prototype('scalar')->end()->end()->end()->end()->end();
     return $builder;
 }
 public function testGetData()
 {
     $data = $this->request->getData();
     $this->assertSame('10.00', $data['purchase']['amount']);
     $this->assertSame($this->card->getNumber(), $data['card']['card[number]']);
     $this->assertSame($this->card->getExpiryMonth(), $data['card']['card[exp_month]']);
     $this->assertSame($this->card->getExpiryYear(), $data['card']['card[exp_year]']);
     $this->assertSame($this->card->getCvv(), $data['card']['card[cvv]']);
 }
 public function testCreateCardLocallyValidatesCardsDuringNonTestMode()
 {
     $this->card->setNumber('1');
     $this->gateway->setTestMode(false);
     $this->setMockHttpResponse('CreateCardSuccess.txt');
     $transaction = $this->gateway->createCard(array('card' => $this->card));
     $this->setExpectedException('\\Omnipay\\Common\\Exception\\InvalidCreditCardException');
     $transaction->send();
 }
 public function setUp()
 {
     $this->gateway = new \Omnipay\PaymentWall\Gateway();
     $gateway = $this->gateway;
     $this->card = new CreditCard($this->getValidCard());
     $this->card->setStartMonth(1);
     $this->card->setStartYear(2000);
     $this->request = new VoidRequest($this->getHttpClient(), $this->getHttpRequest());
     $this->request->initialize(array('transactionReference' => 'ASDF1234', 'publicKey' => 'asdfasdf', 'privateKey' => 'asdfasdf', 'clientIp' => '127.0.0.1', 'browserDomain' => 'PairMeUp'));
     // Sample response data for testing
     $data = array('success' => true, 'id' => 1234, 'card' => array('token' => 'qwerty12341234'), 'error' => 'The quick brown fox', 'code' => 200);
     $this->response = new Response($this->request, $data, 200);
 }
 protected function setUp()
 {
     $arguments = array($this->getHttpClient(), $this->getHttpRequest());
     $this->request = m::mock('Omnipay\\Sisow\\Message\\PurchaseRequest[getEndpoint]', $arguments);
     $card = new CreditCard($this->getValidCard());
     $card->setBirthday('01-02-2000');
     $this->request->setCard($card);
     $this->request->setShopId('0');
     $this->request->setMerchantId('0123456');
     $this->request->setMerchantKey('b36d8259346eaddb3c03236b37ad3a1d7a67cec6');
     $this->request->setAmount('10.00');
     $this->request->setTransactionId('123');
     $this->request->setReturnUrl('http://localhost/return');
     $this->request->setNotifyUrl('http://localhost/notify');
 }
 public function testCardDetails()
 {
     $card = new CreditCard();
     $card->setName('Test Foo');
     $card->setEmail('*****@*****.**');
     $card->setCompany('Test Company');
     $card->setPostcode('13100');
     $card->setCity('Nicetown');
     $card->setCountry('TN');
     $card->setPhone('00999555666');
     $card->setAddress1('Home street');
     $card->setAddress2('Near the shop');
     $this->request->setCard($card);
     $data = $this->request->getData();
     $this->assertSame("Test Foo", $data['CN']);
     $this->assertSame("*****@*****.**", $data['EMAIL']);
     $this->assertSame("Test Company", $data['COM']);
     $this->assertSame("13100", $data['OWNERZIP']);
     $this->assertSame("Nicetown", $data['OWNERTOWN']);
     $this->assertSame("TN", $data['OWNERCTY']);
     $this->assertSame("00999555666", $data['OWNERTELNO']);
     $this->assertSame("Home street", $data['OWNERADDRESS']);
     $this->assertSame("Near the shop", $data['OWNERADDRESS2']);
 }
Ejemplo n.º 9
0
 public static function cardToApiParameters(\Omnipay\Common\CreditCard $card)
 {
     $data = array();
     $data['econCardno'] = $card->getNumber();
     $data['cardExpdate'] = $card->getExpiryDate('Ym');
     $data['CVV2'] = $card->getCvv();
     $data['kanjiName1_1'] = $card->getLastName();
     $data['kanjiName1_2'] = $card->getFirstName();
     return $data;
 }
 public function testStoreCard()
 {
     $card = new CreditCard($this->getValidCard());
     $card->setStartMonth(1);
     $card->setStartYear(2000);
     $this->request = new CreateCardRequest($this->getHttpClient(), $this->getHttpRequest());
     $this->request->initialize(array('card' => $card));
     $data = $this->request->getData();
     $this->assertSame($card->getNumber(), $data['card_number']);
     $this->assertSame($card->getExpiryDate('m/Y'), $data['card_expiry']);
     $this->assertSame($card->getCvv(), $data['cvv']);
     $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
     $this->request->initialize(array('amount' => '10.00', 'transactionReference' => 'TestReference999', 'cardReference' => 'abc1234'));
     $this->request->setTransactionId('525-P-S2Y05UQ9');
     $this->request->setClientIp('127.0.0.1');
     $data = $this->request->getData();
     $this->assertSame('10.00', $data['amount']);
     $this->assertSame('abc1234', $data['card_token']);
 }
Ejemplo n.º 11
0
 /**
  * Fills the card information
  *
  * @param SimpleXMLElement $data
  * @param CreditCard       $card
  */
 private function appendCustomerDetailsCard(SimpleXMLElement $data, CreditCard $card)
 {
     $data->customer_details[0]['salutation'] = $card->getGender();
     $data->customer_details[0]['title'] = $card->getBillingTitle();
     $data->customer_details[0]['firstName'] = $card->getBillingFirstName();
     $data->customer_details[0]['lastName'] = $card->getBillingLastName();
     $data->customer_details[0]['street'] = $card->getBillingAddress1();
     $data->customer_details[0]['streetNo'] = null;
     $data->customer_details[0]['addressAddition'] = $card->getBillingAddress2();
     $data->customer_details[0]['zip'] = $card->getBillingPostcode();
     $data->customer_details[0]['city'] = $card->getBillingCity();
     $data->customer_details[0]['country'] = $this->getCountryCode($card->getBillingCountry());
     $data->customer_details[0]['email'] = $card->getEmail();
     $data->customer_details[0]['phone'] = $card->getBillingPhone();
     $data->customer_details[0]['cellPhone'] = null;
     $data->customer_details[0]['birthday'] = $card->getBirthday('Ymd');
 }
 public function testGetBrandJcb()
 {
     $card = new CreditCard(array('number' => '3530111333300000'));
     $this->assertSame(CreditCard::BRAND_JCB, $card->getBrand());
 }
Ejemplo n.º 13
0
 /**
  * Returns ReD Shield risk checker parameters
  *
  * @param CreditCard $card
  * @return array
  */
 protected function getRedParams($card)
 {
     $params = ['CRITERION.RED_ebWEBSITE' => $card->getEbWebsite(), 'CRITERION.RED_EBT_GENDER' => $card->getGender(), 'CRITERION.RED_EBT_TOF' => $card->getRedTof(), 'CRITERION.RED_SHIP_ADDR1' => $card->getShippingAddress1(), 'CRITERION.RED_SHIP_ADDR2' => $card->getShippingAddress2(), 'CRITERION.RED_SHIP_CITY' => $card->getShippingCity(), 'CRITERION.RED_SHIP_CNTRY_CD' => $card->getShippingCountry(), 'CRITERION.RED_CUST_ID' => $card->getCustomerId(), 'CRITERION.RED_SHIP_EMAIL' => $card->getShippingEmail(), 'CRITERION.RED_SHIP_FNAME' => $card->getShippingFirstName(), 'CRITERION.RED_SHIP_LNAME' => $card->getShippingLastName(), 'CRITERION.RED_SHIP_HOME_PHONE' => $card->getShippingPhone(), 'CRITERION.RED_SHIP_MOBILE_PHONE' => $card->getShippingFax(), 'CRITERION.RED_SHIP_POSTAL_CD' => $card->getShippingPostcode(), 'CRITERION.RED_SHIP_STPR_CD' => $card->getShippingState()];
     foreach ($this->getItemAmount() as $idx => $value) {
         $params["CRITERION.RED_ITEM_AMT" . ($idx + 1)] = $value;
     }
     foreach ($this->getItemQty() as $idx => $value) {
         $params["CRITERION.RED_ITEM_QTY" . ($idx + 1)] = $value;
     }
     foreach ($this->getItemDesc() as $idx => $value) {
         $params["CRITERION.RED_ITEM_DESC" . ($idx + 1)] = $value;
     }
     // set number of ITEMs
     $params['CRITERION.RED_OI_REPEAT'] = max([count($this->getItemAmount()), count($this->getItemQty()), count($this->getItemDesc())]) ?: null;
     foreach ($card->getUserData() as $idx => $value) {
         $params["CRITERION.RED_EBT_USER_DATA" . ($idx + 1)] = $value;
     }
     return $params;
 }
Ejemplo n.º 14
0
 public function setUp()
 {
     parent::setUp();
     $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest());
     $card = new CreditCard($this->getValidCard());
     $card->setBillingAddress1('Wall street');
     $card->setBillingAddress2('Wall street 2');
     $card->setBillingCity('San Luis Obispo');
     $card->setBillingCountry('US');
     $card->setBillingPostcode('93401');
     $card->setBillingPhone('1234567');
     $card->setBillingState('CA');
     $card->setShippingAddress1('Shipping Wall street');
     $card->setShippingAddress2('Shipping Wall street 2');
     $card->setShippingCity('San Luis Obispo');
     $card->setShippingCountry('US');
     $card->setShippingPostcode('93401');
     $card->setShippingPhone('1234567');
     $card->setShippingState('CA');
     $card->setCompany('Test Business name');
     $card->setEmail('*****@*****.**');
     $this->purchaseOptions = array('amount' => 9563, 'card' => $card, 'customerId' => '9966441');
     $this->captureOptions = array('amount' => 1000, 'transactionReference' => '9988775');
     $this->voidOptions = array('accountNumber' => '12345678', 'storeId' => 'test', 'storePassword' => 'test', 'transactionReference' => '115147689');
 }
Ejemplo n.º 15
0
 /**
  * @expectedException Omnipay\Common\Exception\InvalidCreditCardException
  * @expectedExceptionMessage Card number should have 12 to 19 digits
  */
 public function testInvalidShortCard()
 {
     $this->card->setNumber('4440');
     $this->card->validate();
 }
Ejemplo n.º 16
0
    $card = $app['request']->get('card');
    // save POST data into session
    $app['session']->set($sessionVar . '.create', $params);
    $app['session']->set($sessionVar . '.card', $card);
    $params['card'] = $card;
    $params['clientIp'] = $app['request']->getClientIp();
    $response = $gateway->createCard($params)->send();
    return $app['twig']->render('response.twig', array('gateway' => $gateway, 'response' => $response));
});
// create gateway update Credit Card
$app->get('/gateways/{name}/update-card', function ($name) use($app) {
    $gateway = Omnipay::create($name);
    $sessionVar = 'omnipay.' . $gateway->getShortName();
    $gateway->initialize((array) $app['session']->get($sessionVar));
    $params = $app['session']->get($sessionVar . '.update', array());
    $card = new CreditCard($app['session']->get($sessionVar . '.card'));
    return $app['twig']->render('request.twig', array('gateway' => $gateway, 'method' => 'updateCard', 'params' => $params, 'card' => $card->getParameters()));
});
// submit gateway update Credit Card
$app->post('/gateways/{name}/update-card', function ($name) use($app) {
    $gateway = Omnipay::create($name);
    $sessionVar = 'omnipay.' . $gateway->getShortName();
    $gateway->initialize((array) $app['session']->get($sessionVar));
    // load POST data
    $params = $app['request']->get('params');
    $card = $app['request']->get('card');
    // save POST data into session
    $app['session']->set($sessionVar . '.update', $params);
    $app['session']->set($sessionVar . '.card', $card);
    $params['card'] = $card;
    $params['clientIp'] = $app['request']->getClientIp();
Ejemplo n.º 17
0
 /**
  * (non-PHPdoc)
  *
  * @see \Omnipay\Common\Message\MessageInterface::getData()
  */
 public function getData()
 {
     // PaymentMethod independant checks
     $this->validate('transactionReference', 'currency', 'siteId', 'amount', 'description', 'returnUrl', 'notifyUrl', 'ipaddress');
     // PaymentMethod specific checks
     $this->validatePaymentMethodSpecific();
     // Transaction data
     $data = array('ref' => $this->getTransactionReference(), 'currency' => $this->getCurrency(), 'site_id' => $this->getSiteId(), 'amount' => $this->getAmountInteger(), 'description' => $this->getDescription(), 'control_url' => $this->getNotifyUrl(), 'return_url' => $this->getReturnUrl(), 'return_url_failed' => $this->getCancelUrl(), 'ip_address' => $this->getIpAddress(), 'language' => $this->getLanguage());
     if ($this->getPaymentMethod() == 'ideal') {
         $data['issuer_id'] = $this->getIssuer();
     }
     // Customer data
     $customerData = new CreditCard($_POST);
     if ($customerData && strlen($customerData->getFirstName()) && strlen($customerData->getLastName())) {
         $data['customer'] = array('first_name' => $customerData->getFirstName(), 'last_name' => $customerData->getLastName(), 'company_name' => $customerData->getCompany(), 'address' => $customerData->getAddress1(), 'city' => $customerData->getCity(), 'state' => $customerData->getState(), 'postal_code' => $customerData->getPostcode(), 'country_code' => $customerData->getCountry(), 'phone_number' => $customerData->getPhone(), 'email' => $customerData->getEmail());
     }
     return $data;
 }
 /**
  * Get a list of supported credit-card brands.
  * This doesn't depend on the
  * @return array
  */
 public function getCardTypes()
 {
     $card = new CreditCard();
     $brands = $card->getSupportedBrands();
     foreach ($brands as $brand => $x) {
         $brands[$brand] = _t('CreditCard.' . strtoupper($brand), $brand);
     }
     return $brands;
 }
 /**
  * @param Market_OrderModel       $order
  * @param Market_PaymentFormModel $paymentForm
  *
  * @return CreditCard
  */
 private function createCard(Market_OrderModel $order, Market_PaymentFormModel $paymentForm)
 {
     $card = new CreditCard();
     $card->setFirstName($paymentForm->firstName);
     $card->setLastName($paymentForm->lastName);
     $card->setNumber($paymentForm->number);
     $card->setExpiryMonth($paymentForm->month);
     $card->setExpiryYear($paymentForm->year);
     $card->setCvv($paymentForm->cvv);
     if ($order->billingAddressId) {
         $billingAddress = $order->billingAddress;
         $card->setBillingAddress1($billingAddress->address1);
         $card->setBillingAddress2($billingAddress->address2);
         $card->setBillingCity($billingAddress->city);
         $card->setBillingPostcode($billingAddress->zipCode);
         $card->setBillingState($billingAddress->getStateText());
         $card->setBillingCountry($billingAddress->getCountryText());
         $card->setBillingPhone($billingAddress->phone);
     }
     if ($order->shippingAddressId) {
         $shippingAddress = $order->shippingAddress;
         $card->setShippingAddress1($shippingAddress->address1);
         $card->setShippingAddress2($shippingAddress->address2);
         $card->setShippingCity($shippingAddress->city);
         $card->setShippingPostcode($shippingAddress->zipCode);
         $card->setShippingState($shippingAddress->getStateText());
         $card->setShippingCountry($shippingAddress->getCountryText());
         $card->setShippingPhone($shippingAddress->phone);
         $card->setCompany($shippingAddress->company);
     }
     $card->setEmail($order->email);
     return $card;
 }
 public function setUp()
 {
     parent::setUp();
     $bankAccount = new BankAccount();
     $bankAccount->setAccountNumber("12345678");
     $bankAccount->setRoutingNumber("112200439");
     $bankAccount->setBankName("Mikey National Bank");
     $bankAccount->setBankAccountType(BankAccount::ACCOUNT_TYPE_CHECKING);
     $bankAccount->setBillingFirstName("Mikey");
     $bankAccount->setBillingLastName("DABLname");
     $bankAccount->setName("Mikey DABLname");
     $bankAccount->setBillingAddress1("15505 Pennsylvania Ave.");
     $bankAccount->setBillingCity("Washington DC");
     $bankAccount->setBillingName("FED-Payor");
     $bankAccount->setBillingPostcode("20003");
     $bankAccount->setBillingState("CA");
     $bankAccount->setBillingCountry('USA');
     $bankAccount->setBillingPhone('5555555555');
     $bankAccount->setCompany("DAB2LLC");
     $bankAccount->setEmail('*****@*****.**');
     $creditCard = new CreditCard();
     $creditCard->setNumber('4111111111111111');
     $creditCard->setCvv("432");
     $creditCard->setExpiryMonth('12');
     $creditCard->setExpiryYear('2025');
     $creditCard->setEmail('*****@*****.**');
     $creditCard->setName("Mikey DABLname");
     $creditCard->setBillingAddress1("15505 Pennsylvania Ave.");
     $creditCard->setBillingCity("Washington DC");
     $creditCard->setBillingFirstName("FED-Payor");
     $creditCard->setBillingLastName("DABLname");
     $creditCard->setBillingPostcode("20003");
     $creditCard->setBillingState("DC");
     $creditCard->setBillingCountry("USA");
     $this->gateway = new CybersourceGateway($this->getHttpClient(), $this->getHttpRequest());
     $this->gateway->setTestMode(true);
     $defaultOptions = array('merchantId' => '', 'username' => '', 'transactionKey' => '');
     if ($defaultOptions['merchantId'] != '' && $defaultOptions['username'] != '' && $defaultOptions['transactionKey'] != '' && $defaultOptions['password'] != '') {
         $purchaseOptions = array('amount' => '12.00', 'card' => $creditCard, 'merchantReferenceCode' => uniqid());
         /** @var \Omnipay\Cybersource\Message\PurchaseRequest $request */
         $request = $this->gateway->purchase(array_merge($defaultOptions, $purchaseOptions));
         /** @var \Omnipay\Cybersource\Message\CybersourceResponse $response */
         $response = $request->send();
         $this->assertEquals(true, $response->isSuccessful());
         $purchaseOptions = array('amount' => '12.00', 'bankAccount' => $bankAccount, 'merchantReferenceCode' => uniqid());
         /** @var \Omnipay\Cybersource\Message\PurchaseRequest $request */
         $request = $this->gateway->purchase(array_merge($defaultOptions, $purchaseOptions));
         $response = $request->send();
         $this->assertEquals(true, $response->isSuccessful());
         $reportOptions = array('reportDate' => new \DateTime('12/17/2014'));
         /** @var \Omnipay\Cybersource\Message\TransactionDetailReportRequest $request */
         $request = $this->gateway->transactionDetailReport(array_merge($defaultOptions, $reportOptions));
         /** @var \Omnipay\Cybersource\Message\TransactionDetailReportResponse $response */
         $response = $request->send();
         $this->assertEquals(true, $response->isSuccessful());
     }
 }