1.5.1 • Published 7 years ago

safecharge-psp v1.5.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

SafeCharge-psp

Module for integration safeCharge as a payment service provider (PSP)

Constructor call

// create object and pass configuration detail
var SafeChargePayment = new SafeCharge({
    "merchantId": 'YOUR_MERCHANTID',
    "merchantSiteId": 'YOUR_MERCHANT_SITEID',
    "merchantSecretKey": 'YOUR_MERCHANT_SECRET_KEY',
    "merchantHostURL": 'ppp-test.safecharge.com'
});

config option arguments

ArgumentTypeDefaultDescription
merchantSiteIdStringRequiredSafeCharge payment identifier MERCHANT_SITE_ID
merchantIdStringRequiredSafeCharge payment identifier MERCHANT_ID
merchantSecretKeyStringRequiredSafeCharge payment identifier SECRET_KEY
merchantHostURLStringRequiredSafeCharge payment base url eg (ppp-test.safecharge.com)

Exposed medthods defination

Payments

dynamic3d: dynamic 3D

options arguments

ArgumentTypeDefaultDescription
clientUniqueIdStringRequiredClient Unique Id for request identification
sessionTokenStringRequiredSession Token recievied by safecharge
transactionObjectRequiredPayment detail
amountStringRequiredAmount which you want to process
currencyStringRequiredCurrency in which you are sending amount
referenceStringRequiredAbout payment detail
deviceDetailsObjectRequiredObject with information about the client initiating the payment. Only the ip field is required.
deviceTypeStringRequiredClient Device Type
deviceNameStringRequiredClient device Name
deviceOSStringRequiredClient user agent
browserStringRequiredbrowser of client
ipAddressStringRequiredIP address of client
cardDataObjectRequiredObject with information about Card holder.
CVVStringstringRequiredCVV of Card
ccTempTokenStringRequiredccTempToken generated by payment handler
userPaymentOptionObjectRequiredObject with information about Card holder.
userPaymentOptionIdStringRequiredUserPaymentOptionId is given by safecharge
CVVStringRequiredCard CVV number
billingAddressObjectRequiredObject with information about the client initiating the payment.
firstNameStringRequiredFirst name of card owner
lastNameStringRequiredLast name of card owner
emailStringRequiredEmail address of card owner
countryStringRequiredISO country code of Card owner's Billing Address
notificationUrlStringRequiredURL where you get response of dynamic response detail

For payment with CCTEMPTOKEN then you will add cardData () object if UPO then userPaymentOptionId object

The async method returns a response object.

Example

var response ={ paRequest: 'eJxVUuakrtBXWzVsM5L7085vzVBpr0+t2o98Pm/xHHrZ',
acsUrl: 'https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/',
threeDFlow: '1',
orderId: '224036843',
transactionStatus: 'APPROVED',
gwErrorCode: 0,
gwExtendedErrorCode: 0,
userPaymentOptionId: '',
externalTransactionId: '',
transactionId: '101509990458',
authCode: '',
merchantDetails: { customField1: '1', customField2: '2', customField3: '3' },
sessionToken: 'a5935660-df8c-48ce-b119-e861ec5cf990',
clientUniqueId: '100000000007',
internalRequestId: 40810103,
status: 'SUCCESS',
errCode: 0,
reason: '',
merchantId: '7583429810138495724',
merchantSiteId: '140263',
version: '1.0',
clientRequestId: '2017112034020202' };

Read dynamic 3D Response

Read dynamic3D response and get paRequest post the Pares to acsUrl with additional param of term URL

Post data to acsUrl with PaReq and TermUrl value for bank page

If there is no acsUrl in response thats mean card is not 3D secure enrolled and you need to make Payment3D request without it

payment3D: Payment 3D

options arguments

