سؤال

So I'm playing around with the API, I've successfully created a credit card token.

stdClass Object
(
    [id] => CARD-5SK44268VP850653PKMZB22Y
    [state] => ok
    [type] => visa
    [number] => xxxxxxxxxxxx0331
    [expire_month] => 11
    [expire_year] => 2018
    [first_name] => Mary
    [last_name] => Shopper
    [valid_until] => 2017-03-25T00:00:00Z
    [create_time] => 2014-03-26T00:20:59Z
    [update_time] => 2014-03-26T00:20:59Z
    [links] => Array
        (
            [0] => stdClass Object
                (
                    [href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-5SK44268VP850653PKMZB22Y
                    [rel] => self
                    [method] => GET
                )

            [1] => stdClass Object
                (
                    [href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-5SK44268VP850653PKMZB22Y
                    [rel] => delete
                    [method] => DELETE
                )

            [2] => stdClass Object
                (
                    [href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-5SK44268VP850653PKMZB22Y
                    [rel] => patch
                    [method] => PATCH
                )

        )

)

I'm aware I can update and delete this if I remember the id, but what if I don't remember the ID to reference the card. How can I view all the credit cards I've created. If I forget the ID? It bothers me that I can create them and have them stuck theoretically on Paypal's server forever without a way to delete it through a console or any commands to bring me a list of them? Where exactly do the cards go? Do they disappear into the ether?

Is it possible to get a list of credit cards I've stored?

هل كانت مفيدة؟

المحلول

Any time a credit card is processed on PayPal's platform they save that data in their servers. Of course, they're fully PCI compliant so this isn't an issue for them (or buyers).

That card data is saved and related back to your transaction accordingly so that when you send a request to do a new payment using that card ID it can look it up and process it. So as far as the "where", it's simply PayPal's servers.

To my knowledge you cannot obtain a list of your saved cards.

نصائح أخرى

The Credit Card resource allows you to retrieve all previously saved Credit Cards.

API used for it: '/v1/vault/credit-cards'

There are many possible filters that you could apply to it. For complete list, please refere to developer docs here.

use PayPal\Api\CreditCard;

"params = array(
    "sort_by" => "create_time",
    "sort_order" => "desc",
    "merchant_id" => "Your Merchant ID"  // Filtering by MerchantId set during CreateCreditCard.
);"



 cards = CreditCard::all($params, $apiContext);

The Credit Card resource allows you to delete saved Credit Cards, You must have its unique creditCardId to perform delete

API used for it: /v1/vault/credit-card/{}

The CreditCard resource allows you to update previously saved Credit Cards. Please note that Credit card id is required for it.

API used for it: PATCH /v1/vault/credit-cards/

use PayPal\Api\CreditCard;
use PayPal\Api\Patch;

You could update a credit card by sending patch requests. Each path object would have a specific detail in the object to be updated.

pathOperation = new Patch();
pathOperation->setOp("replace")
    ->setPath('/expire_month')
    ->setValue("12");

To add Another Patch Object, You could set more than one patch while updating a credit card.

"pathOperation2 = new Patch();
pathOperation2->setOp('add')
->setPath('/billing_address')
->setValue(json_decode('{
        "line1": "111 First Street",
        "city": "Saratoga",
        "country_code": "US",
        "state": "CA",
        "postal_code": "95070"
    }'));

pathRequest = new \PayPal\Api\PatchRequest();
pathRequest->addPatch($pathOperation)
->addPatch($pathOperation2);"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top