1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85:
<?php
/**
* Fat Zebra REST Create Card (Tokenize) Request
*/
namespace Omnipay\Fatzebra\Message;
/**
* Fat Zebra REST Create Card (Tokenize) Request
*
* In order to tokenize a credit card you must submit the following details:
*
* * Card Holder (string)
* * Card Number (string, numerical, 13 to 16 digits)
* * Card Expiry (string, mm/yyyy format)
* * CVV (numerical, 3 or 4 digits)
*
* Example:
*
* <code>
* // Create a gateway for the Fat Zebra REST Gateway
* // (routes to GatewayFactory::create)
* $gateway = Omnipay::create('FatzebraGateway');
*
* // Initialise the gateway
* $gateway->initialize(array(
* 'username' => 'TEST',
* 'token' => 'TEST',
* 'testMode' => true, // Or false when you are ready for live transactions
* ));
*
* // Create a credit card object
* // This card can be used for testing.
* $card = new CreditCard(array(
* 'firstName' => 'Example',
* 'lastName' => 'Customer',
* 'number' => '4005550000000001',
* 'expiryMonth' => '01',
* 'expiryYear' => '2020',
* 'cvv' => '123',
* ));
*
* // Do a tokenize transaction on the gateway
* $transaction = $gateway->createCard(array(
* 'card' => $card,
* ));
* $response = $transaction->send();
* if ($response->isSuccessful()) {
* echo "createCard transaction was successful!\n";
* $card_id = $response->getCardReference();
* echo "Card Reference = " . $card_id . "\n";
* }
* </code>
*
* @link http://www.paystream.com.au/developer-guides/
* @see Omnipay\Fatzebra\FatzebraGateway
*/
class CreateCardRequest extends AbstractRestRequest
{
public function getData()
{
$this->validate('card');
$card = $this->getCard();
$card->validate();
$data['card_holder'] = $card->getName();
$data['card_number'] = $card->getNumber();
$data['card_expiry'] = $card->getExpiryDate('m/Y');
$data['cvv'] = $card->getCvv();
return $data;
}
/**
* Get transaction endpoint.
*
* Cards are created using the /credit_cards resource.
*
* @return string
*/
protected function getEndpoint()
{
return parent::getEndpoint() . '/credit_cards';
}
}