ArgumentTypeDefaultDescription
clientUniqueIdStringRequiredclient Unique Id Received by dynamic3D Response
clientRequestIdStringRequiredclientRequestId Received by dynamic3D Response
sessionTokenStringRequiredSession Token recievied by safecharge
transactionObjectRequiredpayment detail
orderIdStringRequiredorder ID Received by dynamic3D Response
transactionTypeStringRequiredit will be Auth or Sale
paResponseStringRequiredit received on URL by ACSURL form submition response
amountStringRequiredAmount which you want to process
currencyStringRequiredcurrency in which you are sending amount
referenceStringRequiredAbout payment detail
deviceDetailsObjectRequiredObject with information about the client initiating the payment. Only the ip field is required.
deviceTypeStringRequiredClient Device Type
deviceNameStringRequiredClient device Name
deviceOSStringRequiredClient user agent
browserStringRequiredbrowser of client
ipAddressStringRequiredIP address of client
cardDataObjectRequiredObject with information about Card holder.
cardHolderNameStringRequiredCard holder name of Card
CVVStringstringRequiredCVV of Card
ccTempTokenStringRequiredccTempToken generated by payment handler
userPaymentOptionObjectRequiredObject with information about Card holder.
userPaymentOptionIdStringRequiredUserPaymentOptionId is given by safecharge
CVVStringRequiredCard CVV number
billingAddressObjectRequiredObject with information about the client initiating the payment.
firstNameStringRequiredFirst name of card owner
lastNameStringRequiredLast name of card owner
emailStringRequiredEmail address of card owner
countryStringRequiredISO country code of Card owner's Billing Address
notificationUrlStringRequiredURL where you get response of dynamic response detail

For payment with CCTEMPTOKEN then you will add cardData () object if UPO then userPaymentOptionId object

The async method returns a response object.

Response Example

var response= { eci: '5',
orderId: '224036843',
transactionStatus: 'APPROVED',
gwErrorCode: 0,
gwExtendedErrorCode: 0,
userPaymentOptionId: '',
externalTransactionId: '',
transactionId: '101509990493',
authCode: '111800',
merchantDetails: { customField1: '1', customField2: '2', customField3: '3' },
sessionToken: 'a5935660-df8c-48ce-b119-e861ec5cf990',
clientUniqueId: '100000000006',
internalRequestId: 40811553,
status: 'SUCCESS',
errCode: 0,
reason: '',
merchantId: '7583429810138495724',
merchantSiteId: '140263',
version: '1.0',
clientRequestId: '2017112034020202' };

refundTransaction: Refund Transaction

options arguments

ArgumentTypeDefaultDescription
clientUniqueIdStringRequiredclient Unique Id Received by payment3D Response
clientRequestIdStringRequiredclient Request Id Received by payment3D Response
transactionObjectRequiredtransaction detail
relatedTransactionIdStringRequiredrelated Transaction Id by payment3D Response
authCodeStringRequiredauthCode provided by payment3D Response
amountStringRequiredAmount which you want to process
currencyStringRequiredcurrency in which you are sending amount
commentStringRequireddetail about refund
notificationUrlStringRequiredURL where you get response of refund detail

The async method returns a response object.

Response Example

var response ={ transactionId: '101509994389',
externalTransactionId: '',
gwErrorCode: 0,
gwExtendedErrorCode: 0,
transactionStatus: 'APPROVED',
authCode: '111812',
clientUniqueId: '100000000006',
internalRequestId: 40968073,
status: 'SUCCESS',
errCode: 0,
reason: '',
merchantId: '7583429810138495724',
merchantSiteId: '140263',
version: '1.0',
clientRequestId: '2017112034020202' };

voidTransaction: Void Transaction

options arguments

ArgumentTypeDefaultDescription
internalPaymentIdStringRequiredInternal Payment ID in merchant System
externalIdStringRequiredExternal ID of SafeCharge System
authCodeStringRequiredAuthCode for that particular transaction
amountIntegerRequiredSubunit of amount which you want to process
currencyStringRequiredCurrency in which you are sending amount

The async method returns a response object.

Response Example

var response ={
"merchantId": 8263015379487437770,
"merchantSiteId": "39",
"internalRequestId": 45,
"clientRequestId": "100",
"transactionId": "8498764859",
"externalTransactionId": "",
"status": "SUCCESS",
"transactionStatus": "APPROVED",
"authCode": "8378749",
"errCode": "0",
"errReason": "",
"paymentMethodErrorCode": "0",
"paymentMethodErrorReason": "",
"gwErrorCode": "0",
"gwErrorReason": "",
"gwExtendedErrorCode": "0",
"version": "1"
};

