MIPS 电子商务集成

dev-main 2023-03-04 07:00 UTC

This package is auto-updated.

Last update: 2024-09-04 10:01:22 UTC


README

MIPS 电子商务集成。请参阅 https://www.mips.mu/orchestration

用法

use nadimattari\mips\mips;

$mips = new mips([
    'id_merchant'     => 'respective-values-here',
    'id_entity'       => 'respective-values-here',
    'operator'        => 'respective-values-here',
    'operator_pass'   => 'respective-values-here',
    'salt'            => 'respective-values-here',
    'cipher_key'      => 'respective-values-here',
    'basic_auth_user' => 'respective-values-here',
    'basic_auth_pass' => 'respective-values-here',
]);

$response = $mips
    ->setPayload([
        'order' => [
            'id_order' => 'INV-00011',
            'currency' => 'MUR',
            'amount'   => $total,
        ],
        'iframe_behavior' => [
            'height"                 => 500,
            'width"                  => 960,
            'language"               => 'EN',
            'custom_redirection_url' => 'https://my-domain.tld/display-payment-done',
        ],
    ])
    ->loadPaymentZone()
;

// $response = [
//     'original_message' => 'string',
//     'answer' => [
//         "operation_status' => 'success',
//         "payment_zone_data'=> 'html-string',
//     ],
// ];

Mips 文档

文档可以在以下位置找到: https://docs.mips.mu/

1. 加载支付区域

POST https://api.mips.mu/api/load_payment_zone

此 API 调用返回一个 HTML 代码,生成 iframe。它允许商家在 iframe 内输出一个 HTML 支付区域。

重要:此 API 调用的结果是 Token 或支付结果。只有在进行令牌化或支付成功时,Token 或支付结果才会发送到商家提供的 IMN URL。

iFrame 的外观和感觉将自动生成。

CURL 请求

$ curl --request POST \
  --url https://api.mips.mu/api/load_payment_zone \
  --header 'Authorization: Basic dXNlcjpwYXNz' \
  --header 'Content-Type: application/json' \
  --header 'user-agent: ' \
  --data '{
  "authentify": {
    "id_merchant": "q7r79YV13XjisGDnGgRw7pVMGSagfRzx",
    "id_entity": "Dem1091uOLSIVQPnLYuVTtmkfGppLo0t",
    "id_operator": "w8kvu7ShJrbRnVy54CjGpakWGj6H5zJy",
    "operator_password": "G2JvCxTo2LJpZC3a9zNN9LlCdzjwf9X0"
  },
  "order": {
    "id_order": "INV5026",
    "currency": "MUR",
    "amount": 10.25
  },
  "iframe_behavior": {
    "height": 400,
    "width": 350,
    "custom_redirection_url": "www.example.com",
    "language": "EN"
  },
  "request_mode": "simple",
  "touchpoint": "native_app",
  "odrp": {
    "max_amount_total": 0,
    "max_amount_per_claim": 0,
    "max_frequency": 0,
    "max_date": "2019-08-24"
  },
  "membership": {
    "interval": 1,
    "start_date": "2019-08-24",
    "frequency": "day",
    "end_date": "2019-08-24",
    "day_to_process": 5,
    "membership_amount": 1240.05
  },
  "additional_params": [
    {
      "param_name": "string",
      "param_value": "string"
    }
  ]
}'

HTTP 请求

POST /api/load_payment_zone HTTP/1.1
Content-Type: application/json
User-Agent: 
Authorization: Basic dXNlcjpwYXNz
Host: api.mips.mu

{
  "authentify": {
    "id_merchant": "q7r79YV13XjisGDnGgRw7pVMGSagfRzx",
    "id_entity": "Dem1091uOLSIVQPnLYuVTtmkfGppLo0t",
    "id_operator": "w8kvu7ShJrbRnVy54CjGpakWGj6H5zJy",
    "operator_password": "G2JvCxTo2LJpZC3a9zNN9LlCdzjwf9X0"
  },
  "order": {
    "id_order": "INV5026",
    "currency": "MUR",
    "amount": 10.25
  },
  "iframe_behavior": {
    "height": 400,
    "width": 350,
    "custom_redirection_url": "www.example.com",
    "language": "EN"
  },
  "request_mode": "simple",
  "touchpoint": "native_app",
  "odrp": {
    "max_amount_total": 0,
    "max_amount_per_claim": 0,
    "max_frequency": 0,
    "max_date": "2019-08-24"
  },
  "membership": {
    "interval": 1,
    "start_date": "2019-08-24",
    "frequency": "day",
    "end_date": "2019-08-24",
    "day_to_process": 5,
    "membership_amount": 1240.05
  },
  "additional_params": [
    {
      "param_name": "string",
      "param_value": "string"
    }
  ]
}

JSON 响应

{
  "original_message": "string",
  "answer": {
    "operation_status": "success",
    "payment_zone_data": "string"
  }
}

2. 解密 IMN 回调数据

IMN 回调架构

预先定义的 URL,并由商家托管。此 URL 仅在成功支付时由 MiPS 触发。您的 IMN URL 将在开户时由 MiPS 团队询问。

POST https://api.mips.mu/api/decrypt_imn_data

当商家收到 IMN 回调时,应调用此 API。

CURL 请求

$ curl --request POST \
  --url https://api.mips.mu/api/decrypt_imn_data \
  --header 'Authorization: Basic dXNlcjpwYXNz' \
  --header 'Content-Type: application/json' \
  --header 'user-agent: ' \
  --data '{
  "authentify": {
    "id_merchant": "q7r79YV13XjisGDnGgRw7pVMGSagfRzx",
    "id_entity": "Dem1091uOLSIVQPnLYuVTtmkfGppLo0t",
    "id_operator": "w8kvu7ShJrbRnVy54CjGpakWGj6H5zJy",
    "operator_password": "G2JvCxTo2LJpZC3a9zNN9LlCdzjwf9X0"
  },
  "salt": "string",
  "cipher_key": "string",
  "received_crypted_data": "string"
}'

CURL 请求

POST /api/decrypt_imn_data HTTP/1.1
Content-Type: application/json
User-Agent: 
Authorization: Basic dXNlcjpwYXNz
Host: api.mips.mu
Content-Length: 331

{
  "authentify": {
    "id_merchant": "q7r79YV13XjisGDnGgRw7pVMGSagfRzx",
    "id_entity": "Dem1091uOLSIVQPnLYuVTtmkfGppLo0t",
    "id_operator": "w8kvu7ShJrbRnVy54CjGpakWGj6H5zJy",
    "operator_password": "G2JvCxTo2LJpZC3a9zNN9LlCdzjwf9X0"
  },
  "salt": "string",
  "cipher_key": "string",
  "received_crypted_data": "string"
}

JSON 响应

{
  "amount": "string",
  "currency": "string",
  "status": "success",
  "checksum": "string",
  "id_order": "string",
  "transaction_id": "string",
  "type": "string",
  "reference": "string",
  "payment_method": "string",
  "additional_param": "string",
  "reason_fail": "string",
  "token": {
    "id_token": "stringstringstringstringstringstringstringstringstringstring",
    "token_for_id_order": "string",
    "token_exp_date": "string"
  },
  "card_details": {
    "masked_card_number": "123456xxxxxx1234",
    "expiry_date": "mm/yy"
  }
}