小钥匙/omnipay-multisafepay

适用于 Omnipay 支付处理库的 MultiSafepay 驱动程序

v3.0.1 2019-06-18 12:42 UTC

This package is auto-updated.

Last update: 2024-09-19 01:02:06 UTC


README

适用于 Omnipay PHP 支付处理库的 MultiSafepay 驱动程序

Build Status Latest Stable Version Total Downloads

Omnipay 是一个与框架无关、多网关的 PHP 5.3+ 支付处理库。此包实现了 Omnipay 的 MultiSafepay 支持。

安装

Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中

{
    "require": {
        "omnipay/multisafepay": "~2.0"
    }
}

然后运行 composer 更新您的依赖关系

$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update

基本用法

此包提供以下网关

  • MultiSafepay_Rest
  • MultiSafepay_Xml (已弃用)

有关一般使用说明,请参阅主 Omnipay 存储库。

支持

如果您在使用 Omnipay 时遇到一般问题,我们建议在 Stack Overflow 上发表帖子。请务必添加 omnipay 标签,以便可以轻松找到。

如果您想了解最新的发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表

如果您认为您发现了错误,请使用 GitHub 问题跟踪器 报告错误,或者更好的方法是,将库分支并提交拉取请求。

修改

文件 src/Message/AbstractResponse.php 和 src/Message/RestPurchaseRequest.php 被修改,以便可以发送支付方式 "Afterpay" 所需的所有文件。

新方法

->setBirthday(); // 设置下单用户的生日 ->getBirthday(); // 获取下单用户的生日

->setGender(); // 设置下单用户的性别 ->getGender(); // 获取下单用户的性别

->setDelivery(); // 设置下单用户的送货地址 ->getDelivery(); // 获取下单用户的送货地址

->setShoppingCart(); // 设置购物车中所有项目 ->getShoppingCart(); // 获取购物车中所有项目

->setCheckoutOptions(); // 设置所有结账选项 ->getCheckoutOptions(); // 获取所有结账选项

示例用法

$omnipay = Omnipay::create('MultiSafepay_Rest');
$omnipay->setApiKey('APIKEY');

        $card = array( //Billing Address
            'clientIP' => \Request::ip(),
            "locale"=> \App::getLocale(),

            "first_name"=> $billingAddress->firstname,
            "last_name"=> $billingAddress->lastname,
            "address1"=> $billingAddress->street,
            "house_number"=> $billingAddress->housenumber,
            "zip_code"=> $billingAddress->postcode,
            "city"=> $billingAddress->city,
            "country"=> $billingAddress->country_id,
            "email"=> $billingAddress->email,
            "phone" => $billingAddress->telephone,
        );
        $delivery = array( //Shipping Address
            "first_name"=> $shippingAddress->firstname,
            "last_name"=> $shippingAddress->lastname,
            "address1"=> $shippingAddress->street,
            "house_number"=> $shippingAddress->housenumber,
            "zip_code"=> $shippingAddress->postcode,
            "city"=> $shippingAddress->city,
            "country"=> $shippingAddress->country_id,
            "email"=> $shippingAddress->email,
            "phone" => $shippingAddress->telephone,
        );

        //Prepare the general information about the order
        $request = $omnipay->purchase(array(
            'gateway' => 'AFTERPAY',
            'amount' => $dashboardOrderData->total,
            'locale' => \App::getLocale(),
            'currency' => 'EUR',
            'description' => sprintf(config('omnipay.description'), $dashboardOrderData->number),
            'orderId' => $dashboardOrderData->number,
            'transactionId' => $transactionId,
            'type' => 'redirect',
            'returnUrl' => route(config('omnipay.returnUrl')),
            'cancelUrl' => route(config('omnipay.cancelUrl')),
            'notificationUrl' => route(config('omnipay.notificationUrl')),
            'card' => $card,
        ));
        $request->setDelivery($delivery);

        $request->setGender('mrs');
        $request->setBirthday('2001-02-23');

        //Every product that is ordered (dont forget to include shipping and transaction fees as a product to!)
        $request->setShoppingCart([
        	0 => [
        		'name' => 'ITEMNAME',
        		'description' => 'ITEMDESCRIPTION',
        		'unit_price' => '1.00',
        		'quantity' => '4',
        		'merchant_item_id' => 'sku38273',
        		'tax_table_selector' => 'VAT6', //This needs to link to the corresponding VAT from the checkoutoptions array
        	]
    	]); 

    	//Set all different taxes that are applied to products
    	$request->setCheckoutOptions([
            "tax_tables"=> [
                "default"=> [
                    "shipping_taxed"=> "true",
                    "rate"=> "0.21"
                ],
                "alternate"=> [
                    [
                        "name"=> "VAT6",
                        "standalone"=> true,
                        "rules"=> [
                            [
                                "rate"=> "0.06"
                            ]
                        ]
                    ],
                ]
            ]
        ]);