createUser: Create User

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredclient Request for requestion identification
userDetailObjectRequiredTransaction detail
userTokenIdStringRequiredID of the user in the merchant’s system.
firstNameStringRequiredThe first name of the user being registered.
lastNameStringRequiredThe last name of the user being registered.
addressStringRequiredThe street address of the user being registered.
stateStringRequiredThe two-letter ISO state code of the user being registered.
cityStringRequiredThe city of the user being registered.
zipStringRequiredThe zip code of the user being registered.
countryCodeRequiredRequiredThe two-letter ISO country code of the user being registered.
localeStringRequiredThe user’s locale and default language, for example en_UK.
emailStringRequiredThe email address of the user being registered.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "45",
"clientRequestId": "100",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1",
"userId": "259"
};

updateUser: Update User

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userDetailObjectRequiredTransaction detail
userTokenIdStringRequiredID of the user in the merchant’s system
firstNameStringRequiredThe first name of the user being registered
lastNameStringRequiredThe last name of the user being registered
addressStringRequiredThe street address of the user being registered
stateStringRequiredThe two-letter ISO state code of the user being registered
cityStringRequiredThe city of the user being registered
zipStringRequiredThe zip code of the user being registered
countryCodeStringRequiredThe two-letter ISO country code of the user being registered
localeStringRequiredThe user’s locale and default language, for example en_UK
emailStringRequiredThe email address of the user being registered.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "47",
"clientRequestId": "101",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1",
"userId": "259"
};

getUserDetails: get User Details

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userDetailObjectRequiredTransaction detail
userTokenIdStringRequiredID of the user in the merchant’s system.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "47",
"clientRequestId": "101",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1",
"userId": "259"
};

addUPOCreditCardByTempToken: add UPO CreditCard By TempToken

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.
sessionTokenStringRequiredSession identifier returned by the getSessionToken.
ccTempTokenStringRequiredA hashed value of the credit card number.

The async method returns a response object.

Response Example

var response ={
"SessionToken":"9610a8f6-44cf-4c4f-976a-005da69a2a3b",
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "69",
"useTokenId":"",
"clientRequestId": "110",
"userPaymentOptionId": "741",
"status": " SUCCESS ",
"errCode": "0",
"reason": "",
"version": "1"
};

editUPOCC: edit UPO CC

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.
userPaymentOptionIdStringRequireduserPaymentOptionId by merchant system.
ccExpMonthStringRequiredExpiry Month of credit card.
ccExpYearStringRequiredExpiry Year of credit card.
ccNameOnCardStringRequiredName of credit card holder.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "62",
"clientRequestId": "4556",
"status": "SUCCESS",
"errCode": "0",
"reason":"",
"version": "1"
};

deleteUPO: delete UPO

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.
userPaymentOptionIdStringRequireduserPaymentOptionId by merchant system.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "60",
"clientRequestId": "108",
"status": "SUCCESS",
"errCode": "0",
"reason" : "",
"version": "1"
};

getUserUPOs: getUser UPOs

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "58",
"clientRequestId": "107",
"status":"SUCCESS",
"errCode": "0",
"reason" : "",
"version": "1",
"paymentMethods": [ {
"userPaymentOptionId": "741",
"paymentMethodName":"cc_card",
"upoName":"Credit Card",
"upoRegistrationDate":"",
"upoStatus": "enabled",
"expiryDate": "",
"billingAddress":{
"firstName": "some first name",
"lastName": "some last name",
"phone": "972502457558",
"address": "some street",
"zip": "",
"city": "some city",
"countryCode": "GB",
"state": "",
"email": "someemail@somedomain.com",
"county":""
},
"upoData": {
"cardType": "",
"ccCardNumber": "4****1111",
"ccCardNumberHash":"68bfb396f35af3876fc509665b3dc23a0930aab1",
"ccExpMonth": "12",
"ccExpYear": "24",
"ccNameOnCard": "John Smith",
"ccToken" :"",
"brand": "visa",
"uniqueCC": "aL+zlvNa84dvxQlmWz3COgkwqrE=",
"bin": "411111",
"last4Digits": ""
}
},
{
"userPaymentOptionId": "742",
"paymentMethodName":"apmgw_expresscheckout",
"upoName": "Paypal",
"upoRegistrationDate":"",
"upoStatus ": "suspended",
"expiryDate": "",
"billingAddress":{
"firstName": "some first name",
"lastName": "some last name",
"address": "some street",
"phone": "972502457558",
"zip": "",
"city": "some city",
"country": "GB",
"state": "",
"email": "someemail@somedomain.com",
"county":""
},
"upoData": {
"account_id": "user@mail.com"
}
}]
};

