Amazon Payment Services PHP SDK

2.0.0 2023-06-08 12:45 UTC

This package is not auto-updated.

Last update: 2024-09-27 17:03:50 UTC


README

Amazon Payment Services SDK 为 PHP 平台的商家提供无缝支付服务。如果您还没有 APS 账户,请点击这里注册 Amazon Payment Services 账户。

入门指南

我们知道支付处理对您的业务至关重要。使用此插件,我们旨在提高您的支付处理能力。您有业务关键问题吗?查看我们的快速参考文档,涵盖支付接受、集成和报告的关键见解。对于 SDK 指南,请参考wiki

支付选项

  • 集成类型

    • 重定向
    • 商家页面
    • 托管商家页面
    • Apple Pay
    • 分期付款
    • 定期
    • MOTO
    • 可信
  • 维护操作

    • 签名计算和验证
    • 退款
    • 抓取
    • 作废
    • 检查状态
    • 反馈通知处理

集成步骤

安装 PHP SDK 包

使用 composer 安装您的解决方案的 PHP SDK 包,或从 GitHub 仓库下载,然后在终端中运行 composer update 命令以安装所有依赖项。

商家配置

作为商家,您需要向网关发送一些属性。这些属性必须放入一个数组中,并使用以下方法设置。如果您想集成 Apple Pay,则必须添加包含 "Apple_" 的所有属性,否则这些属性不是必需的。

属性示例
php


return [
    'merchant_identifier'       => '**********',
   
 'access_code'               => '**********',
    
'SHARequestPhrase'          => '**********',
   
 'SHAResponsePhrase'         => '**********',
    
'SHAType'                   => '**********',
   
 'sandbox_mode'              => true,

   
 'Apple_AccessCode'          => '**********',
   
 'Apple_SHARequestPhrase'    => '**********',
   
 'Apple_SHAResponsePhrase'   => '**********',
    
'Apple_SHAType'             => '**********',
    
'Apple_DisplayName'         => 'Test Apple store',
   
 'Apple_DomainName'          => 'https://store.local.com',
    
'Apple_SupportedNetworks'   => ["visa", "masterCard", "amex", "mada"],
    
'Apple_SupportedCountries'  => [],
   
 'Apple_CertificatePath'     => '**path**to**certificate**',
   
 'Apple_CertificateKeyPath'  => '**path**to**certificate**key**',
   
 'Apple_CertificateKeyPass'  => 'apple*certificate*password',

   
 // folder must be created before
    
'log_path'                  => __DIR__ . '/tmp/aps.log',
   
'3ds_modal'                 => true,
    
'debug_mode'                => false,
    
'locale'                    => 'en',
];

所有商家配置属性

// load merchant configuration
$merchantParams = include 'merchant_config.php';

// set merchant configuration one time
APSMerchant::setMerchantParams($merchantParams);

支付数据配置

作为商家,您需要向网关发送支付详情。这些详情必须放入一个数组中,并在下面的 "setPaymentData" 方法中设置。 "merchant_reference" 是客户订单号。

<?php

return  [
    'merchant_reference'=> 'O-00001-'.rand(1000, 99999),
    'amount'            => 3197.00,
    'currency'          => 'AED',
    'language'          => 'en',
    'customer_email'    => 'test@aps.com',

    'order_description' => 'Test product 1',
];

以下是如何发出信用卡重定向支付方式的示例。使用支付详情设置支付数据,然后设置授权/购买命令,设置您的回调 URL 并渲染客户页面所需的信息。

示例
    <?php
    try {
        echo (new CCRedirect())
            ->setPaymentData($paymentData)
            ->useAuthorizationCommand()
            ->setCallbackUrl(‘callback-url.php’)
            ->render([
                    ‘button_text’   => ‘Place order with Authorization’
            ]);
    } catch (APSException $e) {
        echo ‘SETUP ERROR: ‘ . $e->getMessage();
    }
    ?>
</div>

    <?php
    try {
        echo (new CCRedirect())
            ->setPaymentData($paymentData)
            ->usePurchaseCommand()
            ->setCallbackUrl(‘callback-url.php’)
            ->render([
                    ‘button_text’   => ‘Place order with Purchase’
            ]);
    } catch (APSException $e) {
        echo ‘SETUP ERROR: ‘ . $e->getMessage();
    }
    ?>

标准结账

标准结账支付选项的类名为 "CCStandard"。此类可用于授权或购买命令。例如,请参阅以下代码。

示例
<div>
    <?php
    try {
        echo (new CCStandard())
            ->setPaymentData($paymentData)
            ->useAuthorizationCommand()
            ->setCallbackUrl('callback-url.php')
            ->render([
                    'button_text'   => 'Place order with Authorization'
            ]);
    } catch (APSException $e) {
        echo 'SETUP ERROR: ' . $e->getMessage();
    }
    ?>
</div>
<div>
    <?php
    try {
        echo (new CCStandard())
            ->setPaymentData($paymentData)
            ->usePurchaseCommand()
            ->setCallbackUrl('callback-url.php')
            ->render([
                    'button_text'   => 'Place order with Purchase'
            ]);
    } catch (APSException $e) {
        echo 'SETUP ERROR: ' . $e->getMessage();
    }
    ?>
</div>

自定义结账

自定义结账支付选项的类名为 "CCCustom"。此类可用于授权或购买命令。例如,请参阅以下代码。

示例
<div>
    <?php
    try {
        echo (new CCCustom())
            ->setPaymentData($paymentData)
            ->useAuthorizationCommand()
            ->setCallbackUrl('callback-url.php')
            ->render([
                    'button_text'   => 'Place order with Authorization'
            ]);
    } catch (APSException $e) {
        echo 'SETUP ERROR: ' . $e->getMessage();
    }
    ?>
</div>
<div>
    <?php
    try {
        echo (new CCCustom())
            ->setPaymentData($paymentData)
            ->usePurchaseCommand()
            ->setCallbackUrl('callback-url.php')
            ->render([
                    'button_text'   => 'Place order with Purchase'
            ]);
    } catch (APSException $e) {
        echo 'SETUP ERROR: ' . $e->getMessage();
    }
    ?>
</div>


更新日志

API 文档

此 SDK 是使用以下API 库实现的。

进一步问题

有任何问题吗?只需联系我们

许可证

MIT 许可证下发布。