# MobilePay payment actions via eComm API

This tutorial will help you understand how the MobilePay eComm API works and how to perform your first transaction through the MobilePay eComm API with Verifone.

## Prerequisites <a href="#step-1__003a-set-up" id="step-1__003a-set-up"></a>

Before making a transaction, you need:

* A MobilePay Sandbox account (contact your sales rep)
* To obtain an [API key](/online-payments/api-integration-methods-auth-and-endpoints/api-authentication.md)
* The Payment Provider Contract ID associated with your MobilePay connection as part of your onboarding into [Verifone Central](https://docs.verifone.com/verifone-central-getting-started/).

## Create a transaction <a href="#create-a-transaction" id="create-a-transaction"></a>

Make a POST request to /transactions endpoint. Here is an example of a payload:

```json
{
    "intent": "AUTHORIZE",
    "paymentProviderContract": "YOUR_PAYMENT_PROVIDER_CONTRACT",
    "amount": {
    	"value": 2700,
    	"currencyCode": "USD"
    },  
    "customer": {
        "email": "yourEmail@personal.example.com",
        "payerId": "WDJJHEBZ4X2LY",
        "phoneNumber": {
            "phoneType": "MOBILE",
            "value": "64646464"
        },
        "birthDate": "2000-01-31",
            "identification": {
            "taxIdentificationNumber": "123456",
            "taxIdentificationType": "BR_CNPJ"
        },
        "address": {
            "country": "IN",
            "postalCode": "570023",
            "countrySubdivision": "IN-MH",
            "city": "yyy",
            "addressLine1": "add1",
            "addressLine2": "add2"
        },
        "firstName": "James",
        "lastName": "Smith"
    },
    "applicationContext": {
        "brandName": "MAHENDRA",
        "locale": "he-IL",
        "landingPage": "BILLING",
        "returnUrl": "http://example.com/success",
        "cancelUrl": "http://example.com/failure"
    },
    "shipping": {
        "address": {
            "country": "IN",
            "postalCode": "91",
            "countrySubdivision": "IN-MH",
            "city": "mysore",
            "addressLine1": "walstreet",
            "addressLine2": "forcircle"
        },
        "fullName": "JamesSmith"
    },
    "items": [
        {
            "name": "Mac Laptop",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "1",
            "description": "Dell Laptop",
            "sku": "123",
            "category": "PHYSICAL_GOODS"
        },
        {
            "name": "Phone",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "10",
            "description": "Apple phone",
            "sku": "456",
            "category": "PHYSICAL_GOODS"
        },
        {
            "name": "Dell XPS 9310 13.4 FHD Display Thin & Light 11th Gen Laptop (i5-1135G7 / 8 GB / 512 SSD / Integrated Graphics / 1Yr Premium",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "1",
            "description": "groceries",
            "sku": "456",
            "category": "PHYSICAL_GOODS"
        },
        {
            "name": "Samsung 6.5 kg Fully-Automatic Top Loading Washing Machine (WA65A4002VS/TL, Imperial Silver, Center Jet Technology)",
            "unitAmount": {
                "currencyCode": "USD",
                "value": 100
            },
            "tax": {
                "currencyCode": "USD",
                "value": 100
            },
            "quantity": "1",
            "description": "product",
            "sku": "456",
            "category": "PHYSICAL_GOODS"
        }
    ],
    "dynamicDescriptor": "Vipps order DD123",
    "merchantReference": "DD123-reference",
    "detailedAmount": {
        "discount": {
            "currencyCode": "USD",
            "value": 100
        },
        "shippingDiscount": {
            "currencyCode": "USD",
            "value": 100
        },
        "insurance": {
            "currencyCode": "USD",
            "value": 100
        },  
        "handling": {
            "currencyCode": "USD",
            "value": 100
        },
        "shipping": {
            "currencyCode": "USD",
            "value": 100
        }
    }
}
```

**Response example**:

{% tabs %}
{% tab title="Nets Integration" %}

```php
{
   "id": "27241ae8-e72a-4586-9ef2-78dcb7a0ad9f",
   "orderId": "4DD655383X489915V",
   "createdAt": "2021-02-04T17:23:44Z",
   "status": "INITIATED",
   "approvalUrl": "https://www.sandbox.vipps.com/checkoutnow?token=4DD655383X489915V"
}
```

{% endtab %}

{% tab title="Intercard Integration" %}

```php
{
    "amount": 5000,
    "blocked": false,
    "created_at": "2022-11-18T10:44:56.753871Z",
    "customer": "deebacec-cd75-4ce5-9641-bfc40de5710d",
    "details": {
        "auto_capture": false
    },
    "merchant_reference": "ST200050",
    "status": "INITIATED",
    "created_by": "0bc5a545-6bbf-49b1-a1b8-ef533f47cf71",
    "geo_location": [
        35.69,
        139.69
    ],
    "country_code": "FI",
    "id": "8e0ee54d-b6e5-4415-a0c9-ba5389f56594",
    "redirect_url": "https://sandprod-products.mobilepay.dk/remote-website/index.html?page=request&id=d125bf8e-2bf0-47c0-9dbe-4dfb4e901c90",
    "processor": "INTERCARD",
    "payment_product": "CARD",
    "payment_product_type": "Unknown"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Intercard integration will be available starting with 2023.
{% endhint %}

For details about the API reference and the request fields, you can review the [Create Transaction API](/api-reference/open-api-references/ecommerce.md).

## Approve the transaction <a href="#approve-the-transaction" id="approve-the-transaction"></a>

To approve the transactions, follow these steps:

1. Open the approvalUrl link from the previous API response in the browser to approve the transaction. This would open the MobilePay portal and would show the login page.
2. Log in using your MobilePay credentials and, after reviewing the transaction detail, approve the transaction.
3. After the approval, you are redirected to the returnUrl that was passed in the applicationContext while creating the transaction.
4. If you cancel the approval flow in between, then you would be redirected to the cancelUrl.

## Authorize the transaction <a href="#authorize-the-transaction" id="authorize-the-transaction"></a>

Make a POST request to /transactions/:id/authorize for authorizing a transaction.

{% hint style="info" %}
This step is only required if the intent is to authorize a transaction. If the intent is to capture a transaction, skip this step.
{% endhint %}

The ID parameter in the URL is the ID from the response of the createTransaction API call.

## Capture a payment <a href="#capture-a-payment" id="capture-a-payment"></a>

1. Make a POST request to /transactions/:id/capture to capture a transaction payment.
2. Use the ID parameter from the response of the createTransaction API call as a request parameter.
3. If you want to capture the full transaction, then there is no need to send the amount in the request payload; instead, a *null* in the request body is to be sent.
4. However, if you want to capture a partial amount of the transaction, then you can send the amount object in the request payload as shown below:

```json
 {
   "amount": {
       "value": 50,
       "currencyCode": "USD"
   }
}
```


---

# Agent Instructions: 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:

```
GET https://docs.verifone.com/online-payments/payment-actions/mobilepay-payment-actions-via-ecomm-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