suspendUPO: suspend UPO

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.
userPaymentOptionIdStringRequireduserPaymentOptionId by merchant system.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "67",
"clientRequestId": "109",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1"
};

enableUPO: enable UPO

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.
userPaymentOptionIdStringRequireduserPaymentOptionId by merchant system.

The async method returns a response object.

Response Example

var response ={
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"internalRequestId": "67",
"clientRequestId": "109",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1"
};

cardTokenization: card Tokenization

options arguments

ArgumentTypeDefaultDescription
clientRequestIdStringRequiredID of the API request in the merchant system
userTokenIdStringRequiredID of the user in the merchant’s system.
cardDataObjectRequiredObject with information about Card holder.
cardNumberStringRequiredCard number of Card
cardHolderNameStringRequiredCard holder name of Card
expirationMonthStringRequiredExpirationMonth of Card
expirationYearStringRequiredExpirationYear of Card
CVVStringstringCVV of CardCVV of Card

The async method returns a response object.

Response Example

var response ={
"sessionToken": "9610a8f6-44cf-4c4f-976a-005da69a2a3b",
"internalRequestId": "866",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1.0",
"ccTempToken": "65432",
"isVerified":"TRUE"
};

getSessionToken: get Session Token

Response Example

var response ={
"sessionToken": "9610a8f6-44cf-4c4f-976a-005da69a2a3b",
"merchantId": "427583496191624621",
"merchantSiteId": "142033",
"clientRequestId": "1484759782197",
"internalRequestId": "866",
"status": "SUCCESS",
"errCode": "0",
"reason": "",
"version": "1.0"
};

getAPMs: get Alternate Payment Methods

The async method returns a response object.

Response Example

