# Making a Credit Card Charge

## How to Make a Simple Charge

### Required Data

| Data you will need to make a Simple Charge | Where to get this data from                                                                                                                                                      |                                                                                                                                                                     |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The Amount to charge                       | A screenflow field or data stored in a record.                                                                                                                                   | <p><br></p>                                                                                                                                                         |
| 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 Salesforce. |
| Named Credential                           | API Name of the Credential you created with the Configuration steps above. Note: Cardknox has 2 named credentials. Some processes require specifying one of them, and some both. | This will generally be constant, but can vary if you are using Paytram with multiple gateway accounts                                                               |
| <p>External Credential</p><p><br></p>      | API Name of the Credential you created with the Configuration steps above.                                                                                                       | This will usually 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 usually be constant on all Flows you create to use with Paytram                                                                                           |

### &#x20;Logical next steps to do in your Screenflow

| If the transaction was successful                                                               | If the transaction failed       |
| ----------------------------------------------------------------------------------------------- | ------------------------------- |
| Create a record in Salesforce that represents the charge that was made (e.g., a Payment record) | Show the error message response |

\
Create your Flow
----------------

{% hint style="warning" %}
**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’)**
{% endhint %}

{% hint style="warning" %}
For Stripe Users: Due to technical limitations, we cannot charge a card without saving it first. See the below sections on saving cards. You can then charge the saved card. If desired, you can delete the saved card each time post transaction.
{% endhint %}

Start by creating a new Screen Flow. Collect the required data for the charge, either from record data, or screen input fields.

Below is a sample Flow that illustrates getting an Opportunity record (which has an Amount field that can be used as the Amount to Charge), and displaying a screen with user inputs for the credit card number. This screen can also contain additional, optional info like Billing Name and Address, if desired, or a currency field to enter the Amount to Charge manually. The Paytram Charge Card Subflow is mapped with data, and will return a response with a success or error message. If successful, a payment record is created. If not, an error message is displayed on the Flow Screen.<br>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf8a1HuBly97tk-OGjnWpqcjn4SVl-KBjPFbnidf8LnHoqZpTQfTbupT7iMMEQxX56BJIF5LZbCrlKz5YsOSwQG_0PsUdVlRi3VbmCYAQzlvGHNI_ucYEUhOX6Ohe0HNcgy0BcwKLz6fzU23xSrH5A?key=esorVVMR3D62PAiYn8TVv7VL" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Tip: You may want to add additional fields in your payment form such as Name, address, email, etc. You can add fields for that data and prefill the fields from a related Contact or Account record.
{% endhint %}

You will need to add two of the custom Paytram components to this Screen Flow. These components are found in the Custom Components section of the Flow components area (the left side of every Flow Screen page).&#x20;

The **Credit Card Input** (prefixed with the name of the gateway) component displays the secure credit card, expiration, and CVV fields on the page. These fields will not display on the Screen Flow builder canvas, but will display in debug or when the Flow runs. This component  trades the raw credit card information with a secure token, which is used in the next step in the Flow to make the actual charge.

{% hint style="danger" %}
Make sure you are using the correct Credit Card input component. It is called "**{Gateway name} Credit Card Input**". Do not use the "**Secure Credit Card Input**" component.  That one is used for Paytram free only.
{% endhint %}

The **Paytram Process Card Button** component is used in place of the default ‘Next’ or ‘Make Charge’ button so you will likely want to place it on the bottom of the screen. This button is responsible for securely trading the raw credit card information for the secure token, and then navigating to the next step of the Flow.

1. Add both components to your Screen Flow.

   <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe7P3CHB4dQ1PyY3U-0TJReBaxZWdtGUsxZbDcdRLBNFX_gwaiSGEh6q0p72tga47I4wYierjN6LVHGr_sZloutVDlfNyIBNZutkJB6ww1eG6GC3yjsrO-yYS-OFsAURT-8dM5oKxVTHvD7O_2s9w?key=esorVVMR3D62PAiYn8TVv7VL" alt=""><figcaption></figcaption></figure>

2. You must configure the **Paytram Process Card Button** component first.

3. The API Name is your choice. This example uses ‘**processbtn**’.

4. The Label will be the text of the button. For example, ‘**Process Card**’, ‘**Next**’, or ‘**Make Charge**’ are suitable labels, but you can enter any term appropriate to your use case.

5. Navigate on Click checkbox: This is almost always set to **True** (GlobalConstant.True). It sets the behavior of the Flow to move to the next Flow Component when clicked.\
   \
   ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcUf6EB6HPcBJmg7ilmhRIX0X5YrWtIBeTW98Xq8ZAN_wyGBUHiAg00_ZDI5XzJCDqx5eTMri-SWN5LA0umzuE3qMhCbR-1vrKKYd9UgGwXZAJ4lAqCGE4YQRTFFcXb_tQLg08kahrhHKrkUIyhzik?key=esorVVMR3D62PAiYn8TVv7VL)

6. Next, configure the **Credit Card Input** component.

7. The API Name is your choice. In this example, the API Name is ‘**credit\_card\_fields**’. Keep note of the name as you will need it for the next step in your Flow.

8. External Named Credential: Example ‘**AcceptBlueExternal**’, ‘**AuthorizenetExternal**’, or '**stripeExternal**' (<mark style="color:red;">**Important**</mark>: Use the exact API **Name**, not the Label.) Refer to the Configuration section above if you are unsure about the correct name.

