csweb/global-payments

与全球支付网关集成

3.0.0 2021-07-29 00:36 UTC

This package is auto-updated.

Last update: 2024-08-29 05:54:08 UTC


README

Build Status

本包是为使用GlobalPayments公司提供的webservice而开发的

使用的说明书: https://developers.globalpagamentos.com.br/api-portal/pt-br/content/e-commerce-webservice

#安装

为了进行安装,请使用composer

$ composer require csweb/global-payments

目前,此包与Laravel 5.8版本兼容。此包可以在Laravel框架之外进行测试。

使用方法

为了使用,您需要执行以下操作

<?php

require_once __DIR__ . './vendor/autoload.php';

use CSWeb\GlobalPayments\Transaction;
use CSWeb\GlobalPayments\WebService;

$transaction = new Transaction([
    'amount'           => 10.00,
    'order'            => $yourOrderNumber,
    'cardHolder'       => 'Matheus Lopes Santos',
    'cardNumber'       => '4111 1111 1111 1111',
    'cvv'              => 123,
    'expiryDate'       => new DateTime(),
    'merchantCode'     => $yourMerchantCode,
    'merchantTerminal' => $yourMerchantTerminal,
    'merchantKey'      => $yourMerchantKey,
]);

$invoice = (new WebService())->transaction($transaction);

要取消收费,只需按照以下方式操作

<?php

require_once __DIR__ . './vendor/autoload.php';

use CSWeb\GlobalPayments\WebService;
use CSweb\GlobalPayments\Cancellation;

$cancellation = new Cancellation([
    'amount'           => 10.00,
    'order'            => $yourOrderNumber, // Order number deve ser o mesmo enviado ao executar o pagamento
    'merchantCode'     => $yourMerchantCode,
    'merchantTerminal' => $yourMerchantTerminal,
    'merchantKey'      => $yourMerchantKey,
]);

$cancelledPayment = (new WebService())->cancelTransaction($cancellation);

如果在调用过程中发生任何错误,系统将抛出多个异常。请留意这一点。

通常,merchantTerminal字段应填写为001

全球支付提供了一个测试密钥:qwertyasdf0123456789

要使用沙盒,只需调用webservice类,将参数设置为true

$invoice = (new WebService(true))->send(...);

否则,将自动指向生产端点

贡献

所有贡献都非常受欢迎。留下您的pull request :)