wire4/wire4-api-sdk-php

用于与 Wire4 API 工作的客户端 SDK
Wire4 是 Monex 银行的金融科技公司 API,您可以使用它来管理 SPEI 转账

1.1.2 2021-11-04 01:28 UTC

README

Wire4 API 参考

用于与 Wire4 API 工作的客户端 SDK
Wire4 是 Monex 银行的金融科技公司 API,您可以使用它来管理 SPEI 转账

  • Wire4 API 版本:1.0.0
  • SDK 包版本:1.1.4

要求

PHP 5.5 或更高版本

安装和使用

Composer

要使用 Composer 安装,请将以下内容添加到 composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/wire4/wire4-api-sdk-php.git"
    }
  ],
  "require": {
    "wire4/wire4-api-sdk-php": "dev-master"
  }
}

执行以下命令

composer install

或直接从命令行执行以下行

composer require wire4/wire4-api-sdk-php dev-master

安装客户端到您的项目后,导入 autoload.php

    require_once('/path/to/wire4-php-client/vendor/autoload.php');

如何开始

请按照安装和使用说明进行操作,并执行以下示例代码,将应用程序凭据替换为您的数据。请注意,这些是仅供参考的示例,可能随时更改,但您必须在 wire4.mx 上创建一个账户以获取应用程序数据。

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$accessToken= "";
try {
    // Create the authenticator to obtain access token
    $oauth = new \mx\wire4\auth\OAuthWire4 (
        'YOUR_OAUTH_CONSUMER_KEY', //REPLACE THIS WITH YOUR DATA
        'YOUR_OAUTH_CONSUMER_SECRET', //REPLACE THIS WITH YOUR DATA
        \mx\wire4\auth\Environment::SANDBOX); // O \mx\wire4\auth\Environment::PRODUCTION
    // Obtain an access token use application flow and scope "general"
    $accessToken= $oauth->obtainAccessTokenApp("general");
} catch(OAuthException $e) {
    echo "Respuesta: ". $e->lastResponse . "\n";
}

$apiInstance = new \mx\wire4\client\api\ComprobanteElectrnicoDePagoCEPApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$body = new \mx\wire4\client\model\CepSearchBanxico(); // \mx\wire4\client\model\CepSearchBanxico | Información para buscar un CEP

try {
    $result = $apiInstance->obtainTransactionCepUsingPOST($body,$accessToken);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ComprobanteElectrnicoDePagoCEPApi->obtainTransactionCepUsingPOST: ', $e->getMessage(), PHP_EOL;
}
?>

在 GitHub 项目 https://github.com/wire4/wire4-api-sdk-php 的“示例”部分(examples)中,您可以找到说明如何使用 SDK 的示例,该示例演示了 API 中每个资源的用法。然而,为了获得更详细的信息或了解如何使用 API 的每个方法,我们建议您在 https://developers.wire4.mx 的“参考”部分中查看文档。

API 端点文档

所有 URI 都相对于 https://sandbox-api.wire4.mx/wire4/1.0.0 在沙盒环境中或 https://api.wire4.mx/wire4/1.0.0 在生产环境中。

模型文档

Webhooks签名验证

我们建议您查阅wire4参考文档以获取更多详细信息,不过我们为您提供了一个针对此客户的签名验证示例。

    $message = "{\"id\":\"evt_641296342fdbf2db40ce674dde4881b87ada81b1695ae1c54666578272c1cd10\",\"object\":\"spid_outgoing\",\"api_version\":\"1.0.0\",\"created\":\"2019-12-05T11:55:10.058-06:00\",\"data\":{\"account\":\"8999998\",\"amount\":120.25,\"currency_code\":\"USD\",\"monex_description\":\"Nombre Receptor: BANAMEX | Monto Pago: 120.25 | Cuenta beneficiaria: 112680000189999984 | Nombre Beneficiario: notificar@wire4.mx | Clave de Rastreo:  | Referencia Numerica: 1234567 | Concepto del pago: Transfer out test 1 | Fecha Confirmacion de Liquidacion: 05-12-2019 11:55:10\",\"detention_message\":\"Cuenta de beneficiario, no existe\",\"payment_order_id\":1427991983,\"status_code\":\"FAILED\",\"transaction_id\":704814938,\"beneficiary_account\":\"112680000189999984\",\"beneficiary_bank\":{\"key\":\"40112\",\"name\":\"BMONEX\",\"company_name\":\"BANCO MONEX S.A. INSTITUCION DE BANCA MULTIPLE, MONEX GRUPO FINANCIERO\",\"rfc\":\"BMI9704113PA\"},\"beneficiary_name\":\"notificar@wire4.mx\",\"concept\":\"Transfer out test 1\",\"order_id\":\"8A736A1D-ECA6-4959-93FE-794365F53E24\",\"reference\":1234567,\"request_id\":\"7dbf528d-b395-4779-924e-b182a4de17a5\",\"cep\":{}},\"livemode\":false,\"pending_webhooks\":0,\"request\":\"8A736A1D-ECA6-4959-93FE-794365F53E24\",\"type\":\"TRANSACTION.OUTGOING.SPID.RECEIVED\"}";
    $referenceString = "7c088d16a8a25f1640e95dfdce65770cb0a31dc0e71a9749bba1e4e114201efb6e78c50bea3d8d9337b8ea63b2a8abf5b1e03d0cf9dda6f8e83a509d1ac11908";
    $key = "wh_6b5cb70ab7fd489a8bd0c9d06513008"; //Lo encontraras en la consola de administracion de wire4.mx una vez que estes registrado y hayas dado de alta un webhook, reemplaza este valor

    $signResult = \mx\wire4\webhooks\sign\UtilsCompute::toExadecimal(
        \mx\wire4\webhooks\sign\UtilsCompute::computeHmacSha512($message, $key));

    var_dump($signResult);

    if( ! \mx\wire4\webhooks\sign\UtilsCompute::compareSignatures($referenceString,$signResult) ) {
        echo "Las firmas no son iguales:";

    } else {
        echo "Las validacion de firmas es correcta";
    }

    echo "\noriginal:".$referenceString;
    echo "\nresultado:".$signResult;

认证文档

wire4_aut_app

wire4_aut_app_user_spei

wire4_aut_app_user_spid

作者

Wire4 版权所有 2019. 隐私政策 - 条款和条件 https://wire4.mx/#/policies/use-policies