PayTabs Node.js Package makes integration with the PayTabs payment gateway very easy by providing a ready-made payment class that handles the card entry, and billing & shipping information and completes the missing details.
This article is dedicated to walking you through how to manage/manipulate both shipping and billing/customer information in this package. The following string values can be passed within the "customer_details" and "shipping_address" arrays, which are passed as the fourth and fifth parameters in sequence to the "createPaymentPage" function, as shown below:
Through out the article we will use the same concepet clarified in our How to remove/hide the billing/shipping information? solution article.
The following parameters are required to be sent within both parameters, as shown below:
let customer = {
name:"Mohammed ELRayes",
email:"elrayes@paytabs.com",
phone:"+201234567890",
street1:"dummy street, dummy building, dummy apt",
city:"Heliopolis",
state:"CAI",
country:"EG",
zip:"52121",
IP:"10.0.0.1"
}
let customer_details = [
customer.name,
customer.email,
customer.phone,
customer.street1,
customer.city,
customer.state,
customer.country,
customer.zip,
customer.IP
];
let shipping_address = customer_details;
paytabs.createPaymentPage(
paymentMethods,
transaction_details,
cart_details,
customer_details, // billing address array
shipping_address, // shipping address array
response_URLs,
lang,
paymentPageCreated
);
This "customer_details" and "shipping_details" parameters are Mandatory, not passing them would throw an exception.
The customer details are still required and must be passed, in case any of the details are missing or passed with invalid values; the cardholder will be required to enter any of the missing details on the payment page
Name
The Parameter Tag/Name | name |
Data Type | STRING |
Purpose | Indicates the customer's valid name.
|
Min | 3 |
Max | 128 |
Required | ✔ |
Email
The Parameter Tag/Name | email |
Data Type | STRING
|
Validation Rules | Valid email format |
Purpose | Indicates the customer's valid email address. Preferred not to pass the same email with every transaction, as blocking any for a fraud attempt will cause blocking your payments at all.
|
Min | - |
Max | - |
Required | ✔ |
Phone
The Parameter Tag/Name | phone |
Data Type | STRING
|
Validation Rules | Valid number + country code prefix |
Purpose | Indicates the customer's valid phone number
|
Min | - |
Max | - |
Required | ✔ |
Street1
The Parameter Tag/Name | street1 |
Data Type | STRING
|
Purpose | Indicates the customer's valid address.
|
Min | 3 |
Max | 128 |
Required | ✔ |
City
The Parameter Tag/Name | city |
Data Type | STRING
|
Purpose | Indicates the customer's valid city name.
|
Min | 3 |
Max | 128 |
Required | ✔ |
State
The Parameter Tag/Name | state |
Data Type | STRING
|
Validation Rules | ISO 3166-1 alpha-2 code (two-letter state codes) |
Purpose | Indicates the customer's valid state name.
|
Min | 2 |
Max | 2 |
Required | ✔ |
Country
The Parameter Tag/Name | country |
Data Type | STRING
|
Validation Rules | ISO 3166-1 alpha-2 code (two-letter state codes) |
Purpose | Indicates the customer's valid state name.
|
Min | 2 |
Max | 2 |
Required | ✔ |
Zip
The Parameter Tag/Name | zip |
Data Type | STRING
|
Validation Rules | Valid/related zip code |
Purpose | Indicates the customer's valid zip code.
|
Min | - |
Max | - |
Required | ✔ |
IP
The Parameter Tag/Name | ip |
Data Type | STRING
|
Validation Rules | Valid IP address |
Purpose | Indicates the customer's valid IP address.
|
Min | - |
Max | - |
Required | ❌ |