{
"sessionToken": "",
"merchantId": "",
"merchantSiteId": "",
"clientRequestId": "",
"internalRequestId": "",
"paymentMethods": [{
"paymentMethod": "cc_card",
"paymentMethodDisplayName": [{
"language": "en",
"message": "Credit Card"
}],
"isDirect": "true",
"countries": ["US", "DE"],
"currencies": ["USD"],
"logoURL": "",
"fields": [{
"name": "ccCardNumber",
"regex": "",
"type": "text",
"validationmessage": [{
"language": "en",
"message": "Invalid Card Number"
}],
"caption": [{
"language": "en",
"message": "Card Number"
},
{
"name": "ccExpMonth",
"regex": "",
"type": "text",
"validationmessage": [{
"language": "en",
"message": "Invalid Expiration Month"
}],
"caption": [{
"language": "en",
"message": "Card Expiration Month"
},
{
"name": "ccExpYear",
"regex": "",
"type": "text",
"validationmessage": [{
"language": "en",
"message": "Invalid Expiration Year"
}],
"caption": [{
"language": "en",
"message": "Card Expiration Year"
},
{
"name": "ccNameOnCard",
"regex": "",
"type": "text",
"validationmessage": [{
"language": "en",
"message": "Invalid Name on Card"
}],
"caption": [{
"language": "en",
"message": "Cardholder name as it appears on your credit card"
}]
}
]
}
],
"status": "",
"errCode": "",
"reason": "",
"version": ""
}

payout: Payout to deposited & non-deposited cards

options arguments

ArgumentTypeDefaultDescription
userTokenIDStringRequiredUserTokenID of user from UPO
amountStringRequiredAmount that you want to payout
currencyStringRequiredThe two-letter ISO language code of the user being registered.

The async method returns a response object.

Response Example

{
"merchantId": "8263015379487437770",
"merchantSiteId": "39",
"userTokenId": "487106",
"clientUniqueId": "12345",
"clientRequestId": "1484759782197",
"internalRequestId": "866",
"transactionId": "8498764859",
"externalTransactionId": "",
"status": "SUCCESS",
"transactionStatus": "APPROVED",
"userPaymentOptionId": "12442",
"errCode": "0",
"reason": "",
"paymentMethodErrorCode": "0",
"paymentMethodErrorReason": "",
"gwErrorCode": "0",
"gwErrorReason": "",
"gwExtendedErrorCode": "0",
"version": "1"
}

getPaymentUrl: Get hosted page payment URL

options arguments

ArgumentTypeDefaultDescription
internalPaymentIdStringRequiredInternal payment ID in merchant System
userIdStringRequiredID of the user in the merchant’s system
amountintegerRequiredSubunit of amount that user will pay
currencyStringRequiredThe two-letter ISO language code of the user being registered.
referenceStringRequiredAbout payment detail
billingAddressObjectRequiredObject with information about the client initiating the payment.
firstNameStringOptionalFirst name of card owner
lastNameStringOptionalLast name of card owner
emailStringOptionalEmail address of card owner
countryStringRequiredISO country code of Card owner's Billing Address
urlDetailsObjectOptionalObject with information of URLs
successUrlStringOptionalRedirect URL in success scenario
failureUrlStringOptionalRedirect URL in failure scenario
pendingUrlStringOptionalRedirect URL in pending scenario
notificationUrlStringOptionalDM Notifications call back URL
backUrlStringOptionalRedirect URL in back scenario

The async method returns a response object.

Response Example

{
"redirectUrl": "https://ppp-test.safecharge.com/ppp/purchase.do?numberofitems=1&country=US&merchantLocale=en_US&city=&theme_id=New+Template+2018-01-10+10%3A01%3A46&county=&discount=0&item_name_1=CY213&customData=&merchant_id=7583&userid=101&isNative=1&phone1=&error_url=https%3A%2F%2Fwww.safecharge.com&shipping=0&payment_method_mode=&checksum=2e362c35015f02748c38a8568f5b58cec218bdd4d152f518ecy=USD&promoCode=&user_token=auto&state=&first_name=Arslan&email=arslan.bn1%40gmail.com&payment_method=&success_url=https%3A%2F%2Fwww.safecharge.com&zip=&productId=&customSiteName=&merchant_site_id=140263&address1=&item_shipping_1=&pending_url=https%3A%2F%2Fwww.safecharge.com&back_url=https%3A%2F%2Fwww.safecharge.com&skip_billing_tab=&last_name=Pervaiz&encoding=UTF-8&total_tax=0.0&notify_url=https%3A%2F%2Foawebdev.demovopium.com%2Fmobapp_co%2Fsms%2Fnotifyterm%2F&version=4.0.0&user_token_id=101&item_discount_1=&total_amount=100.0&skip_review_tab=&handling=0&item_quantity_1=1&item_amount_1=100&",
"raw": '{}'
}

validateDMNCallback: Validate Direct Merchant Notifications Callbacks(DMN)

options arguments

ArgumentTypeDefaultDescription
bodyobjectRequiredCallback request body

This method returns a validation result.

parsePayment: Parse the DMN Callback response

options arguments

ArgumentTypeDefaultDescription
bodyobjectRequiredCallback request body

This method returns a parse payment object

{
  "internalPaymentId": '12344',
  "externalId": '1512574818',
  "amount": 15408,
  "currency": 'USD',
  "state": 'completed',
  "eci": '5',
  "authCode": '111519',
  "card": {
     "token": 'UQA1AGQANQAwAGwAdQBmAEoATAAxACMAawBiAFsATgBfAEEAdABxAFoAPQBcAHgAKgBPAFAASABZAFcAVwAtAEMARwBnAHoATABdADIALgBDAFMAMwA=',
     "bin": '401200',
     "lastFour": '0014',
     "cardBrand": 'VISA',
     "expiryDate": '1128'
  },
  "raw: {}"
}