9. Named Credential Paytram: Example ‘**AcceptBluePaytram**’ or ‘**AuthorizenetPaytram**’ or '**stripePaytram**' (Important: Use the exact API Name, not the Label.) Refer to the Configuration section above if you are unsure about the correct name.

10. Action: The process card button component.‘Action’. The first part of this will be the API name of the Process Card Button component lat you named earlier. For example, ‘**processbtn.action**’.

11. Label: Credit Card field label (Optional)

12. Using Sandbox: **True** or **False** depending on whether you are using a Sandbox.\
    \
    ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfUAxeySRt0sBWErCYl_VqaHITlAl9prbsEx4ovTvdKudXfkgTjAmskENEBE8eJ3knDbT13sHGWvfyjNfAJktHcLGJZgVTMeh4hkZ8E9-HOBXr9WMrnwtqecUdGo5SunuyU10y_BYMyY6nIWzVJ1P0?key=esorVVMR3D62PAiYn8TVv7VL)<br>

13. Because you will use the **Paytram Process Card Button** instead of the standard ‘Next’ or ‘Finish’ button, configure the **Flow Footer** to hide the standard button.

14. Once you have completed the fields, click **Done**.

{% hint style="info" %}
Tip: You may want to store the values used for credentials as Flow Variables or Constants so they can be reused in future components in this Flow. This is valuable for complex flows that handle many scenarios.
{% endhint %}

### Transacting the charge

To transact the credit card charge, you will next configure the **Charge Card/ACH** subflow and map its fields.  *Note: The actual name of the subflow is prefixed with the gateway name- so you will see something like '**Paytram - Accept Blue - Charge Card/ACH**')*

1. Add the **Charge Card/ACH** Subflow to your Flow canvas below your Screen Flow element. Map the Output fields as follows:
2. **CC\_CreditCardToken**: This is the output token of the Credit Card Input component you configured in the previous step. In this example, the API name is ‘credit\_card\_fields’, therefore the path is All Resources > creditcardscreen > credit\_card\_fields > Credit Card Token.\ <br>

   <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdkzx-Z2DoKsRzcEulJNjTex6setbJmrPo2zTUG3RWvvkAJ_reHfUUxKh0w7n4Evnmb_jKxm5417Mz5urgSlhWZvFtDcFqB7HfeKgrhimki_VTKKZd8Bb374gOx0xTjr1zJ1dSoUuY8YsKpIsqddHE?key=esorVVMR3D62PAiYn8TVv7VL" alt=""><figcaption></figcaption></figure>
3. **Info\_Amount**: This maps the value for the amount you want to charge. This may be sourced from a previous step in the screenflow or directly from a record, depending on how you designed the Flow.
4. **Info\_CardorACHorAUTH**: Enter ‘**Card**’ or ‘**ACH**’ or ‘**AUTH**, depending on whether you want to charge a Credit Card, charge an ACH method, or charge (capture) a previously made Credit Card Authorization. *To make an AUTH transaction (Authorize)  instead of a charge (Capture),* [*see here.*](https://fast-track-digital.gitbook.io/paytram-documentation/making-charges/making-a-credit-card-charge/making-a-credit-card-authorization)
5. **Info\_NamedCredential**: Enter the API name of the Named credential. In this example, ‘**AcceptBlue**’.

   <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdBLhimzQ4L_J2yieO6u3iVkGTIa4f7amFvG7oLgEUUfk-TATsCM0qnR1KVoLsxm52ajcPviDC_-FxRG6iYzYibqAlA_WR35hh8v0-6kbw-KZLzcykkhvkWwBxBvKr2vJETzpdPlRZpwmPiCBlaIJw?key=esorVVMR3D62PAiYn8TVv7VL" alt=""><figcaption></figcaption></figure>
6. The other ‘**Info\_**’ fields are self-explanatory and optional.

{% hint style="info" %}
It is good practice to map the address fields for the AVS match that helps with security and results in lower credit card fees. As needed, you  map name, address, phone, email, etc. to pass those fields to the gateway. As mentioned above, You can source that data from screenflow input fields, or directly from records utilizing the standard Get Records component.
{% endhint %}

## Handling the Response

When the Flow runs and returns a response from the Gateway, it will contain the following Values.

| Field            | Type    | Notes                                                                                                                              |
| ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| WasError         | Boolean | True or False if there was and Error processing the transaction                                                                    |
| ErrorMessage     | Text    | The error message returned from the Gateway                                                                                        |
| TransactionID    | Text    | If succesful, the transaction ID will appear here.                                                                                 |
| GatewayLogRecord | Record  | A record created with every call to the gateway (charge, refund, save card, etc), that can be used for auditing and record keeping |

Use these values to update or create records according to your workflow needs.<br>

{% hint style="info" %}
Tip: You will likely want to add additional functions to the Flow. For example, you might want to add a step to create a Salesforce Payment Record if the payment was successful or you might want to display an Error on a Screen Component if it wasn’t.&#x20;

It is important to store the **Transaction ID** with the payment record, so it can be used in the future for Voids or Refunds. It is good practice to reference the **Gateway Log i**n a lookup field on the payment record as well.
{% endhint %}
