abeta-io/abeta-punchout

Abeta 扩展程序,适用于 Laravel

dev-main 2023-12-10 12:22 UTC

This package is auto-updated.

Last update: 2024-09-10 13:54:16 UTC


README

这是 Abeta 的官方 Laravel 插件。通过 Abeta,您可以快速轻松地提供 OCI 和 cXML PunchOut。与 Coupa、Oracle 和 Sap Ariba 等采购系统/ERP 连接。借助 B2B 连接,通过增加现有客户的营业额或通过 B2B 连接获取新客户。

安装

通过 composer 安装

composer require abeta-io/laravel

快速开始

使用类

use AbetaIO\Laravel\AbetaPunchout;

// Don't forget to make the necessary changes to your VerifyCsrfToken file!

//Create an endpoint for the setupRequest
Route::post('/abeta-setup-request', function (Request $request) {
    return AbetaPunchout::setupRequest($request);
});

//Create an endpoint for a login
Route::post('/abeta-login', function (Request $request) {
    $loggedInUser = AbetaPunchout::login($request);
    // redirect logged in user to shop
});

//Create an endpoint for a login
Route::post('/abeta-cart', function (Request $request) {
    //Return Cart and Product Model or Array to Abeta
    $returned = AbetaPunchout::returnCart($cart, $products);

    //Return Customer to Abeta
    return AbetaPunchout::returnCustomer();
});

使用全局助手函数检查用户是否是 PunchOut 用户

if( is_abeta_punchout_user() ) {
    //show button to abeta return cart
} else {
    //show regulal checkout button
}

使用除 User 模型之外的其他模型

想要使用 Laravel 默认的 User 模型之外的其他模型?创建一个名为 abeta.php 的配置文件(在 config/ 目录下)。之后,将所需的值替换为您自己的。

<?php

/*
* Configuration of the Abeta Punchout Package, used to offer OCI and cXML via the Abeta Middleware.
*/

return [
    
    /*
    * Customer model, used to select customer from.
    */
    'customerModel' => '\App\Models\User',

    /*
    * Auth provider
    */
    'auth' => '\Illuminate\Support\Facades\Auth',

    /*
    * String, representing database column of username
    */
    'username' => 'email',

    /*
    * String, representing database column of password
    */
    'password' => 'password',
   

];