> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/3rd-party-integration/masterpass-integrations/masterpass-rest-payment-option.md).

# Masterpass Rest Payment Option

## <mark style="color:red;">**Omnitron Settings**</mark>

### <mark style="color:red;">**Payment Options**</mark>

One payment option must be defined in Omnitron to be specific for the extension installed. Explanations on how the settings should be made at this stage are in the table below.

| Field               | Description                                                   |
| ------------------- | ------------------------------------------------------------- |
| Payment Option      | Masterpass Rest                                               |
| Payment Option Name | Masterpass Rest                                               |
| Payment Option Slug | mp\_rest                                                      |
| Config              | { “pos\_slug”: “mp\_rest”, "provision\_enabled": true/false } |

## <mark style="color:red;">**Token Services and Init Payments**</mark>

### <mark style="color:red;">**Masterpass Rest Token**</mark>

This method is used to get Masterpass Bearer Token. It should be used after *PaymentOptionSelectionPage.* If *three\_d* is false or isn’t provided, pos’es “*Three d enabled”* value will be used.

```
GET
https://{{commerce_url}}/orders/masterpass-rest-token?three_d=true|false&msisdn_validated=true|false
```

#### **Example Response**

```
{
    "msisdn": "...",
    "token": "Bearer...",
    "extras": {
        "bank_ica": null
    }
}
```

### <mark style="color:red;">**Masterpass via Craftgate Rest Token**</mark>

This method is used to get Masterpass Bearer Token from Craftgate. It should be used after *PaymentOptionSelectionPage* to list saved cards. It uses *123456* for bin\_number and *1* for installment\_count\*.\* After *MasterpassRestOrderNoPage*, it uses customers bin\_number and installment\_count. So, the token must be requested again.

**Example request flow:**

* PaymentOptionSelectionPage
* Get token from Craftgate
* MasterpassRestBinNumberPage
* MasterpassRestInstallmentPage
* MasterpassRestOrderNoPage
* Get token from Craftgate **again**
* MasterpassRestCompletePage

```
GET
https://{{commerce_url}}/orders/craftgate-masterpass-token?three_d=true|false
```

#### **Example Response**

```
{
    "msisdn": "...",
    "token": "Bearer...",
    "referenceId": "...",
    "orderNo": "...",
    "extras": {
        "bank_ica": null
    }
}
```

### <mark style="color:red;">**Masterpass via Craftgate 3D Init**</mark>

Also, if the payment is 3D, *init* service must be called before the payment. You can get more details from [Craftgate](https://developer.craftgate.io/en/api/payment/payment-with-masterpass/#init-3d-secure-payment)

```
GET
https://{{commerce_url}}/orders/craftgate-masterpass-init?reference_id=...
```

#### **Example Response**

```
{
    "paymentId": ...,
    "returnUrl": "https://...",
}
```

## <mark style="color:red;">**Pages**</mark>

### <mark style="color:red;">**Start Masterpass Rest Payment Type**</mark>

This method is used to start Masterpass Rest Payment Type.

```
POST
https://{{commerce_url}}/orders/checkout/?page=MasterpassRestBinNumberPage
```

#### **Example Request**

```

{
    "is_masterpass_stored_card": true,
    "bin_number": "665544"
}

```

#### **Example Response**

```
{
	"context_list": [
    	{
        	"page_context": {
            	"installments": [
                	{
                    	"pk": 1,
                    	"installment_count": 1,
                    	"label": "Advance",
                    	"price_with_accrued_interest": 100,
                    	"monthly_price_with_accrued_interest": 100
                	},
                	{
                    	"pk": 2,
                    	"installment_count": 3,
                    	"label": "3 Installments",
                    	"price_with_accrued_interest": 105,
                    	"monthly_price_with_accrued_interest": 105
                	}
            	],
            	"card_type": {
                	"name": "Card Finans",
                	"slug": "card-finans",
                	"logo": "https://cdn-mgsm.akinon.net/card_types/2017/01/25/56dd552c-c769-4b3f-86f6-1f340bafa3c0.jpg"
            	},
            	"installment_messages": []
        	},
        	"page_name": "MasterpassRestInstallmentPage",
        	"page_slug": "masterpassrestinstallmentpage"
    	}
	],
	"template_name": "orders/checkout.html",
	"errors": null,
	"pre_order": {}
}
```

### <mark style="color:red;">**Set Installment on Masterpass Rest Payment Type**</mark>

This method is used to set installment option on Masterpass Rest Payment Type.

```
POST
https://{{commerce_url}}/orders/checkout/?page=MasterpassRestInstallmentPage
```

#### **Example Request**

```

{
	"installment": 1
}

```

#### **Example Response**

```
{
	"context_list": [
    	{
        	"page_context": {},
        	"page_name": "MasterpassRestOrderNoPage",
        	"page_slug": "masterpassrestordernopage"
    	}
	],
	"template_name": "orders/checkout.html",
	"errors": null,
	"pre_order": {...}
}
```

### <mark style="color:red;">**Continue on Masterpass Rest Payment Type**</mark>

This method is used to continue on Masterpass Rest Payment Type.

```
POST
https://{{commerce_url}}/orders/checkout/?page=MasterpassRestOrderNoPage
```

#### **Example Request**

```
{
	"use_three_d": true
}
```

#### **Example Response**

```
{
	"context_list": [
    	{
        	"page_context": {
            	"msisdn": "...",
            	"order_no": "...",
            	"three_d": true,
            	"extras": {...},
        	},
        	"page_name": "MasterpassRestCompletePage",
        	"page_slug": "masterpassrestcompletepage"
    	}
	],
	"template_name": "orders/checkout.html",
	"errors": null,
	"pre_order": {...}
}
```

### <mark style="color:red;">**Continue on Masterpass Rest Payment Type**</mark>

This method is used to continue on Masterpass Rest Payment Type.

*transactionType* values:

* DIRECT\_PURCHASE
* DIRECT\_PURCHASE\_3D
* PURCHASE
* PURCHASE\_3D
* REGISTER\_AND\_PURCHASE
* REGISTER\_AND\_PURCHASE\_3D

```
POST https://{{commerce_url}}/orders/checkout/?page=MasterpassRestCompletePage&responseCode={{responseCode}}&token={{token}}&three_d_secure={{true/false}}
```

#### **Example Request for Masterpass POS**

```
{
	"token": "...",
	"transactionType": "...",
	...
}
```

#### **Example Request for Craftgate POS**

```
{
	"token": "...", // Non-3D
	"referenceId": "...", // Non-3D
	"paymentId": "...", // 3D
...
}
```

#### **Example Response**

```
{
	"context_list": [
    	{
        	"page_context": {
            	"redirect_url": "/orders/completed/IjcwMjExMjMyMTA5MTci:1mRByT:tTgDsJbIKXyxJZyIZwHIBqtShvw/",
            	"order_id": 303,
            	"new_user": false,
            	"token": "138ddd19a0436166354cccbacb4cbb0473104193",
            	"campaigns": []
        	},
        	"page_name": "ThankYouPage",
        	"page_slug": "thankyoupage"
    	}
	],
	"template_name": "orders/checkout.html",
	"errors": null,
	"pre_order": {...}
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.akinon.com/technical-guides/3rd-party-integration/masterpass-integrations/masterpass-rest-payment-option.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
