safecharge-psp

    1.5.1 • Public • Published

    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

    Argument Type Default Description
    merchantSiteId String Required SafeCharge payment identifier MERCHANT_SITE_ID
    merchantId String Required SafeCharge payment identifier MERCHANT_ID
    merchantSecretKey String Required SafeCharge payment identifier SECRET_KEY
    merchantHostURL String Required SafeCharge payment base url eg (ppp-test.safecharge.com)

    Exposed medthods defination

    Payments

    dynamic3d: dynamic 3D

    options arguments

    Argument Type Default Description
    clientUniqueId String Required Client Unique Id for request identification
    sessionToken String Required Session Token recievied by safecharge
    transaction Object Required Payment detail
    amount String Required Amount which you want to process
    currency String Required Currency in which you are sending amount
    reference String Required About payment detail
    deviceDetails Object Required Object with information about the client initiating the payment. Only the ip field is required.
    deviceType String Required Client Device Type
    deviceName String Required Client device Name
    deviceOS String Required Client user agent
    browser String Required browser of client
    ipAddress String Required IP address of client
    cardData Object Required Object with information about Card holder.
    CVV String string Required
    ccTempToken String Required ccTempToken generated by payment handler
    userPaymentOption Object Required Object with information about Card holder.
    userPaymentOptionId String Required UserPaymentOptionId is given by safecharge
    CVV String Required Card CVV number
    billingAddress Object Required Object with information about the client initiating the payment.
    firstName String Required First name of card owner
    lastName String Required Last name of card owner
    email String Required Email address of card owner
    country String Required ISO country code of Card owner's Billing Address
    notificationUrl String Required URL 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

    Argument Type Default Description
    clientUniqueId String Required client Unique Id Received by dynamic3D Response
    clientRequestId String Required clientRequestId Received by dynamic3D Response
    sessionToken String Required Session Token recievied by safecharge
    transaction Object Required payment detail
    orderId String Required order ID Received by dynamic3D Response
    transactionType String Required it will be Auth or Sale
    paResponse String Required it received on URL by ACSURL form submition response
    amount String Required Amount which you want to process
    currency String Required currency in which you are sending amount
    reference String Required About payment detail
    deviceDetails Object Required Object with information about the client initiating the payment. Only the ip field is required.
    deviceType String Required Client Device Type
    deviceName String Required Client device Name
    deviceOS String Required Client user agent
    browser String Required browser of client
    ipAddress String Required IP address of client
    cardData Object Required Object with information about Card holder.
    cardHolderName String Required Card holder name of Card
    CVV String string Required
    ccTempToken String Required ccTempToken generated by payment handler
    userPaymentOption Object Required Object with information about Card holder.
    userPaymentOptionId String Required UserPaymentOptionId is given by safecharge
    CVV String Required Card CVV number
    billingAddress Object Required Object with information about the client initiating the payment.
    firstName String Required First name of card owner
    lastName String Required Last name of card owner
    email String Required Email address of card owner
    country String Required ISO country code of Card owner's Billing Address
    notificationUrl String Required URL 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

    Argument Type Default Description
    clientUniqueId String Required client Unique Id Received by payment3D Response
    clientRequestId String Required client Request Id Received by payment3D Response
    transaction Object Required transaction detail
    relatedTransactionId String Required related Transaction Id by payment3D Response
    authCode String Required authCode provided by payment3D Response
    amount String Required Amount which you want to process
    currency String Required currency in which you are sending amount
    comment String Required detail about refund
    notificationUrl String Required URL 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

    Argument Type Default Description
    internalPaymentId String Required Internal Payment ID in merchant System
    externalId String Required External ID of SafeCharge System
    authCode String Required AuthCode for that particular transaction
    amount Integer Required Subunit of amount which you want to process
    currency String Required Currency 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

    Argument Type Default Description
    clientRequestId String Required client Request for requestion identification
    userDetail Object Required Transaction detail
    userTokenId String Required ID of the user in the merchant’s system.
    firstName String Required The first name of the user being registered.
    lastName String Required The last name of the user being registered.
    address String Required The street address of the user being registered.
    state String Required The two-letter ISO state code of the user being registered.
    city String Required The city of the user being registered.
    zip String Required The zip code of the user being registered.
    countryCode Required Required The two-letter ISO country code of the user being registered.
    locale String Required The user’s locale and default language, for example en_UK.
    email String Required The 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userDetail Object Required Transaction detail
    userTokenId String Required ID of the user in the merchant’s system
    firstName String Required The first name of the user being registered
    lastName String Required The last name of the user being registered
    address String Required The street address of the user being registered
    state String Required The two-letter ISO state code of the user being registered
    city String Required The city of the user being registered
    zip String Required The zip code of the user being registered
    countryCode String Required The two-letter ISO country code of the user being registered
    locale String Required The user’s locale and default language, for example en_UK
    email String Required The 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userDetail Object Required Transaction detail
    userTokenId String Required ID 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID of the user in the merchant’s system.
    sessionToken String Required Session identifier returned by the getSessionToken.
    ccTempToken String Required A 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID of the user in the merchant’s system.
    userPaymentOptionId String Required userPaymentOptionId by merchant system.
    ccExpMonth String Required Expiry Month of credit card.
    ccExpYear String Required Expiry Year of credit card.
    ccNameOnCard String Required Name 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID of the user in the merchant’s system.
    userPaymentOptionId String Required userPaymentOptionId 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID of the user in the merchant’s system.
    userPaymentOptionId String Required userPaymentOptionId 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID of the user in the merchant’s system.
    userPaymentOptionId String Required userPaymentOptionId 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

    Argument Type Default Description
    clientRequestId String Required ID of the API request in the merchant system
    userTokenId String Required ID of the user in the merchant’s system.
    cardData Object Required Object with information about Card holder.
    cardNumber String Required Card number of Card
    cardHolderName String Required Card holder name of Card
    expirationMonth String Required ExpirationMonth of Card
    expirationYear String Required ExpirationYear of Card
    CVV String string CVV 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

    Argument Type Default Description
    userTokenID String Required UserTokenID of user from UPO
    amount String Required Amount that you want to payout
    currency String Required The 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

    Argument Type Default Description
    internalPaymentId String Required Internal payment ID in merchant System
    userId String Required ID of the user in the merchant’s system
    amount integer Required Subunit of amount that user will pay
    currency String Required The two-letter ISO language code of the user being registered.
    reference String Required About payment detail
    billingAddress Object Required Object with information about the client initiating the payment.
    firstName String Optional First name of card owner
    lastName String Optional Last name of card owner
    email String Optional Email address of card owner
    country String Required ISO country code of Card owner's Billing Address
    urlDetails Object Optional Object with information of URLs
    successUrl String Optional Redirect URL in success scenario
    failureUrl String Optional Redirect URL in failure scenario
    pendingUrl String Optional Redirect URL in pending scenario
    notificationUrl String Optional DM Notifications call back URL
    backUrl String Optional Redirect 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

    Argument Type Default Description
    body object Required Callback request body

    This method returns a validation result.

    parsePayment: Parse the DMN Callback response

    options arguments

    Argument Type Default Description
    body object Required Callback 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: {}"
    }

    Install

    npm i safecharge-psp

    DownloadsWeekly Downloads

    8

    Version

    1.5.1

    License

    MIT

    Unpacked Size

    80.1 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar