---
page_source: https://docs.juspay.io/agoda-integration/docs/wallets-payments-api/wallet-payment
page_title: Wallet Payment
---

## API Version: default


# Wallet Payment



Create a payment transaction for paying from a prepaid **Wallet** . Once you have the response, depending on the “method” attribute, you will have to take the next step. If you receive GET, then take the value in the “URL” attribute and redirect the user to this location. If you receive POST, then “params” attribute will hold a map containing key-value pairs.

For Web, you can create a form with these parameters as hidden variables and auto submit the form. Example code in Javascript: [Serialize Parameters](https://gist.github.com/ramanathanrv/31c0b687f0177c37b892).

For Android, serialize this data such that it can be loaded to WebView directly via postData. Example code in Java: [Serialize Parameters](https://gist.github.com/ramanathanrv/59fb412e1c75a1d9398a).


## HANDLING POST



When you get `POST` as the authentication method in the response, then the customer must be redirected using a form. Example HTML code is given to you. Depending on your client language, choose the appropriate way to create the form.


#### Handling POST Code Snippet:

```handling post
<form method="POST" action="$authentication.url" id="authForm">
  {{ for key in  $authentication.params }}
  <input type="hidden" name="$key" value="$authentication.params[$key]">
  {{ end }}
</form>
<script type="text/javascript">
 document.forms["authForm"].submit()
</script>
```



## HANDLING GET



When you get `GET` as the authentication method in the response, you may load the URL directly into the customer’s browser. You can easily achieve this by sending HTTP 302 from your server. However, if the API call was made from the browser, then you can utilize the code snippet provided.


#### Request Code Snippet:

```request
<form method="POST" action="$authentication.url" id="authForm">
  {{ for key in  $authentication.params }}
  <input type="hidden" name="$key" value="$authentication.params[$key]">
  {{ end }}
</form>
<script type="text/javascript">
 document.forms["authForm"].submit()
</script>
```
## Endpoints:
- Production: https://api.juspay.in/txns

## Request Type: 
POST

## Authorization:

#### Basic Auth:
Consists of two parts.

* Username: API Key obtained from Juspay dashboard
* Password: Empty string
- Value: <p>Example:- <br> Basic MUQ2QUxxxxxxxxxxxxU5QTIxQzNFNTQwNkFDMEZCOg==</p>
- Tags: Base64 Encoded username:password, required
## Headers:

#### x-merchantid:
Merchant ID provided by Juspay
- Value: <p>Example:- <br>merchant-id</p>
- Tags: string, required

#### version:
Pass the date in YYYY-MM-DD format
- Value: <p>Example:- <br>2023-01-01</p>
- Tags: string

#### Content-Type:
application/x-www-form-urlencoded
- Tags: String
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl --location 'https://api.juspay.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic xxx==' \
--data-urlencode 'merchant_id=:merchant_id' \
--data-urlencode 'payment_method_type=WALLET' \
--data-urlencode 'payment_method=GOPAY' \
--data-urlencode 'redirect_after_payment=true' \
--data-urlencode 'format=json' \
--data-urlencode 'order.order_id=:order_id' \
--data-urlencode 'order.amount=100' \
--data-urlencode 'order.currency=IDR' \
--data-urlencode 'order.customer_id=test123' \
--data-urlencode 'order.customer_phone=9164326296'

```

### Sample Response:

#### Example Response (Having POST As The Method):
```json
{
  "order_id": ":order_id",
  "txn_id": ":txn_id",
  "status": "PENDING_VBV",
  "payment": {
    "authentication": {
      "method": "POST",
      "url": "https://wallet-url.com/payment-path/start",
      "params": {
        "key1": "v1",
        "key2": "v2",
        "key3": "v3"
      }
    }
  }
}
```

#### Example Response (Having GET As The Method):
```json
{
  "order_id": ":order_id",
  "txn_id": ":txn_id",
  "status": "PENDING_VBV",
  "payment": {
    "authentication": {
      "method": "GET",
      "url": "https://wallet-url.com/payment-path/start?hello=world"
    }
  }
}

```

## Body Parameters:
### Parameters:

#### Order object:
- Description: [Order object](https://docs.juspay.in/api-reference-global/docs/order/order-object)``pertaining to the order you are creating. 
- Tags: string, Required

#### merchant_id:
- Description: ID of the merchant_account that you hold with us.
- Tags: string, Required

#### payment_method_type:
- Description: Must be `WALLET`
- Tags: string, Required

#### payment_method:
- Description: The actual payment method that was selected by the user. For WALLET transactions, the values will be shared by Juspay team. 
- Tags: string, Required

#### redirect_after_payment:
- Description: This is a boolean variable and accepts true/false. We recommend that you set this to true. If set to `true`, then the user is redirected to the `return\_url` configured for the order. If set to `false`, then the user will be stopped at the response page from the gateway. Your client should be able to read the page/title to infer that the user has completed the transaction.
- Tags: string, Required

#### format:
- Description: If it is set to `json`, then the response will be HTTP 200 with a JSON formatted text. Otherwise, the response is HTTP 302 with the Location attribute having the destination URL.
- Tags: string, Required
## API Responses:
### 200:

#### order_id:
- Description: :order_id
- Tags: string

#### txn_id:
- Description: :txn_id
- Tags: string

#### status:
- Description: PENDING_VBV
- Tags: string

#### payment:
- Value:
  - **Authentication.method**:
    - Tags: string
  - **Authentication.url**:
    - Tags: String
  - **Authentication.params**:
    - Description: Only when you have POST as the authentication method
    - Value:
      - **Key1**:
        - Tags: String
      - **Key2**:
        - Tags: String
      - **Key3**:
        - Tags: String
    - Tags: Object
- Tags: object
### 400:

#### status:
- Description: error
- Tags: string

#### error_message:
- Description: Order timed out
- Tags: string

#### error_code:
- Description: invalid_request
- Tags: string
