DEV Community

Cover image for Getting Started with Rapyd Collect for Credit Cards
Kyle Pollock for Rapyd

Posted on • Edited on • Originally published at community.rapyd.net

Getting Started with Rapyd Collect for Credit Cards

By James Olaogun

The use of debit and credit cards has been on the rise, and this trend shows no signs of slowing down. Business owners who refuse to accept debit or credit card payments are likely to lose a significant amount of money, as well as potential customers.

If you want to keep up with modern customers, you must ensure that you have the systems in place to satisfy their payment needs. Thankfully, developing and configuring your own card payment processing infrastructure is easy using a payment platform like Rapyd Collect.

Rapyd Collect is a universal payment platform with a collection of APIs that businesses can use to access a wide range of customers who want to complete transactions in their preferred payment methods in their respective countries.

These payment methods include e-wallets, local and international card payments, and bank transfers; by utilizing the Rapyd Collect API, businesses may seamlessly authorize a transaction and successfully capture the authorized transaction via any of the selected payment methods.

In this article, you’ll learn about the Rapyd Collect API, its use cases, some advantages, and, most importantly, step-by-step instructions on implementing a payment processor using the Rapyd Collect API for cards.

Rapyd Collect API

The Rapyd Collect API is a set of definitions and protocols that allows you to integrate an online payment processing platform into your applications. It has a range of features, for example, it allows you to set up recurring payments, use the currency of your choice, send bulk invoices, and split payments:

  • Recurring payments: Also known as subscriptions, the recurring payments feature allows you and your customer to virtually agree to pay for products or services on a predetermined schedule. These are frequently set up as weekly, monthly, or annual payments, and your customer's credit card is charged according to the predetermined schedule via Rapyd Collect.

  • Multi-currency: The multi-currency feature allows customers to make payments to your business via Rapyd Collect using the currency of their choice. Rapyd also provides a multi-currency Client Wallet that allows your business to handle accounts in several currencies and convert between currencies.

  • Seamless invoicing: Invoices are used to request payment after a service has been completed. These can be single invoices, which request payment for a single service, or bulk (also known as mass or batch) invoices, which are a seamless way to generate several invoices for multiple entities (that is, completed services).

  • Split payments: The split payments feature allows your business to pay multiple individuals in a single operation by splitting a single payment into multiple Rapyd Wallets (usually two to ten wallets).

Advantages of Using the Rapyd Collect API

Now that you have a good understanding of what the Rapyd Collect API involves, let's look at some of its advantages, which include the collection of international and local payments, simplified account management, and security (fraud protection).

​​Collection of International and Local Payments

The Rapyd Collect API allows you to expand your business to the worldwide market, which means that anyone with internet access can do business with you and make payments from anywhere in the world.

It also allows you to accept payments in many currencies and via multiple methods, enabling you to expand your international customer base, reduce payment abandonment rates, and service your local customers without having to worry about payment issues.

Simplified Account Management

Rapyd Collect API has a portal that allows you to manage critical information you and your customers utilize. With the Rapyd portal, you can access and manage your account information, manage linked bank accounts to receive settlements, manage your wallet, convert between currencies, disburse payments to customers, and so on.

As a result, you won't have to worry about manually maintaining records of your transactions or finances.

Security

Protecting your customers' confidential (or sensitive) information and implementing secure data encryption technologies to protect against threats can be a tough challenge for your business. Rapyd Collect API comes with a Rapyd Protect, a machine learning fraud detection system. The Rapyd Hosted Check Page is PCI DSS compliant, ensuring the highest level of protection for you and your customers.

Rapyd Collect API also protects your business transactions from overdrafts, insufficient funds, and expired cards.

​​How to Use Rapyd Collect API to Accept Credit Card Payments

Now that you’ve seen some of Rapyd Collect’s benefits, the following sections present the step-by-step process of integrating card payment using the Rapyd Collect API.

Step One: ​​Create a Rapyd Account

You can skip this step if you already have a Rapyd account. However, if you’re new to Rapyd, you should first create a Rapyd Client Portal account to access everything you need to get started.

Rapyd signup page

Step Two: ​​Getting Your API Keys

