getId() public method

ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.**
Deprecation: Not publicly available
public getId ( ) : string
return string
Exemplo n.º 1
0
 /**
  * Save a credit card with paypal
  * 
  * This helps you avoid the hassle of securely storing credit
  * card information on your site. PayPal provides a credit card
  * id that you can use for charging future payments.
  * 
  * @param array $params	credit card parameters
  */
 function saveCard($params)
 {
     $card = new CreditCard();
     $card->setType($params['type']);
     $card->setNumber($params['number']);
     $card->setExpireMonth($params['expire_month']);
     $card->setExpireYear($params['expire_year']);
     $card->setCvv2($params['cvv2']);
     $card->create(getApiContext());
     return $card->getId();
 }
Exemplo n.º 2
0
 /**
  * @depends testSerializationDeserialization
  * @param CreditCard $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getId(), "TestSample");
     $this->assertEquals($obj->getNumber(), "TestSample");
     $this->assertEquals($obj->getType(), "TestSample");
     $this->assertEquals($obj->getExpireMonth(), 123);
     $this->assertEquals($obj->getExpireYear(), 123);
     $this->assertEquals($obj->getCvv2(), "TestSample");
     $this->assertEquals($obj->getFirstName(), "TestSample");
     $this->assertEquals($obj->getLastName(), "TestSample");
     $this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
     $this->assertEquals($obj->getExternalCustomerId(), "TestSample");
     $this->assertEquals($obj->getState(), "TestSample");
     $this->assertEquals($obj->getValidUntil(), "TestSample");
     $this->assertEquals($obj->getLinks(), LinksTest::getObject());
 }
Exemplo n.º 3
0
 public function doStoreCreditCardAPI($payment_type, $card_number, $exp_month, $exp_year, $csc, $first_name, $last_name)
 {
     $apiContext = new ApiContext(new OAuthTokenCredential(self::CLIENT_ID, self::SECRET));
     $card = new CreditCard();
     $card->setType($payment_type);
     $card->setNumber($card_number);
     $card->setExpire_month($exp_month);
     $card->setExpire_year($exp_year);
     $card->setCvv2($csc);
     $card->setFirst_name($first_name);
     $card->setLast_name($last_name);
     try {
         $card->create($apiContext);
         //$card->create($apiContext);
     } catch (\PPConnectionException $ex) {
         echo "Exception:" . $ex->getMessage() . PHP_EOL;
         var_dump($ex->getData());
         exit(1);
     }
     //            $test = $card->getId();
     //
     //            $creditCardToken = new CreditCardToken();
     //            $creditCardToken->setCredit_card_id($test);
     //
     //            $fundingInstrument = new FundingInstrument();
     //            $fundingInstrument->setCredit_card($creditCardToken);
     //
     //            $payer = new Payer();
     //            $payer->setPayment_method("credit_card");
     //            $payer->setFunding_instruments(array($fundingInstrument));
     //
     //            $amount = new Amount();
     //            $amount->setCurrency("USD");
     //            $amount->setTotal($total);
     //
     //            $transaction = new Transaction();
     //            $transaction->setAmount($amount);
     //            $transaction->setDescription("creating a direct payment with credit card");
     //
     //            $payment = new Payment();
     //            $payment->setIntent("sale");
     //            $payment->setPayer($payer);
     //            $payment->setTransactions(array($transaction));
     //
     //            try {
     //                $payment->create($apiContext);    //$card->create($apiContext);
     //            } catch (\PPConnectionException $ex) {
     //                echo "Exception:" . $ex->getMessage() . PHP_EOL;
     //                var_dump($ex->getData());
     //                exit(1);
     //            }
     return $card->getId();
 }
Exemplo n.º 4
0
$card->setExpire_year("2019");
$card->setCvv2("012");
$card->setFirst_name("Joe");
$card->setLast_name("Shopper");
// ### Save card
// Creates the credit card as a resource
// in the PayPal vault. The response contains
// an 'id' that you can use to refer to it
// in the future payments.
// (See bootstrap.php for more on `ApiContext`)
try {
    $card->create($apiContext);
} catch (\PPConnectionException $ex) {
    echo "Exception:" . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);
}
?>
<html>
<body>
	<div>Saved a new credit card with id: <?php 
echo $card->getId();
?>
</div>
	<pre><?php 
var_dump($card);
?>
</pre>
	<a href='../index.html'>Back</a>
</body>
</html>