定制 zea/rest-library 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

zea/rest-library

Composer 安装命令:

composer require zea/rest-library

包简介

Library to connect with the PlacetoPay Rest api

README 文档

README

With this code you will be able to quickly connect with the PlacetoPay Rest service.

In order to see more comprehensive examples of how it works, please refer to the examples and the documentation

Installation

Using composer from your project

composer require zea/rest-library

Or If you just want to run the examples contained in this project run "composer install" to load the vendor autoload

Usage

Create an object with the configuration required for that instance

$placetopay = new Zea\RestLibrary\PlacetoPay([
    'login' => 'YOUR_LOGIN', // Provided by PlacetoPay
    'tranKey' => 'YOUR_TRANSACTIONAL_KEY', // Provided by PlacetoPay
    'baseUrl' => 'https://THE_BASE_URL_TO_POINT_AT',
    'timeout' => 10, // (optional) 15 by default
]);

Creating a new payment request to get a Payment Response

Simply provide the necessary payment information and you will get a Process Response if successful, for this example, are using the MINIMUM INFORMATION that must be provided, to see the complete structure, consult the documentation or the example in examples/basic/payment.php

$reference = 'COULD_BE_THE_PAYMENT_ORDER_ID";
$request = [
    'payment' => [
        'reference' => $reference,
        'description' => 'Testing payment',
        'amount' => [
            'currency' => 'USD',
            'total' => 120,
        ],
    ],
    'instrument' => [
        'card' => [
            'number' => '36545400000008',
            'expiration' => '12/20',
            'cvv' => '123',
            'installments' => 2
        ]
    ],
    'ipAddress' => '127.0.0.1',
    'userAgent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
];

$response = $placetopay->process($request);
if ($response->isSuccessful()) {
    $response->toArray()['response'];
} else {
    // There was some error so check the message and log it
    $response->status()->message();
}

Obtain information about a previously made payment

$response = $placetopay->query('THE_INTERNAL_REFERENCE_TO_QUERY');

if ($response->isSuccessful()) {

    if ($response->status()->isApproved()) {
        // The payment has been approved
    }
} else {
    // There was some error with the connection so check the message
    print_r($response->status()->message() . "\n");
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-04