To get your API keys, log in to your dashboard (if you haven't already), and then go to Developers > Credentials Details, where you’ll find your secret and access key.

Step Three: Generating a Signature For Each Request

The signature for each API request is calculated as a hash of the request payload and headers; use the formula below to generate the signature for each request.

signature = BASE64 ( HASH ( http_method + url_path + salt + timestamp + access_key + secret_key + body_string ) )

Where:

  • BASE64: is an algorithm for Base-64 encoding.
  • HASH: refers to the HMAC-SHA256 algorithm.
  • http_method: refers to the HTTP method. All in lowercase letters. (eg, post, get)
  • url_path: refers to the section of the URL after the base URI (https://api.rapyd.net). It usually begins with /v1. (eg, /v1/data/countries)
  • salt: is a random string of numbers, letters, and special characters that is typically 8-16 characters long for each request.
  • timestamp: is the time of the request, in Unix time (seconds).
  • access_key: is a unique string for each user, assigned by Rapyd. Follow the previous step to get it.
  • secret_key: is also a unique string for each user, assigned by Rapyd. Follow the previous step to get it.
  • body_string: is a valid JSON string that contains all of the request's payloads or raw data. It can be empty if the request has no payloads or raw data.

Visit the official documentation for more details, including code snippets in some popular programming languages and frameworks that demonstrate how to create request signatures, and other applicable rules in Rapyd.

Step Four: ​​Making a Request to List Payment Methods by Country

Rapyd offers hundreds of different payment and payout method types for different countries. You can get a list of payment methods available in a specific country using the List Payment Methods by Country API.

Developers can use the API by sending a get request to https://sandboxapi.rapyd.net/v1/payment_methods/country?country&currency; it includes several payloads such as:

  • country: A mandatory parameter with a string in the form of a two-letter ISO 3166-1 ALPHA-2 code for the specific country, all in uppercase.
  • currency: An optional parameter with a string in the form of a three-letter ISO 4217 code for a specific currency, all in uppercase.

Additionally, the access key, content-type, a salt string for the request signature, a signature calculated for each request individually, and a timestamp (in Unix time) for the request will all be included in the request headers.

The code sample that follows shows how to use curl to get the list of payment methods by country:

curl --location --request GET 'https://sandboxapi.rapyd.net/v1/payment_methods/country?country=US&currency=USD' \
--header 'Content-Type: application/json' \
--header 'access_key: {{rapyd_access_key}}' \
--header 'salt: {{any_random_string}}' \
--header 'signature: {{rapyd_signature}}' \
--header 'timestamp: {{rapyd_request_timestamp}}'
Enter fullscreen mode Exit fullscreen mode

The official documentation has a specific section about List Payment Methods by Country API payloads, headers, and response format; you can also find some sample code in your preferred programming language.

Step Five: ​​Making a Request to Get the Payment Method Required Fields

Once you have the list of payments available in your selected country, the next thing to do is send a get request to Get Payment Method Required Fields via https://sandboxapi.rapyd.net/v1/payment_methods/required_fields/type.

The API payload includes the type parameter, a required parameter that indicates the type of payment method. The request also requires the list of headers that was mentioned in the previous step. Additionally, the request returns a list of objects, and the name of each required field appears in the data -> fields -> name of the response.

The code sample below shows how to use curl to get the required fields for the payment method you selected:

curl --location --request GET '// Request URL: GET https://sandboxapi.rapyd.net/v1/payment_methods/required_fields/us_visa_card' \
--header 'Content-Type: application/json' \
--header 'access_key: {{rapyd_access_key}}' \
--header 'salt: {{any_random_string}}' \
--header 'signature: {{rapyd_signature}}' \
--header 'timestamp: {{rapyd_request_timestamp}}'
Enter fullscreen mode Exit fullscreen mode

The official documentation has a specific section about request payloads, header, and response format; you can also find some sample code in your preferred programming language.

Step Six: ​​Creating a Payment Request

The final step is sending a post request to the Create Payment API. This API can be used to collect payment immediately for a one-time charge, fund one or more Rapyd Wallets, start the collection process in the middle of a billing cycle relevant to a subscription, and replace a failed payment in a group payment, among other things.

The following are some things to keep in mind when using the Create Payment API:

  • Only PCI-certified clients can handle personal identifying information for cards. Alternatively, clients who are not PCI-certified can use Rapyd Checkout to collect money from a card.
  • Always ensure that the value of is_tokenizable is true before making a payment with a tokenized payment method.
  • The customer must authenticate transactions involving 3DS authentication within fifteen minutes.

The code sample below shows how to use curl to create a new payment request;

curl --location --request POST 'https://sandboxapi.rapyd.net/v1/payments' \
--header 'Content-Type: application/json' \
--header 'access_key: {{rapyd_access_key}}' \
--header 'salt: {{any_random_string}}' \
--header 'timestamp: {{rapyd_request_timestamp}}' \
--header 'signature: {{rapyd_signature}}' \
--data-raw '{
    "amount": 10,
    "currency": "USD",
    "customer": "cus_*******************",
    "payment_method": {
        "type": "us_visa_card'",
        "fields": {
            "number": "4111111111111111",
            "expiration_month": "12",
            "expiration_year": "23",
            "name": "John Doe",
            "cvv": "345"
        },
        "metadata": {
        "merchant_defined": true
    }
    },
    "capture": true
}'
Enter fullscreen mode Exit fullscreen mode

The official documentation contains a more detailed explanation of how to use the Create Payment API, its required and optional payload, and request headers; it also has some demo code in a variety of programming languages, as well as the required asynchronous webhooks.

Step Seven: ​​Activate Your Account

To use any of Rapyd's functionalities in production (to accept actual payments), you must first go through Rapyd's Know Your Business (KYB) process and receive application approval.

However, European businesses can process actual payments (in production) up to a certain amount without KYB approval, but, the payments will not be settled in their bank account until KYB is approved. The KYB steps to fully activate your account can be found in your Rapyd portal, and you can check this list of restricted businesses to confirm that you’re eligible to apply for a Rapyd account.

Finally, download and use the Rapyd Postman Collection to see a working example of all Rapyd APIs in the programming language of your choice. Note that to hit endpoints successfully, you must switch to the Rapyd Sandbox Environment in Postman and enter the values for your access and secret keys.

Conclusion

You now have a comprehensive understanding of Rapyd Collect API, including some of its use cases and benefits, as well as a step-by-step guide to getting started with and implementing Rapyd Collect for both international and local card payments.

If you own a business that serves customers from all over the world, you can start utilizing Rapid Collect right away and reap all of the benefits that come with it, including those covered in this article.

Rapyd Collect API is powered by Rapyd, a payment platform that integrates fintech into any app and simplifies the complicated world of local and international payment processing.

Businesses like e-commerce, gig platforms, remittance platforms, online lenders, and traditional banks can use Rapyd to break away from their old infrastructure and limits and use a modern infrastructure to service a wide range of customers. Businesses and customers can also conduct local and cross-border transactions in any market using Rapyd's payments network and Fintech-as-a-Service platform.

Top comments (0)