Saving Cards in Salesforce
The screenshots and names of Components and Fields were taken on an installation that was using the ‘Accept Blue’ gateway. Other gateways screens and components will be similar but a bit different, and the names of the fields will be specific to the gateway you are configuring for (eg. ‘Authorize.net Credit Card Fields Component’ instead of ‘Accept Blue Credit Card Fields Component’)
Required Data
Tokenized credit card number
Output from the Paytram Credit Card Input custom Flow component
The raw credit card info is entered into a special protected field and traded for a secure token. This token is used to process the transaction through Paytram.
Named Credential
API Name of the Credential you created with the Configuration steps above.
This will generally be constant, but can vary if you are using Paytram with multiple gateway accounts
External Credential
API Name of the Credential you created with the Configuration steps above.
This will be constant on all Flows you create to use with Paytram
Paytram External Credential
API Name of the Credential you created with the Configuration steps above.
This will be constant on all Flows you create to use with Paytram
Account, Contact or other record to relate the card to
Customer Profile ID
A Customer Profile ID field is installed with Paytram on the Contact object, but you can create your own field to store this data on Account or any other object that you’d like to use to represent the customer being charged.
Record to store the saved card info to
You can use the Payment Method object that is installed with Paytram, or any object you prefer that has the proper fields to store the saved card information
Logical next steps to do in your Screenflow
Create a record in Salesforce that represents the charge that was made (e.g., a Payment record)
Show the error message response
Saving Cards
Cards – or more specifically a customer profile ID and payment profile ID that represent cards– are typically stored as records in an object. This enables multiple cards to be associated with a Contact or an Account. You can either use the Payment Method object that is included with Paytram or use your own object. If you choose to create your own object, you can see which fields are needed by referencing the Payment Method object.
Here is an example of a Payment Method record displaying the Gateway Info. This record is associated with the Contact record as a Related object.
Understanding Customers and Payment Profiles
It is important to understand that saved cards in the gateway are associated in a hierarchy under an entity called Customers. A Customer represents the Cardholder or Company making the payments. The Customer will have its own record and ID (named Customer Profile ID), and can have one or more Payment Methods. Each payment method has its own record and ID as well (named Payment Profile ID). Paytram mirrors that behavior so that each saved payment method will reference the Gateway Customer Profile ID and Payment Method ID.



Creating your Screen Flow
To securely save a card or an ACH payment method from the Contact or Account record so that it can be used for future payments, create a Save Card Screen Flow using Paytram elements, then launch the Flow from the Contact or Account record to save the card relative to that Contact or Account. You may also choose to give users the option to save a card whilst making a payment.
Paytram includes a field called Customer Profile ID on the Contact object. This field is used to store the Customer Profile ID that is generated the first time a customer is created in the gateway. You will reference this field to determine if the Customer has already been created in the Gateway (in which case only the Payment Method needs to be created in the Gateway) or if both the Customer and the Payment Method need to be created in the Gateway.
Just as you would do if making a charge, design a Screen Flow with credit card input fields. You can pre-fill the fields for name, address, etc. from the Contact record to the Screen Flow fields, or choose to map those values directly to the Save Customer Subflow. You will also want to check if the Customer Profile ID field has a value. If so, you will want to use that value in your Flow when creating a Payment Method and skip the Create Customer step (which would have otherwise created a new Customer Profile ID). Below are the steps for creating that Flow.
Use a Get Records element and create a resource for the Contact ID that you want to relate to the saved payment method.
- Add a Screen element to the canvas and configure it with your input fields like Name, Amount to Charge, etc. 
- Add the Credit Card Input custom component to your Screen.. This component outputs a token for the credit card. Configure the fields: 
- API Name: This is your choice. 
- External Named Credential: ‘AcceptBlueExternal’ (or the API name you chose when you created it.) 
- Named Credential Paytram: ‘AcceptBluePaytram’ (or the API name you created it.) 
- Action: Pass in the action output for the Process Card Component. 
- Label: Enter a label for the component or leave blank. 
- Using Accept Blue Sandbox: As appropriate, set this Global Constant to ‘True’ or ‘False’. 
 
- Add the Paytram Process Card Button to the Screen Flow and configure the fields. 
- API Name: Your choice or ‘‘button’ 
- Label: Your choice or ‘Save Card’. 
- Navigate on Click: Set to ‘True’. 
- Set Component Visibility: Always. 
 
