moneymour/api-client-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moneymour/api-client-php

Composer 安装命令:

composer require moneymour/api-client-php

包简介

The library offers easy access to Moneymour APIs

README 文档

README

The library offers easy access to Moneymour APIs


Installation

A composer package is available on Packagist

$ composer install moneymour/api-client-php

Usage

use Moneymour\ApiClient as MoneymourApiClient;

class ApiClient {

  // Get the following information from https://merchant.sandbox.moneymour.com
  // For production: https://merchant.moneymour.com
  const PRIVATE_KEY = '<YOUR_PRIVATE_KEY>';
  const MERCHANT_ID = '<YOUR_MERCHANT_ID>';
  const MERCHANT_SECRET = '<YOUR_MERCHANT_SECRET>';

  // Build the client
  $signatureFactory = new SignatureFactory(self::PRIVATE_KEY);
  $client = new MoneymourApiClient(
    self::MERCHANT_ID,
    self::MERCHANT_SECRET,
    $signatureFactory,
    MoneymourApiClient::ENVIRONMENT_SANDBOX  // or ENVIRONMENT_PRODUCTION when you get ready
  );

  // Request payload
  $payload = [
    'orderId' => '123456', // the order id in your system
    'amount' => '1080', // must be >= 300 and <= 2000
    'email' => 'customer@merchant.com',
    'phoneNumber' => '+393334444555', // must include +39
    'products' => [ // the list of products in the cart
      [
        'name' => 'iPhone 7',
        'type' => 'Electronics',
        'price' => '500',
        'quantity' => 2,
        'discount' => 0
      ],
      [
        'name' => 'MacBook Pro Charger',
        'type' => 'Electronics',
        'price' => '80',
        'quantity' => 1,
        'discount' => 0
      ]
    ]
  ];

  // Perform the request
  $response = $client->request($payload);
  
  // Output example in JSON format
  print json_encode($res, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE) . "\n";
  
  /*
  {
    "status": "accepted",
    "amount": 1080,
    "phoneNumber": "+393334444555",
    "orderId": "123456",
    "products": [
        {
            "name": "iPhone 7",
            "type": "Electronics",
            "price": "500",
            "price": "2",
            "discount": 0
        },
        {
            "name": "MacBook Pro Charger",
            "type": "Electronics",
            "price": "80",
            "price": "1",
            "discount": 0
        }
    ]
  }
  */
}

Gotchas


Moneymour APIs allow only one pending request at a time. If you get a 403 error having message Duplicated request please cancel the current pending request using the Moneymour app for iOS or Android.


Verify signature in your webhook

$factory = new SignatureFactory(self::PRIVATE_KEY);
$factory->verify(
  $signature, // http request header "Signature"
  $expiresAt, // http request header "Expires-at"
  $body, // http request body
  MoneymourApiClient::ENVIRONMENT_SANDBOX  // or ENVIRONMENT_PRODUCTION when you get ready
); // return true or false

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固