All docs This doc
Skip to end of metadata
Go to start of metadata


Overview

The following operations allow you to work with credit cards in the PayPal vault. Click an operation name to see details on how to use it.

For a sample proxy service the illustrates how to work with credit cards, see Sample configuration.

OperationDescription

storeCreditCardDetails

Stores credit card details

deleteCreditCardDetails

Deletes details of a credit card

lookupCreditCardDetails

Looks up details of a credit card

Operation details

This section provides details on each of the operations.

Storing credit card details 

Below is the request for storing credit card details. 

storeCreditCardDetails
<paypal.storeCreditCardDetails>
	<payerId>{$ctx:payerId}</payerId>    
	<number>{$ctx:number}</number>
    <type>{$ctx:type}</type>
 	<cvv2>{$ctx:cvv2}</cvv2>
    <expireMonth>{$ctx:expireMonth}</expireMonth>
    <expireYear>{$ctx:expireYear}</expireYear>
   	<firstName>{$ctx:firstName}</firstName>
    <lastName>{$ctx:lastName}</lastName>
	<billingAddress>{$ctx:billingAddress}</billingAddress>
</paypal.storeCreditCardDetails>

Properties

  • payerId: Required - A unique identifier that you can assign and track when storing a credit card or using a stored credit card.
  • number: Required - Containing credit card number.
  • type: Required - Credit card type. Valid types are visamastercarddiscover, and amex.
  • cvv2: Required - 3-4 digit card validation code.
  • expireMonth: Required - Expiration month with no leading zero. Acceptable values are 1 through 12.
  • expireYear : Required - 4-digit expiration year.
  • firstName: Required - Cardholder’s first name. 25 characters max.
  • lastName: Required - Cardholder’s last name.
  • billingAddress: Required - Billing address associated with card.
Sample request

Following is a sample REST request that can be handled by the storeCreditCardDetails operation.

Sample request for storeCreditCardDetails
{"apiUrl":"https://api.sandbox.paypal.com",
  "accessToken":"B74EO4MjpnBsKVJ4YJ8BTB2KHnEDnDnofWmKkMZu2hc",
 "payerId": "user1234",
 "type":"visa",
 "number":"4417119669820331",
 "expireMonth":"11",
 "expireYear":"2018",
 "firstName":"Betsy",
 "lastName":"Buyer",
 "billingAddress":{
                "line1": "111 First Street",
                "city": "Saratoga",
                "state": "CA",
                "postal_code": "95070",
                "country_code": "US",
                "phone":"1234556"
              }
  }

For more information on the billingAddress property, see: https://developer.paypal.com/webapps/developer/docs/api/#address-object-for-payments

Related PayPal documentation

https://developer.paypal.com/webapps/developer/docs/api/#store-a-credit-card

Deleting stored credit card details 

Use this operation to delete details of a credit card.

deleteCreditCardDetails
<paypal.deleteCreditCardDetails>
	<id>{$ctx:cardId}</id>
</paypal.deleteCreditCardDetails>

Properties

  • id: Required - Credit card ID.
Sample request

Following is a sample REST request that can be handled by the deleteCreditCardDetails operation.

Sample request for deleteCreditCardDetails
{
  "apiUrl":"https://api.sandbox.paypal.com",
  "accessToken":"uBMdhxyLxCi8dJztjRCLvoXIzlJ.Fq81tQ8vBYlvXwI",
  "cardId":"CARD-93S57297CX224500YKL2MIXQ"
}

Related PayPal documentation

https://developer.paypal.com/webapps/developer/docs/api/#delete-a-stored-credit-card

Looking up stored credit card details 

 Use this operation to look up details of a credit card by its ID.

lookupCreditCardDetails
<paypal.lookupCreditCardDetails>
	<id>{$ctx:id}</id>
</paypal.lookupCreditCardDetails>

Properties

  • id: Required - Credit card ID
Sample request

Following is a sample REST request that can be handled by the lookupCreditCardDetails operation.

Sample request for lookupCreditCardDetails
{
"apiUrl":"https://api.sandbox.paypal.com",
"accessToken":"uBMdhxyLxCi8dJztjRCLvoXIzlJ.Fq81tQ8vBYlvXwI",
"id":"CARD-1XU77818DK8407512KKSWJOY"
}

Related PayPal documentation

https://developer.paypal.com/webapps/developer/docs/api/#look-up-a-stored-credit-card

Sample configuration

Following is a sample proxy service that illustrates how to connect to PayPal with the init operation and use the storeCreditCardDetails operation. The sample request for this proxy can be found in storeCreditCardDetails sample request. You can use this sample as a template for using other operations in this category.

As a best practice, create a separate sequence for handling the response payload for errors. In the following sample, this sequence is "faultHandlerSeq".

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="storeCreditCardDetails"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">
         <property name="apiUrl" expression="json-eval($.apiUrl)"/>
         <property name="accessToken" expression="json-eval($.accessToken)"/>
         <property name="number" expression="json-eval($.number)"/>
         <property name="type" expression="json-eval($.type)"/>
         <property name="expireMonth" expression="json-eval($.expireMonth)"/>
         <property name="expireYear" expression="json-eval($.expireYear)"/>
         <property name="payerId" expression="json-eval($.payerId)"/>
         <property name="cvv2" expression="json-eval($.cvv2)"/>
         <property name="firstName" expression="json-eval($.firstName)"/>
         <property name="lastName" expression="json-eval($.lastName)"/>
         <property name="billingAddress" expression="json-eval($.billingAddress)"/>
         <paypal.init>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
            <accessToken>{$ctx:accessToken}</accessToken>
         </paypal.init>
         <paypal.storeCreditCardDetails>
            <number>{$ctx:number}</number>
            <type>{$ctx:type}</type>
            <expireMonth>{$ctx:expireMonth}</expireMonth>
            <expireYear>{$ctx:expireYear}</expireYear>
            <payerId>{$ctx:payerId}</payerId>
            <cvv2>{$ctx:cvv2}</cvv2>
            <firstName>{$ctx:firstName}</firstName>
            <lastName>{$ctx:lastName}</lastName>
            <billingAddress>{$ctx:billingAddress}</billingAddress>
         </paypal.storeCreditCardDetails>
         <filter source="$axis2:HTTP_SC" regex="^[^2][\d][\d]">
            <then>
               <property name="ERROR_CODE" expression="$axis2:HTTP_SC"/>
               <switch source="$axis2:HTTP_SC">
                  <case regex="401">
                     <property name="ERROR_MESSAGE" value="Unauthorized"/>
                  </case>
                  <case regex="404">
                     <property name="ERROR_MESSAGE" value="Not Found"/>
                     <property name="error_description" expression="json-eval($.message)"/>
                  </case>
                  <case regex="400">
                     <property name="ERROR_MESSAGE" value="Bad Request"/>
                     <property name="error_description" expression="json-eval($.message)"/>
                  </case>
               </switch>
               <sequence key="faultHandlerSeq"/>
            </then>
         </filter>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>
                                
  • No labels