Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/sms.picotech.app/public_html/vendor/paypal/rest-api-sdk-php/sample/doc/vault/ drwxr-xr-x |
Viewing file: Select action/file-type: vault/CreateCreditCard.php <?php require __DIR__ . '/../bootstrap.php';
use PayPal\Api\CreditCard; CreditCardA resource representing a credit card that is to be stored with PayPal. $card = new CreditCard();
$card->setType("visa")
->setNumber("4917912523797702")
->setExpireMonth("11")
->setExpireYear("2019")
->setCvv2("012")
->setFirstName("Joe")
->setLastName("Shopper"); Additional InformationNow you can also store the information that could help you connect your users with the stored credit cards. All these three fields could be used for storing any information that could help merchant to point the card. However, Ideally, MerchantId could be used to categorize stores, apps, websites, etc. ExternalCardId could be used for uniquely identifying the card per MerchantId. So, combination of "MerchantId" and "ExternalCardId" should be unique. ExternalCustomerId could be userId, user email, etc to group multiple cards per user. $card->setMerchantId("MyStore1");
$card->setExternalCardId("CardNumber123" . uniqid());
$card->setExternalCustomerId("123123-myUser1@something.com"); For Sample Purposes Only. $request = clone $card; Save cardCreates the credit card as a resource
in the PayPal vault. The response contains
an 'id' that you can use to refer to it
in future payments.
(See bootstrap.php for more on try {
$card->create($apiContext);
} catch (Exception $ex) { NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Create Credit Card", "Credit Card", null, $request, $ex);
exit(1);
} NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Create Credit Card", "Credit Card", $card->getId(), $request, $card);
return $card; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0039 ]-- |
Create Credit Card Sample
You can store credit card details securely with PayPal. You can then use the returned Credit card id to process future payments. API used: POST /v1/vault/credit-card