Tokenization ensures that no sensitive card data ever needs to touch your server so your integration can operate in a PCI compliant way. If any card data were to pass through or be stored on your server, you would be responsible for any PCI DSS guidelines and audits that are required.
Github Repository
PaymentezJS is a library that allows developers to easily connect to the Paymentez CREDITCARDS API
View working example >
Installation
You will need to include jQuery and both payment_stable.min.js
and payment_stable.min.css
into your webpage specifying "UTF-8" like charset.
<script src="https://code.jquery.com/jquery-1.11.3.min.js" charset="UTF-8"></script>
<link href="https://cdn.paymentez.com/ccapi/sdk/payment_stable.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.paymentez.com/ccapi/sdk/payment_stable.min.js" charset="UTF-8"></script>
Usage
For working examples of using PaymentezJS, see the examples folder of this project.
Using the Paymentez Form
Any elements with the class payment-form
will be automatically converted into a basic credit card input with the expiry date and CVC check.
The easiest way to get started with PaymentForm is to insert the snippet of code:
<div class="payment-form" id="my-card" data-capture-name="true"></div>
To get a Card
object from the PaymentForm
, you ask the form for its card.
var myCard = $('#my-card');
var cardToSave = myCard.PaymentForm('card');
if(cardToSave == null){
alert("Invalid Card Data");
}
If the returned Card
is null, error states will show on the fields that need to be fixed.
Once you have a non-null Card
object from the widget, you can call addCard.
Init library
You should initialize the library.
/**
* Init library
*
* @param env_mode `prod`, `stg`, `local` to change environment. Default is `stg`
* @param payment_client_app_code provided by Paymentez.
* @param payment_client_app_key provided by Paymentez.
*/
Payment.init('stg', 'PAYMENT_CLIENT_APP_CODE', 'PAYMENT_CLIENT_APP_KEY');
addCard
addCard converts sensitive card data to a single-use token which you can safely pass to your server to charge the user.
/* Add Card converts sensitive card data to a single-use token which you can safely pass to your server to charge the user.
*
* @param uid User identifier. This is the identifier you use inside your application; you will receive it in notifications.
* @param email Email of the user initiating the purchase. Format: Valid e-mail format.
* @param card the Card used to create this payment token
* @param success_callback a callback to receive the token
* @param failure_callback a callback to receive an error
* @param payment_form Payment Form instance
*/
Payment.addCard(uid, email, cardToSave, successHandler, errorHandler, myCard);
var successHandler = function(cardResponse) {
console.log(cardResponse.card);
if(cardResponse.card.status === 'valid'){
$('#messages').html('Card Successfully Added<br>'+
'status: ' + cardResponse.card.status + '<br>' +
"Card Token: " + cardResponse.card.token + "<br>" +
"transaction_reference: " + cardResponse.card.transaction_reference
);
}else if(cardResponse.card.status === 'review'){
$('#messages').html('Card Under Review<br>'+
'status: ' + cardResponse.card.status + '<br>' +
"Card Token: " + cardResponse.card.token + "<br>" +
"transaction_reference: " + cardResponse.card.transaction_reference
);
}else{
$('#messages').html('Error<br>'+
'status: ' + cardResponse.card.status + '<br>' +
"message Token: " + cardResponse.card.message + "<br>"
);
}
submitButton.removeAttr("disabled");
submitButton.text(submitInitialText);
};
var errorHandler = function(err) {
console.log(err.error);
$('#messages').html(err.error.type);
submitButton.removeAttr("disabled");
submitButton.text(submitInitialText);
};
The third argument to addCard is a Card object. A Card contains the following fields:
- number: card number as a string without any separators, e.g. '4242424242424242'.
- holder_name: cardholder name.
- expiry_month: integer representing the card's expiration month, e.g. 12.
- expiry_year: integer representing the card's expiration year, e.g. 2013.
- cvc: card security code as a string, e.g. '123'.
getSessionId
The Session ID is a parameter Paymentez use for fraud purposes.
Call this method if you want to Collect your user's Device Information.
var session_id = Payment.getSessionId();
Once you have the Session ID, you can pass it to your server to charge the user.
PaymentForm Complete Reference
Manual Insertion
If you wish to manually alter the fields used by PaymentForm to add additional classes or set the input field placeholder, name or id. you can pre-populate the form fields as show below.
This could be helpful in case you want to Render the Form in another Language (by default the Form is Rendered in Spanish), or to reference some input by name or id.
For example if you want to render the form in English and add a custom class to the card-number
<div class="payment-form">
<input class="card-number my-custom-class" name="card-number" placeholder="Card number">
<input class="name" id="the-card-name-id" placeholder="Card Holders Name">
<input class="expiry-month" name="expiry-month">
<input class="expiry-year" name="expiry-year">
<input class="cvc" name="cvc">
</div>
Select Fields
You can determinate the fields to show on your form.
Field |
Description |
data-capture-name |
Card Holder Name |
data-capture-email |
User Email |
data-capture-cellphone |
User Cellphone |
data-icon-colour |
Icons color |
data-use-dropdowns |
Use dropdowns to set the Card Expiration Date |
data-exclusive-types |
Define allowed card types |
data-invalid-card-type-message |
Define a custom message to show for invalid card types |
The 'data-use-dropdowns' can solve an issue with the expiration mask in not so recent mobiles.
Integrate in the form is so simple like this
<div class="payment-form"
id="my-card"
data-capture-name="true"
data-capture-email="true"
data-capture-cellphone="true"
data-icon-colour="#569B29"
data-use-dropdowns="true">
Specific the card types
If you want specify the card types allowed in the form, like Exito or Alkosto. You can do something like next example.
when a card type not allowed is seted, the form is reset, block the inputs and show a message, the default message is
Tipo de tarjeta invalida para está operación.
<div class="payment-form"
id="my-card"
data-capture-name="true"
data-exclusive-types="ex,ak"
data-invalid-card-type-message="Tarjeta invalida. Por favor ingresa una tarjeta Exito / Alkosto."
>
Follow this link to see all card types allowed by Paymentez.
Reading Values
PaymentForm provides functionality allowing you to read the form field values directly with JavaScript. This can be useful if you wish to submit the values via Ajax.
Create a PaymentForm element and give it a unique id (in this example my-card
)
<div class="payment-form" id="my-card" data-capture-name="true"></div>
The javascript below demonstrates how to read each value of the form into local variables.
var myCard = $('#my-card');
var cardNumber = myCard.PaymentForm('cardNumber');
var cardType = myCard.PaymentForm('cardType');
var name = myCard.PaymentForm('name');
var expiryMonth = myCard.PaymentForm('expiryMonth');
var expiryYear = myCard.PaymentForm('expiryYear');
var fiscalNumber = myCard.PaymentForm('fiscalNumber');
var validationOption = myCard.PaymentForm('validationOption');
Functions
To call a function on a PaymentForm element, follow the pattern below.
Replace the text 'function' with the name of the function you wish to call.
$('#my-card').PaymentForm('function')
The functions available are listed below:
Function |
Description |
card |
Get the card object |
cardNumber |
Get the card number entered |
cardType |
Get the type of the card number entered |
name |
Get the name entered |
expiryMonth |
Get the expiry month entered |
expiryYear |
Get the expiry year entered |
fiscalNumber |
Get the fiscal number |
validationOption |
Get the validation option |
CardType Function
The cardType
function will return one of the following strings based on the card number entered.
If the card type cannot be determined an empty string will be given instead.
Card Type |
AMEX |
Diners |
Diners - Carte Blanche |
Discover |
JCB |
Mastercard |
Visa |
Visa Electron |
Exito |
Static functions
If you just want to perform simple operations without the PaymentForm form, there are a number of static functions provided
by the PaymentForm library that are made available.
Card Type from Card Number
var cardNumber = '4242 4242 4242 4242'; // Spacing is not important
var cardType = PaymentForm.cardTypeFromNumber(cardNumber);
Cleaning and Masking
// var formatMask = 'XXXX XXXX XXXX XXXX'; // You can manually define an input mask
// var formatMask = 'XX+X X XXXX XXXX XXXX'; // You can add characters other than spaces to the mask
var formatMask = PaymentForm.CREDIT_CARD_NUMBER_VISA_MASK; // Or use a standard mask.
var cardNumber = '424 2424242 42 42 42';
var cardNumberWithoutSpaces = PaymentForm.numbersOnlyString(cardNumber);
var formattedCardNumber = PaymentForm.applyFormatMask(cardNumberWithoutSpaces, formatMask);
Masks
Variable Name |
Mask |
PaymentForm.CREDIT_CARD_NUMBER_DEFAULT_MASK |
XXXX XXXX XXXX XXXX |
PaymentForm.CREDIT_CARD_NUMBER_VISA_MASK |
XXXX XXXX XXXX XXXX |
PaymentForm.CREDIT_CARD_NUMBER_MASTERCARD_MASK |
XXXX XXXX XXXX XXXX |
PaymentForm.CREDIT_CARD_NUMBER_DISCOVER_MASK |
XXXX XXXX XXXX XXXX |
PaymentForm.CREDIT_CARD_NUMBER_JCB_MASK |
XXXX XXXX XXXX XXXX |
PaymentForm.CREDIT_CARD_NUMBER_AMEX_MASK |
XXXX XXXXXX XXXXX |
PaymentForm.CREDIT_CARD_NUMBER_DINERS_MASK |
XXXX XXXX XXXX XX |
PaymentForm.CREDIT_CARD_NUMBER_EXITO_MASK |
XXXX XXXX XXXX XXXX |
Card Expiry Validation
The expiry month can be in the range: 1 = January to 12 = December
In the case of 'Exito' cards, they do not have an expiration date
var month = 3;
var year = 2019;
var valid = PaymentForm.isExpiryValid(month, year);
The expiry month and year can be either and integer or a string.
var month = "3";
var year = "2019";
var valid = PaymentForm.isExpiryValid(month, year);
The expiry year can be either 4 digits or 2 digits long.
var month = "3";
var year = "19";
var valid = PaymentForm.isExpiryValid(month, year);
Card Validations Options
There are three card validation options
Validation Option |
Description |
PaymentForm.AUTH_CVC |
Card validation by cvc, the most common option |
PaymentForm.AUTH_NIP |
Card validation by nip (Available only by Exito cards) |
PaymentForm.AUTH_OTP |
Card validation by otp (Available only by Exito cards) |
Github Repository
Paymentez Android SDK is a library that allows developers to easily connect to the Paymentez CREDITCARDS API

