eurolink/sagepay-form-php

一个简单的包,用于将 SagePay/Opayo 表单 v3.00 集成到您的网站中。

v2.0.0 2022-11-14 10:49 UTC

This package is auto-updated.

Last update: 2024-09-14 14:45:13 UTC


README

Latest Version on Packagist Total Downloads

官方文档

请参阅SagePay PDF文档

安装

您可以通过 composer 安装此包

composer require eurolink/sagepay-form-php

使用方法

输出

$sagePay = new \Eurolink\SagePayForm\Builder([
    'isProduction' => FALSE,
    'encryptPassword' => 'XXXXXXXXXXXXXXXX',
    'vendor' => 'ZZZZZZZZZZZZZZZZ',
]);

$sagePay->setVendorTxCode( rand( 0, 32000 ) * rand( 0, 32000 ) );
$sagePay->setCurrency( 'GBP' );
$sagePay->setAmount( 100 );
$sagePay->setDescription('Payment' );
$sagePay->setSendEMail( 1 );
$sagePay->setBillingSurname( 'Smith' );
$sagePay->setBillingFirstnames( 'John' );
$sagePay->setBillingCity( 'London' );
$sagePay->setBillingPostCode( 'LN1 ON' );
$sagePay->setBillingAddress1( '1 An Other Road' );
$sagePay->setCustomerEMail( 'user@example.com' );
$sagePay->setCustomerName( 'John Smith' );
$sagePay->setBillingCountry( 'GB' );
$sagePay->setDeliverySameAsBilling();
$sagePay->setSuccessURL( 'http://example.com/sage?outcome=success' );
$sagePay->setFailureURL( 'http://example.com/sage?outcome=failure' );
<form method="POST" action="<?php echo $sagePay->getFormEndpoint(); ?>">
    <input type="hidden" name="VPSProtocol" value="<?php echo $sagePay->getVPSProtocol(); ?>">
    <input type="hidden" name="TxType" value="<?php echo $sagePay->getTxType(); ?>">
    <input type="hidden" name="Vendor" value="<?php echo $sagePay->getVendorCode(); ?>">
    <input type="hidden" name="Crypt" value="<?php echo $sagePay->getCrypt(); ?>">
    <button type="submit">Pay with SagePay</button>
</form>

输入

$sagePay = new \Eurolink\SagePayForm\Builder([
    'isProduction' => FALSE,
    'encryptPassword' => 'XXXXXXXXXXXXXXXX',
    'vendor' => 'ZZZZZZZZZZZZZZZZ',
]);

$sagePay->decode( $_GET['crypt'] );

// has response been successfully decrypted
var_dump( $sagePay->isResponseValid() );

// is response successful?
var_dump( $sagePay->isResponseStatusOK() );

// return the success or error message
var_dump( $sagePay->getResponseStatusMessage() );

// return vendor code (as previously submitted)
var_dump( $sagePay->getResponseVendorCode() );

// return transaction ID
var_dump( $sagePay->getResponseVendorCode() );

// return transaction ID (excluding curly brackets)
var_dump( $sagePay->getResponseTransactionIDFormatted() );

测试

composer test

变更日志

请参阅 CHANGELOG 了解最近的变化。

致谢

感谢 tolzhabayev 提供的 初始 PHP 类

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。