# safecharge-psp

> Safecharge Node JS Payment SDK

Latest version **1.5.1** (published 2018-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install safecharge-psp
pnpm add safecharge-psp
yarn add safecharge-psp
bun add safecharge-psp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2018-06-01 |
| First published | 2018-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 78.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Arslan Pervaiz, Khan Muhammad |
| Maintainers | coinifyaps |
| Keywords | payment, refund, payment 3D, Void Payment, UPO, Secure, GetPaymentURL, Payout, APMs, Validate MDN Notification |

## Links

- npm: https://www.npmjs.com/package/safecharge-psp
- Repository: https://github.com/CoinifySoftware/safecharge-psp
- Homepage: https://github.com/CoinifySoftware/safecharge-psp#readme
- Issues: https://github.com/CoinifySoftware/safecharge-psp/issues
- npm.io page: https://npm.io/package/safecharge-psp

## Dependencies (7)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [request](https://npm.io/package/request.md) ^2.83.0
- [node-datetime](https://npm.io/package/node-datetime.md) ^2.0.3
- [@coinify/currency](https://npm.io/package/@coinify/currency.md) ^1.0.1
- [console-log-level](https://npm.io/package/console-log-level.md) ^1.4.0
- [request-promise-native](https://npm.io/package/request-promise-native.md) ^1.0.5
- [@coinify/eslint-config-coinify](https://npm.io/package/@coinify/eslint-config-coinify.md) ^1.1.5

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.5.1 (latest) — 2018-06-01
- 1.5.0 — 2018-04-24
- 1.4.0 — 2018-04-17
- 1.3.0 — 2018-03-27
- 1.1.0 — 2018-03-23
- 1.0.0 — 2018-01-09

## README

# SafeCharge-psp

_Module for integration safeCharge as a payment service provider (PSP)_

`Constructor call`

```javascript
// 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_    | CVV of Card
`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

```javascript
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_    | CVV of Card
`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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
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  | CVV of Card

The async method returns a response object.

#### Response Example

```javascript
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

```javascript
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

```javascript
{
"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

```javascript
{
"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.
&rarr;`firstName`  | String  | `Optional` | First name of card owner
&rarr;`lastName`  | String  | `Optional` | Last name of card owner
&rarr;`email`  | String  | `Optional` | Email address of card owner
&rarr;`country`  | String  | _Required_ | ISO country code of Card owner's Billing Address
`urlDetails`  | Object  | `Optional`  | Object with information of URLs
&rarr;`successUrl`   | String  | `Optional`  | Redirect URL in success scenario
&rarr;`failureUrl`  | String  | `Optional`  |  Redirect URL in failure scenario
&rarr;`pendingUrl`  | String  | `Optional`  |  Redirect URL in pending scenario
&rarr;`notificationUrl`  | String  | `Optional`  |  DM Notifications call back URL
&rarr;`backUrl`  | String  | `Optional`  |  Redirect URL in back scenario

The async method returns a response object.

#### Response Example

```javascript
{
"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

```javascript
{
  "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: {}"
}
```

---
_Source: https://npm.io/package/safecharge-psp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