Installation
Android Studio (or Gradle)
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add this line to your app's build.gradle
inside the dependencies
section:
implementation 'com.github.paymentez:paymentez-android:v1.3.4'
ProGuard
If you're planning on optimizing your app with ProGuard, make sure that you exclude the Paymentez bindings. You can do this by adding the following to your app's proguard.cfg
file:
-keep class com.paymentez.android.** { *; }
Usage
Using the CardMultilineWidget
You can add a widget to your apps that easily handles the UI states for collecting card data.
First, add the CardMultilineWidget to your layout.
<com.paymentez.android.view.CardMultilineWidget
android:id="@+id/card_multiline_widget"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
You can customize the view with this tags:
app:shouldShowPostalCode="true"
app:shouldShowPaymentezLogo="true"
app:shouldShowCardHolderName="true"
app:shouldShowScanCard="true"
In order to use any of this tags, you'll need to enable the app XML namespace somewhere in the layout.
xmlns:app="http://schemas.android.com/apk/res-auto"
To get a Card
object from the CardMultilineWidget
, you ask the widget for its card.
Card cardToSave = cardWidget.getCard();
if (cardToSave == null) {
Alert.show(mContext,
"Error",
"Invalid Card Data");
return;
}
If the returned Card
is null, error states will show on the fields that need to be fixed.
Once you have a non-null Card
object from the widget, you can call addCard.
Init library
You should initialize the library on your Application or in your first Activity.
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.paymentez.android.Paymentez;
import com.paymentez.examplestore.utils.Constants;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* Init library
*
* @param test_mode false to use production environment
* @param paymentez_client_app_code provided by Paymentez.
* @param paymentez_client_app_key provided by Paymentez.
*/
Paymentez.setEnvironment(Constants.PAYMENTEZ_IS_TEST_MODE, Constants.PAYMENTEZ_CLIENT_APP_CODE, Constants.PAYMENTEZ_CLIENT_APP_KEY);
// In case you have your own Fraud Risk Merchant Id
//Paymentez.setRiskMerchantId(1000);
// Note: for most of the devs, that's not necessary.
}
}
addCard
addCard converts sensitive card data to a single-use token which you can safely pass to your server to charge the user.
Paymentez.addCard(mContext, uid, email, cardToSave, new TokenCallback() {
public void onSuccess(Card card) {
if(card != null){
if(card.getStatus().equals("valid")){
Alert.show(mContext,
"Card Successfully Added",
"status: " + card.getStatus() + "\n" +
"Card Token: " + card.getToken() + "\n" +
"transaction_reference: " + card.getTransactionReference());
} else if (card.getStatus().equals("review")) {
Alert.show(mContext,
"Card Under Review",
"status: " + card.getStatus() + "\n" +
"Card Token: " + card.getToken() + "\n" +
"transaction_reference: " + card.getTransactionReference());
} else {
Alert.show(mContext,
"Error",
"status: " + card.getStatus() + "\n" +
"message: " + card.getMessage());
}
}
//TODO: Create charge or Save Token to your backend
}
public void onError(PaymentezError error) {
Alert.show(mContext,
"Error",
"Type: " + error.getType() + "\n" +
"Help: " + error.getHelp() + "\n" +
"Description: " + error.getDescription());
//TODO: Handle error
}
});
The first argument to addCard is mContext (Context).
+ mContext. Context of the Current Activity
The second argument to addCard is uid (String).
+ uid Customer identifier. This is the identifier you use inside your application; you will receive it in notifications.
The third argument to addCard is email (String).
+ email Email of the customer
The fourth argument to addCard is a Card object. A Card contains the following fields:
- number: card number as a string without any separators, e.g. '4242424242424242'.
- holderName: cardholder name.
- expMonth: integer representing the card's expiration month, e.g. 12.
- expYear: integer representing the card's expiration year, e.g. 2013.
- cvc: card security code as a string, e.g. '123'.
- type:
The fifth argument tokenCallback is a callback you provide to handle responses from Paymentez.
It should send the token to your server for processing onSuccess, and notify the user onError.
Here's a sample implementation of the token callback:
Paymentez.addCard(
mContext, uid, email, cardToSave,
new TokenCallback() {
public void onSuccess(Card card) {
// Send token to your own web service
MyServer.chargeToken(card.getToken());
}
public void onError(PaymentezError error) {
Toast.makeText(getContext(),
error.getDescription(),
Toast.LENGTH_LONG).show();
}
}
);
addCard
is an asynchronous call – it returns immediately and invokes the callback on the UI thread when it receives a response from Paymentez's servers.
getSessionId
The Session ID is a parameter Paymentez use for fraud purposes.
Call this method if you want to Collect your user's Device Information.
String session_id = Paymentez.getSessionId(mContext);
Once you have the Session ID, you can pass it to your server to charge the user.
Client-side validation helpers
The Card object allows you to validate user input before you send the information to Paymentez.
validateNumber
Checks that the number is formatted correctly and passes the Luhn check.
validateExpiryDate
Checks whether or not the expiration date represents an actual month in the future.
validateCVC
Checks whether or not the supplied number could be a valid verification code.
validateCard
Convenience method to validate card number, expiry date and CVC.
Example apps
There is an example app included in the repository:
- PaymentezStore project is a full walk-through of building a shop activity, including connecting to a back end.
https://cdn.paymentez.com/apps/paymentez-example-1-2-7.apk
To build and run the example app, clone the repository and open the project.
Getting started with the Android example app
Note: the app require an Android SDK and Gradle to build and run.
Building and Running the PaymentezStore
Before you can run the PaymentezStore application, you need to provide it with your Paymentez Credentials and a Sample Backend.
- If you don't have any Credentials yet, please ask your contact on Paymentez Team for it.
- Head to https://github.com/paymentez/example-java-backend and click "Deploy to Heroku" (you may have to sign up for a Heroku account as part of this process). Provide your Paymentez Server Credentials
PAYMENTEZ_SERVER_APP_CODE
and PAYMENTEZ_SERVER_APP_KEY
fields under 'Env'. Click "Deploy for Free".
- Open the project on Android Studio.
- Replace the
PAYMENTEZ_CLIENT_APP_CODE
and PAYMENTEZ_CLIENT_APP_KEY
constants in Constants.java with your own Paymentez Client Credentials.
- Replace the
BACKEND_URL
variable in the Constants.java file with the app URL Heroku provides you with (e.g. "https://my-example-app.herokuapp.com")
- Run the Project.
Important Note: if you only have one APP_CODE, please asume that it's your PAYMENTEZ_SERVER_APP_CODE
. So you need to ask your contact on Paymentez Team for your PAYMENTEZ_CLIENT_APP_CODE
.
Github Repository
Requirements
Version <= 1.4.x
- iOS 9.0 or Later
- Xcode 9
Version >= 1.5.x
- iOS 9.0 or Later
- Xcode 10
Framework Dependencies:
Accelerate
AudioToolbox
AVFoundation
CoreGraphics
CoreMedia
CoreVideo
Foundation
MobileCoreServices
OpenGLES
QuartzCore
Security
UIKit
CommonCrypto (Just for version 1.4)
Project Configuration
- ObjC in other linker flags in target
- lc++ in target other linker flags
- Disable Bitcode
INSTALLATION
Carthage
If you haven't already, install the latest version of Carthage
Add this to the Cartfile:
git "https://github.com/paymentez/paymentez-ios.git"
For Beta Versions:
git "https://github.com/paymentez/paymentez-ios.git" "master"
ObjC configuration
Set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
In Build Phases -> Embed Frameworks Uncheck "Copy Only When Installing"
Manual Installation(Recommended)
SDK is a dynamic framework (More Info) so you have to build each version for the desire target (simulator and device). To make the integration easy, you can follow these instructions in order to have just one Universal .framework file.
- Build the SDK and create .framework files
This will create a /build folder where there are all the necesary .framework (simulator, iphoneos and universal)
- With Target PaymentSDK selected, build the project for any iOS Simulator.
- With Target PaymentSDK selected, build the project for a physical device.
After
- With the Target PaymentezSDK-Universal, build the project for any iOS device.
- Inside the group Products -> PaymentSDK.framework -> Show in finder
- Inside the the directory of PaymentSDK.framework, CMD+up
You can see three groups, inside the group Release-iosuniversal, you'll find the PaymentSDK.framework
Or if you prefer you can download pre-compilled .framework files from Releases
- Drag the PaymentSDK.framework To your project and check "Copy Files if needed".
In Target->General : Add PaymentSDK.framework to Frameworks, Libraries, and Embedded Content
In Target->Build Settings : Validate Workspace should be YES
- Update the Build Settings with
Set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
In Build Phases -> Embed Frameworks Uncheck "Copy Only When Installing"
- If you use the Universal version and you want to upload to the appstore. Add Run Script Phase: Target->Build Phases -> + ->New Run Script Phase. And paste the following. Make sure that this build phase is added after Embed Frameworks phase.
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/PaymentSDK.framework/install_dynamic.sh"
Usage
Importing Swift
import PaymentSDK
Setting up your app inside AppDelegate->didFinishLaunchingWithOptions. You should use the Payment Client Credentials (Just ADD enabled)
PaymentSDKClient.setEnvironment("AbiColApp", secretKey: "2PmoFfjZJzjKTnuSYCFySMfHlOIBz7", testMode: true)
Types of implementation
There are 3 ways to present the Add Card Form:
- As a Widget in a Custom View
- As a Viewcontroller Pushed to your UINavigationController
- As a ViewController presented in Modal
The AddCard Form includes: Card io scan, and card validation.
Show AddCard Widget
In order to create a widget you should create a PaymentAddNativeController from the PaymentSDKClient. Then add it to the UIView that will be the container of the Payment Form. The min height should be 300 px, and whole screen as width (270px without payment logo)
Note: When you are using the Payment Form as Widget. The Client custom ViewController will be responsible for the layout and synchronization (aka Spinner or loading)
The widget can scan with your phones camera the credit card data using card.io.
let paymentAddVC = self.addPaymentWidget(toView: self.addView, delegate: nil, uid:UserModel.uid, email:UserModel.email)
Objc
[self addPaymentWidgetToView:self. addView delegate:self uid:@"myuid" email:@"myemail"];
Retrive the valid credit card from the PaymentAddNativeController (Widget):
if let validCard = paymentAddVC.getValidCard() // CHECK IF THE CARD IS VALID, IF THERE IS A VALIDATION ERROR NIL VALUE WILL BE RETURNED
{
sender?.isEnabled = false
PaymentSDKClient.createToken(validCard, uid: UserModel.uid, email: UserModel.email, callback: { (error, cardAdded) in
if cardAdded != nil // handle the card status
{
}
else if error != nil //handle the error
{
}
})
}
Objc
PaymentCard *validCard = [self.paymentAddVC getValidCard];
if (validCard != nil) // Check if it is avalid card
{
[PaymentSDKClient add:validCard uid:USERMODEL_UID email:USERMODEL_EMAIL callback:^(PaymentSDKError *error, PaymentCard *cardAdded) {
[sender setEnabled:YES];
if(cardAdded != nil) // handle the card status
{
}
else //handle the error
{
}
}];
}
Pushed to your NavigationController
self.navigationController?.pushPaymentViewController(delegate: self, uid: UserModel.uid, email: UserModel.email)
Objc
[self.navigationController pushPaymentViewControllerWithDelegate:self uid:@"myuid" email:@"mymail@mail.com"]`;
Present as Modal
self.presentPaymentViewController(delegate: self, uid: "myuid", email: "myemail@email.com")
Objc
[self presentPaymentViewControllerWithDelegate:self uid:@"myuid" email:@"myemail@email.com"];
PaymentCardAddedDelegate Protocol
If you present the Form as a viewcontroller (push and modal) you must implement the PaymetnezCardAddedDelegate Protocol in order to handle the states or actions inside the Viewcontroller. If you are using Widget implementation you can handle the actions as described above.
protocol PaymentCardAddedDelegate
{
func cardAdded(_ error:PaymentSDKError?, _ cardAdded:PaymentCard?)
func viewClosed()
}
func cardAdded(_ error:PaymentSDKError?, _ cardAdded:PaymentCard?)
is called whenever there is an error or a card is added.
func viewClosed()
Whenever the modal is closed
Scan Card
If you want to do the scan yourself, using card.io
PaymentSDKClient.scanCard(self) { (closed, number, expiry, cvv, card) in
if !closed // user did not closed the scan card dialog
{
if card != nil // paymentcard object to handle the data
{
}
})
-ObjC
[PaymentSDKClient scanCard:self callback:^(BOOL userClosed, NSString *cardNumber, NSString *expiryDate, NSString *cvv, PaymentCard *card) {
if (!userClosed) //user did not close the scan card dialog
{
if (card != nil) // Handle card
{
}
}
}];
Add Card (Only PCI Integrations)
For custom form integrations
Fields required
+ cardNumber: card number as a string without any separators, e.g. 4111111111111111.
+ cardHolder: cardholder name.
+ expuryMonth: integer representing the card's expiration month, 01-12.
+ expiryYear: integer representing the card's expiration year, e.g. 2020.
+ cvc: card security code as a string, e.g. '123'.
let card = PaymentCard.createCard(cardHolder:"Gustavo Sotelo", cardNumber:"4111111111111111", expiryMonth:10, expiryYear:2020, cvc:"123")
if card != nil // A valid card was created
{
PaymentSDKClient.add(card, uid: "69123", email: "gsotelo@globalpay.com", callback: { (error, cardAdded) in
if cardAdded != nil
{
//the request was succesfully sent, you should check the cardAdded status
}
})
}
else
{
//handle invalid card
}
ObjC
PaymentCard *validCard = [PaymentCard createCardWithCardHolder:@"Gustavo Sotelo" cardNumber:@"4111111111111111" expiryMonth:10 expiryYear:2020 cvc:@"123"];
if (validCard != nil) // Check if it is avalid card
{
[PaymentSDKClient add:validCard uid:USERMODEL_UID email:USERMODEL_EMAIL callback:^(PaymentSDKError *error, PaymentCard *cardAdded) {
[sender setEnabled:YES];
if(cardAdded != nil) // handle the card status
{
}
else //handle the error
{
}
}];
}
Secure Session Id
Debit actions should be implemented in your own backend. For security reasons we provide a secure session id generation, for kount fraud systems. This will collect the device information in background
let sessionId = PaymentSDKClient.getSecureSessionId()
Objc
NSString *sessionId = [PaymentSDKClient getSecureSessionId];
Utils
Get Card Assets
let card = PaymentCard.createCard(cardHolder:"Gustavo Sotelo", cardNumber:"4111111111111111", expiryMonth:10, expiryYear:2020, cvc:"123")
if card != nil // A valid card was created
{
let image = card.getCardTypeAsset()
}
Get Card Type (Just Amex, Mastercard, Visa, Diners)
let card = PaymentCard.createCard(cardHolder:"Gustavo Sotelo", cardNumber:"4111111111111111", expiryMonth:10, expiryYear:2020, cvc:"123")
if card != nil // A valid card was created
{
switch(card.cardType)
{
case .amex:
case .masterCard:
case .visa:
case .diners:
default:
//not supported action
}
}
Customize Look & Feel
You can customize widget colors sample
paymentAddVC.baseFontColor = .white
paymentAddVC.baseColor = .green
paymentAddVC.backgroundColor = .white
paymentAddVC.showLogo = false
paymentAddVC.baseFont = UIFont(name: "Your Font", size: 12) ?? UIFont.systemFont(ofSize: 12)
The customizable elements of the form are the following:
baseFontColor
: The color of the font of the fields
baseColor
: Color of the lines and titles of the fields
backgroundColor
: Background color of the widget
showLogo
: Enable or disable Payment Logo
baseFont
: Font of the entire form
nameTitle
: String for the custom placeholder for the Name Field
cardTitle
: String for the custom placeholder for the Card Field
invalidCardTitle
String for the error message when a card number is invalid
Building and Running the PaymentSwift
Before you can run the PaymentStore application, you need to provide it with your APP_CODE, APP_SECRET_KEY and a sample backend.
- If you haven't already and APP_CODE and APP_SECRET_KEY, please ask your contact on Payment Team for it.
- Replace the
PAYMENT_APP_CODE
and PAYMENT_APP_SECRET_KEY
in your AppDelegate as shown in Usage section
- Head to https://github.com/paymentez/example-java-backend and click "Deploy to Heroku" (you may have to sign up for a Heroku account as part of this process). Provide your Paymentez Server Credentials APP_CODE and APP_SECRET_KEY fields under 'Env'. Click "Deploy for Free".
- Replace the
BACKEND_URL
variable in the MyBackendLib.swift (inside the variable myBackendUrl) with the app URL Heroku provides you with (e.g. "https://my-example-app.herokuapp.com")
- Replace the variables (uid and email) in UserModel.swift with your own user id reference