# SMS Payment Request

![SMS Message example](https://3556089516-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbqMA3Kf8t2xEX9F6y9%2Fuploads%2FA9Kzgty9dosRyMhxDzfg%2FSMS-Payment-Request.png?alt=media\&token=9063591c-6e40-42f0-9690-40b0466dd6ce)

SMS Payment Request enables you to send a payment request to a consumer remotely, without asking the consumer any confidential information like credit card number.

The SMS message will be sent from SensePass servers, all of the countries globally are supported.

For delivery status - See "SMS" field in [#transaction-entity](https://docs.sensepass.com/sensepay/models/transaction-model#transaction-entity "mention")

Request Body:

<pre class="language-json"><code class="lang-json">{
  "timeOut": 600,
  "amount": 5500,
  "isCent": true,
  "currency": "USD",
<strong>  "apiKey": "2ooeww5ufzg3nkuf8a10gu5n695yolixlbgb042o038o58jv1rznif3o1tr6xsb1rm",
</strong>  "returnURL": "https://merchantDomain.com/thankYouPage",
  "cancelURL": "https://merchantDomain.com/cart",
  "callbackURL": "https://merchantDomain.com/sensepass/callbackEndPoint",
  "clientPhoneNumber": "+155555551234"
}
</code></pre>

## Customizing message format

Full customization of the SMS message including variables can be done using "customSmsText" field in the "/transactions/init" API.

Request Body:

```json
{
  "timeOut": 600,
  "amount": 5500,
  "isCent": true,
  "currency": "USD",
  "deviceId": "2ooeww5ufzg3nkuf8a10gu5n695yolixlbgb042o03to9bxfkr7t815i5epu8o58jv1rznif3o1tr6xsb1rm",
  "clientPhoneNumber": "+155555551234",
  "customSmsText": "%%businessName%% asks you for %%amount%%"
}
```

### Available variables:

1. businessName: Merchant name
2. locationName: Location name
3. amount: Transaction amount including currency
4. link: Full URL to payment request page
5. reason: Reason field of the transaction
6. expiration: Transaction expiration date formatted

### Using variables:

&#x20;Add %% before and after the name of the variable.

Examples:

1. %%businessName%% asks you to pay
2. Hi, you got payment request from %%businessName%%, %%locationName%% of %%amount%% - %%reason%%. Please click here to pay: %%link%%

## Creating a new transaction object (Payment Request)

<mark style="color:green;">`POST`</mark> `/transactions/init`

This API creates new payment request based on the fields below.

#### Request Body

| Name                                       | Type    | Description                                                                                                                                                                                                                                       |
| ------------------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| amount<mark style="color:red;">\*</mark>   | number  | <p>The required amount for this transaction (Cents). </p><p>If products are a part of the transaction - they are all summed up & calculated via the following formula: </p><p>(amount + vat - discount) \* quantity e.g. (10 + 1.7 - 1) \* 2.</p> |
| isCent                                     | boolean | Determines if Amount represents in cents or not                                                                                                                                                                                                   |
| timeOut                                    | number  | Time until the transaction will be timed out (seconds)                                                                                                                                                                                            |
| currency<mark style="color:red;">\*</mark> | string  | \[ USD, CAD, ILS, EUR, RUB ]                                                                                                                                                                                                                      |
| apiKey<mark style="color:red;">\*</mark>   | string  | Unique API provided by SensePass, unique for each location of your merchant                                                                                                                                                                       |
| clientPhoneNumber                          | string  | <p>SMS message will be sent to this consumer number for SMS payment</p><p>For delivery status - See "SMS" field in <a data-mention href="../../../../models/transaction-model#transaction-entity">#transaction-entity</a></p>                     |
| returnURL                                  | string  | URL to redirect consumer after Success or Error                                                                                                                                                                                                   |
| cancelURL                                  | string  | URL to redirect consumer on cancel event from consumer                                                                                                                                                                                            |
| callbackURL                                | string  | URL to Callback API - SensePass will call this API with full Transaction Entity for every status change about this transaction                                                                                                                    |

{% tabs %}
{% tab title="200: OK OK" %}
**See Transactions entity schema:** [#transaction-entity](https://docs.sensepass.com/sensepay/models/transaction-model#transaction-entity "mention")

```javascript
{
  "TransactionNumber": "14a4334a32c852aeb0cfae52cbff1314649da7f175a8e140b35c147c",
  "date": "2019-12-19T09:47:59.105Z",
  "amount": "1234.56",
  "currency": "USD",
  "status": 0,
  "statusName": "Transaction Approved",
  "pos": "POS 3, Branch Tel Aviv",
  "posReceiptsEndpoint": "http://pay.sensepass-api.com/api/invoicesReceipts/receipt/save/hofai3478o8o78o4s849j3920ckj",
  "posData": {
    "foo": "bar",
    "hello": [
      "world"
    ]
  },
  "businessName": "Coffee Bar",
  "businessId": 144,
  "timeoutDate": "2019-12-19T09:47:59.105Z",
  "paymentMethodData": {
    "PaymentType": "Bit",
    "directAppLinks": {
      "iOSLink": "paymentsBIT://www.bitpay.co.il/app/bitcom-info",
      "androidLink": "intent://www.bitpay.co.il/app/bitcom-info;scheme=bit;package=com.bnhp.payments.paymentsapp;end",
      "qrURL": "https://www.bitpay.co.il/app/bitcom-info"
    }
  },
  "SMS": "Sent",
  "paymentCommit": {
    "messsage": "Payment commit is enabled for this transaction",
    "isPaymentCommitted": false,
    "secondsToCommit": 60,
    "commitLink": "https://pay.sensepass-api.com/api/transactions/commitPayment/ec2dc489d161aa27a803f48bcf5ffcf"
  },
  "products": [
    {
      "name": "Coffee",
      "quantity": 2,
      "amount": 100,
      "discount": 0,
      "posIdentifier": "1234A"
    },
    {
      "name": "Beer",
      "quantity": 1,
      "amount": 600,
      "discount": 0,
      "posIdentifier": "1234B"
    }
  ],
  "productSumMismatch": true,
  "confirmations": [
    {
      "paymentType": "Regular",
      "confirmationNumber": "063-d9j09YsY1",
      "fullConfirmationCode": "063-d9j09YsY1",
      "dateApproval": "2019-12-19T09:47:59.105Z",
      "installments": 1,
      "paymentMethodName": "PayPal",
      "approvedBy": "PayPal",
      "providerId": "uGfNuwEGiP18SUnTUEo1/atTdesDnhDhZ/8i7G9NAEg=",
      "requestID": "a4dbf66e-d3f1-4a29-baf7-2591424a9a0c",
      "authNumber": "123213dsf13111",
      "referenceNumber": "1778298289",
      "acquirer": "Visa",
      "voucher": "yyyAbnlmlfm1323",
      "lastFourDigits": "8858",
      "sensePassReferenceId": "34e209ea8b24cc831cf"
    }
  ],
  "confirmation": {
    "paymentType": "Regular",
    "confirmationNumber": "063-d9j09YsY1",
    "fullConfirmationCode": "063-d9j09YsY1",
    "dateApproval": "2019-12-19T09:47:59.105Z",
    "installments": 1,
    "paymentMethodName": "PayPal",
    "approvedBy": "PayPal",
    "providerId": "uGfNuwEGiP18SUnTUEo1/atTdesDnhDhZ/8i7G9NAEg=",
    "requestID": "a4dbf66e-d3f1-4a29-baf7-2591424a9a0c",
    "authNumber": "123213dsf13111",
    "referenceNumber": "1778298289",
    "acquirer": "Visa",
    "voucher": "yyyAbnlmlfm1323",
    "lastFourDigits": "8858",
    "sensePassReferenceId": "34e209ea8b24cc831cf"
  },
  "transactionPage": {
    "iOSLink": "https://mbeta.sensepass-api.com/orderSummary/027e4e48d59fdbe83f5a78cab62a53c676b7f111fa9d0ee0a36d1872",
    "androidLink": "https://mbeta.sensepass-api.com/orderSummary/027e4e48d59fdbe83f5a78cab62a53c676b7f111fa9d0ee0a36d1872",
    "qrURL": "https://mbeta.sensepass-api.com/orderSummary/027e4e48d59fdbe83f5a78cab62a53c676b7f111fa9d0ee0a36d1872"
  },
  "balance": 0
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Input" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Error" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}