- Click Done. 
 
- Next, add a Decision element to the canvas to check if the Contact’s Customer Profile ID field is null. 
- If null, continue to update the Contact record and create a Customer Profile ID. (See Step 4.) 
- If not null, store the value of the Customer Profile ID in a variable and proceed to creating the Payment Method. 
 
- If the Contact does not have an Accept Blue Customer Profile ID, you can use Paytram components to update the Contract record and then save the card using the Save Card Flow using Paytram components. Under your ‘No’ Decision path, add the Paytram – AcceptBlue - Save Customer Subflow and map the following fields: 
- Info_FirstName: From the Screen Flow or Contact record. 
- Info_LastName: From the Screen Flow or Contact record. 
- Info_NamedCredential: ‘AcceptBlue’. 
- The Contact’s Salesforce ID (optional). 
- Check the Manually Assign Variables checkbox. Then: 
- Create text variables for the Error Message and Customer Profile ID responses. 
- Create a record variable for the GatewayLogRecord that is created when the charge card transaction is made. 
 
- Create a boolean variable for the WasError response. This is a true/false value that tells you if the transaction was successful or not. 
 
Now that the Customer Profile ID is either created - or previously created and retrieved - you can move on to creating the Payment Method in Accept Blue.
Follow the instructions below
You cannot save a payment method directly using the card token. Instead follow these directions.
- After saving the customer, create a $1 authorization using the PayTram - Usaepay - Authorize Card subflow. 
- Retrieve back the Transaction ID from the response 
- Follow the instructions below to use the Save Payment Method subflow. - Instead of mapping the CC_CreditToken, you will map the Auth_TransactionId field with the Transaction ID you received from the $1 step. 
 
- Continue mapping the other fields as described below. 
Saving the Payment Method
- Add the Save Payment Method Subflow to your Save Card Flow. 
- Map the following fields: 
- Info_FirstName: From Screen Flow or Contact record. 
- Info_LastName: From Screen Flow or Contact record. 
- Info_NamedCredential: ‘AcceptBlue’ 
- CC_CreditCardToken: The output Token of the Credit Card fields component. (Navigate to that Screen Flow component and you will see the Token value to select). 
- Info_CustomerProfileID: The newly created or retrieved Customer Profile ID. 
- Optionally, map the Info_Street and Info_Zip fields as well. 
- If saving an ACH method instead of a credit card, set the Info_SaveACH switch to ‘Included’ and map the following fields: 
- ACH Account Number 
- Account Type (checking or savings) 
- Routing number fields (These 3 fields are mapped instead of the CC_CreditCardToken) 
 
 
- Check the Manually Assign Variables checkbox. 
- Create text variables for the Error Message and Payment Profile ID responses 
- Create a record variable for the GatewayLogRecord that is created when the charge card transaction is made. 
- Create a boolean variable for the WasError response. This is a true/false value that tells you if the transaction was successful or not. 
 
- Use a Create Records element to save the payment method as a record. Use the values from the newly created Gateway Log Record you have just mapped in the Save Payment Method Subflow. You need to follow this process because certain data, like the card's last four digits, expiration date, and other information, was not directly accessible by Salesforce when it was entered in the Secure Credit Card Input component. Instead, it is stored in the Gateway Log Record, which is created when the payment method is saved to the Gateway. 
In the Create Records element, assign the following field values:
- Payment method name: Input any value. Paytram installs a Flow that will rename the payment method with an appropriate name in the format {Contact Name} | Credit Card or ACH | Credit Card Type | Expiration Date. You can see this on the Payment Method record page: 
- Active: True 
- Contact: the Contact’s Salesforce ID 
- Payment Profile ID: The ID that was generated by the Gateway 
- Customer Profile ID: The ID that was generated by the Gateway 
- Type: Credit Card or ACH 
- Payment Gateway: Accept Blue 
- First and Last Name: The Cardholder name 
- Account Type: Gateway Log > Account Type 
- Expiration Date: Gateway Log > Expiration Date 
- Last Four: Create a new formula variable to compute the last four characters of the Gateway Log > Card/Account Number to use for this field. 
- The card is now successfully saved. If you want to charge the card now with an initial amount, follow the below steps, starting from step 3. 
- Save the Flow. 
Last updated
