bsecure/bsecure-payments

bSecure Payment Plugin 是一个 Php 库,允许您安全地处理您的支付。此插件立即创建一个符合 PCI、HIPAA、GDPR 或 CCPA 安全要求的表单。

1.0.0 2022-07-18 13:04 UTC

This package is auto-updated.

Last update: 2024-09-19 11:21:53 UTC


README

Latest Version on Packagist Latest Stable Version Total Downloads License Build Status Code Coverage Scrutinizer Code Quality

bSecure Payments

bSecure Payments 是一个库,允许您安全地处理您的支付。此插件立即创建一个符合 PCI、HIPAA、GDPR 或 CCPA 安全要求的表单。
它适用于 桌面平板移动设备,并持续测试和更新,以提供无摩擦的支付体验。

bSecure Payment Plugin 简介

此支付网关集成指南是针对商家的一项技术集成文档,旨在与 bSecure Payment Plugin 集成,使客户能够通过互联网执行电子商务交易。
它指导商家如何使用 bSecure 的各种功能。商家可以通过此集成在其电子商务网站上启用信用卡支付。

谁应该阅读此指南

此文档旨在为商家的应用开发人员和业务分析师提供,使他们能够有效地与 bSecure Payment Plugin 集成。

商家设置流程

为了使用 bSecure Payment Plugin 处理在线支付,商家需要在 bSecure Builder Portal 上注册。
以下流程假设商家已注册,并且所有与商家相关的参数都已配置。
一旦商家在 bSecure Builder Portal 上注册并获得其支付网关配置,商家就可以使用提供的示例代码执行测试交易。一旦示例交易成功处理,这表明所有必要的系统都已正确配置,商家即可开始操作。

获取您的凭证

  1. 前往 Builder Portal
  2. App Integration >> Sandbox / Live
  3. 从应用集成选项卡复制 Client Id 并将其保存在安全文件中。
  4. 从应用集成选项卡复制 Client Secret 并将其保存在安全文件中。
  5. 从应用集成选项卡复制 Store Slug 并将其保存在安全文件中。
  6. Builder Portal 获取 Merchant Id

安装

您可以通过 composer 安装此包

composer require bsecure/bsecure-payments

先决条件

PHP 7.2.5 以上

依赖项

"guzzlehttp/guzzle": "^7.2"

用法

配置

bSecure Payments

在 app.php 中添加 bSecure 支付提供者

bSecure\Payments\PaymentServiceProvider::class

添加别名

'BsecurePayments' => bSecure\Payments\BsecurePayments::class

发布语言文件。

php artisan vendor:publish --provider="bSecure\Payments\PaymentServiceProvider"

它将在 resources/lang 文件夹中的 vendor/bSecure 文件夹中创建一个文件夹。如果您想自定义错误消息,则可以覆盖该文件。

发布配置文件

php artisan vendor:publish --provider="bSecure\Payments\PaymentServiceProvider" --tag="config"

将一个文件(bSecure.php)放置在 config 文件夹中。

return [
    'client_id' => env('BSECURE_CLIENT_ID', ''),
    'integration_type' => env('BSECURE_INTEGRATION_TYPE','sandbox'), //use 'production' for live orders and 'sandbox' for testing orders. When left empty or `null` the sandbox environment will be used
    'store_slug' => env('BSECURE_STORE_SLUG'),   //If store id is not mentioned your orders will be marked against your default store
    'merchant_id' => env('BSECURE_MERCHANT_ID'),   //If store id is not mentioned your orders will be marked against your default store
];

a) 设置交易

bSecure Payment Plugin 将从商家网站接收一个包含商家认证详情和交易详情的 HTTP POST 请求。支付插件将从客户那里查询所需详情并处理交易

交易详情
[
    'order_id' => '',
    'transaction_dt' => Carbon::now()->toString(),
    'sub_total_amt' => '',
    'discount_amt' => '',
    'total_amt' => '',
    'redirect_url' => '',
],
客户详情
[
    'name' => '',
    'country_code' => '',
    'phone_number' => '',
    'email' => '',
],
客户地址详情
[
    'country' => '',
    'province' => '',
    'city' => '',
    'area' => '',
    'address' => '',
],

示例

创建交易

use bSecure\Payments\BsecurePayments;
$order = new BsecurePayments();

$order->setTransactionDetails($transactionDetails);
$order->setCustomer($customer);
$order->setCustomerAddress($customerAddress);

return $order->createOrder();
return $result;

在createOrder()函数响应中,将返回订单过期时间、结账URL、订单引用和商户订单ID。

array (
  'expiry' => '2020-11-27 10:55:14',
  'checkout_url' => 'bSecure-checkout-url',
  'store_url' => 'store-url',
  'merchant_store_name' => 'your-store-name',
  'order_reference' => 'bsecure-reference',
  'merchant_order_id' => 'your-order-id'
) 

如果您使用的是Web解决方案,则只需将用户重定向到结账URL。

if(!empty($result['checkout_url']))
return redirect($result['checkout_url']); 

如果您有Android或IOS SDK,则使用'checkout_url'初始化您的本地应用的webview,并向其提供订单引用以进行URL匹配。

if(!empty($result['order_reference']))
return $result['order_reference']; 

一旦创建交易,您将能够处理您的结账。

订单放置回调

一旦订单成功放置,bSecure将把客户重定向到您在合作伙伴门户中的“结账重定向URL”设置中提到的URL,并在查询字符串中添加一个额外的参数“order_ref”。

订单更新

通过使用您在"订单放置回调"中收到的order_ref,您可以调用以下方法来获取订单详情。

use bSecure\Payments\BsecurePayments;
$order_ref = $order->order_ref;

$orderStatusUpdate = new BsecurePayments();
$result =  $orderStatusUpdate->orderStatusUpdates($order_ref);
return $result;

订单状态变更Webhook

每当订单状态或支付状态发生变化时,bSecure将在您在合作伙伴门户的环境设置中的“结账订单状态webhook”提到的URL上发送包含完整订单详情的更新(内容将与订单更新的响应相同)。您的webhook必须能够接受POST请求。

在"订单放置回调"和"订单更新"的响应中,您将收到以下提到的格式的订单完整详情。

{
  "status": 200,
  "message": [
    "Request Successful"
  ],
  "body": {
    "merchant_order_id": "your-order-id",
    "order_ref": "bsecure-order-reference",
    "order_type": "App/Manual/Payment gateway",
    "placement_status": "6",
    "payment_status": null,
    "customer": {
      "name": "",
      "email": "",
      "country_code": "",
      "phone_number": "",
      "gender": "",
      "dob": ""
    },
    "payment_method": {
      "id": 5,
      "name": "Debit/Credit Card"
    },
    "card_details": {
      "card_type": null,
      "card_number": null,
      "card_expire": null,
      "card_name": null
    },
    "delivery_address": {
      "country": "",
      "province": "",
      "city": "",
      "area": "",
      "address": "",
      "lat": "",
      "long": ""
    },
    "shipment_method": {
      "id": 0,
      "name": "",
      "description": "",
      "cost": 0
    },
    "items": [
      {
        "product_id": "",
        "product_name": "",
        "product_sku": "",
        "product_qty": ""
      },
    ],
    "created_at": "",
    "time_zone": "",
    "summary": {
      "total_amount": "",
      "sub_total_amount": "",
      "discount_amount": "",
      "shipment_cost": "",
      "merchant_service_charges": ""
    }
  },
  "exception": null
}

管理订单和支付

支付状态

订单状态

变更日志

有关最近更改的更多信息,请参阅变更日志

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件

贡献

"bSecure – 您的通用结账"是开源软件。