Load SDK configuration for the resource. This intialization code can be done as Init Servlet.
Sample showing how to create a CreditCard.
A resource representing a credit card that can be used to fund a payment.
Retrieve the access token from OAuthTokenCredential by passing in ClientID and ClientSecret It is not mandatory to generate Access Token on a per call basis. Typically the access token can be generated once and reused within the expiry window
Pass in a ApiContext
object to authenticate
the call and to send a unique request id
(that ensures idempotency). The SDK generates
a request id if you do not pass one explicitly.
Use this variant if you want to pass in a request id
that is meaningful in your application, ideally
a order id.
String requestId = Long.toString(System.nanoTime();
APIContext apiContext = new APIContext(accessToken, requestId ));
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.
CreateCreditCard Sample
Using the 'vault' API, you can store a Credit Card securely on PayPal. You can use a saved Credit Card to process a payment in the future. The following code demonstrates how can save a Credit Card on PayPal using the Vault API. API used: POST /v1/vault/credit-card