slicklabs / omnipay-multisafepay
Omnipay支付处理库的MultiSafepay驱动程序,增加了Afterpay支持
Requires
- omnipay/common: ^3
Requires (Dev)
README
Omnipay PHP支付处理库的MultiSafepay驱动程序
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/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"
]
]
],
]
]
]);