get() public static method

Obtain the Credit Card resource for the given identifier.
public static get ( string $creditCardId, ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : CreditCard
$creditCardId string
$apiContext PayPal\Rest\ApiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
$restCall PayPal\Transport\PayPalRestCall is the Rest Call Service that is used to make rest calls
return CreditCard
 public function getDetails($creditCardToken)
 {
     $apiContext = $this->connectionService->getApiContext();
     $dispatcher = $this->connectionService->getDispatcher();
     $dispatcher->dispatch(CreditCardEvent::GET_START);
     $creditCard = CreditCard::get($creditCardToken, $apiContext);
     $creditCardEvent = new CreditCardEvent($creditCard);
     $dispatcher->dispatch(CreditCardEvent::GET_END, $creditCardEvent);
     return $creditCard;
 }
示例#2
0
 public function testOperations()
 {
     $c1 = $this->cards['full'];
     // 		$this->assertNull($c1->getId());
     $c1->create();
     $this->assertNotNull($c1->getId());
     $c2 = CreditCard::get($c1->getId());
     $this->assertEquals($c1->getBilling_address(), $c2->getBilling_address());
     $this->assertGreaterThan(0, count($c2->getLinks()));
     $this->assertEquals(self::$cardType, $c2->getType());
     $this->assertNotNull($c2->getState());
 }
示例#3
0
文件: Paypal.php 项目: shivap87/cost
 /**
  * 
  * @param string $cardId credit card id obtained from 
  * a previous create API call.
  */
 function getCreditCard($cardId)
 {
     return CreditCard::get($cardId, getApiContext());
 }
示例#4
0
// Creates the credit card as a resource
// in the PayPal vault. The response contains
// an 'id' that you can use to refer to it later.
// (See bootstrap.php for more on `ApiContext`)
try {
    $card = $card->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
    echo "Exception:" . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);
}
try {
    // ### Delete Card
    // Lookup and delete a saved credit card.
    // (See bootstrap.php for more on `ApiContext`)
    $creditCard = CreditCard::get($card->getId(), $apiContext);
    $creditCard->delete($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
    echo "Exception: " . $ex->getMessage() . PHP_EOL;
    exit(1);
}
?>
<html>
<head>
	<title>Delete a saved credit card</title>
</head>
<body>
    <p> Credit Card deleted Successfully</p>
	<a href='../index.html'>Back</a>
</body>
</html>
 /**
  * @dataProvider mockProvider
  * @param CreditCard $obj
  */
 public function testGet($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(CreditCardTest::getJson()));
     $result = $obj->get("creditCardId", $mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }
示例#6
0
// The following code takes you through
// the process of retrieving a saved CreditCard
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
// The cardId can be obtained from a previous save credit
// card operation. Use $card->getId()
$cardId = "CARD-5BT058015C739554AKE2GCEI";
// ### Authentication
// Pass in a `OAuthTokenCredential` object
// explicilty to authenticate the call.
// If you skip this step, the client id/secret
// set in the config file will be used.
CreditCard::setCredential($cred);
/// ### Retrieve card
try {
    $card = CreditCard::get($cardId);
} catch (\PPConnectionException $ex) {
    echo "Exception: " . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);
}
?>
<html>
<body>
	<div>Retrieving credit card: <?php 
echo $cardId;
?>
</div>
	<pre><?php 
var_dump($card);
?>
示例#7
0
    ->setExpireMonth("11")
    ->setExpireYear("2020")
    ->setCvv2("999")
    ->setFirstName("Nicolash1")
    ->setLastName("Smith");


try {
    $creditCard->create($apiContext);
    display($creditCard);
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
    // This will print the detailed information on the exception. 
    //REALLY HELPFUL FOR DEBUGGING
    display($ex->getData());
} 
*/
//  GET Credit card
echo '<h1>GET Credit Card</h1>';
try {
    // CArd id 2 => CARD-72U57472B3613723VKXFO5OA
    // Card id 3 => CARD-0Y723068NH051793HKXFO7ZA
    $creditCard = \PayPal\Api\CreditCard::get('CARD-0Y723068NH051793HKXFO7ZA', $apiContext);
} catch (Exception $ex) {
    display($ex);
    //ResultPrinter::printError("Get Credit Card", "Credit Card", $card->getId(), null, $ex);
    exit(1);
}
//ResultPrinter::printResult("Get Credit Card", "Credit Card", $card->getId(), null, $card);
display($creditCard);
return $creditCard;
示例#8
0
// # Get Credit Card Sample
// The CreditCard resource allows you to
// retrieve previously saved CreditCards,
// by sending a GET request to the URI
// '/v1/vault/credit-card'
// The following code takes you through
// the process of retrieving a saved CreditCard
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard;
// The cardId can be obtained from a previous save credit
// card operation. Use $card->getId()
$cardId = "CARD-5BT058015C739554AKE2GCEI";
/// ### Retrieve card
// (See bootstrap.php for more on `ApiContext`)
try {
    $card = CreditCard::get($cardId, $apiContext);
} catch (\PPConnectionException $ex) {
    echo "Exception: " . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);
}
?>
<html>
<body>
	<div>Retrieving credit card: <?php 
echo $cardId;
?>
</div>
	<pre><?php 
var_dump($card);
?>