HEX
Server: nginx/1.24.0
System: Linux prod-btpayments-io 6.14.0-1018-aws #18~24.04.1-Ubuntu SMP Mon Nov 24 19:46:27 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.3.19
Disabled: NONE
Upload Files
File: /var/www/BtPayments/BtPayments-platform/app/Models/MerchantIntegrationConfig.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MerchantIntegrationConfig extends Model
{
    const TYPE_SHOPIFY = 'shopify';

    protected $guarded = [];

    protected $casts = [
        'data' => 'object',
    ];

    /**
     * Relation: 商户
     */
    public function merchant()
    {
        return $this->belongsTo(Merchant::class);
    }

    /**
     * Attribute: Shopify 收银台代码
     */
    public function getShopifyCheckoutCodeAttribute()
    {
        $gatewayName = 'BtPayments';
        $merchantNo = $this->merchant->id;
        $paymentUrl = route('gateway.payments.shopify.checkout');

        $code = file_get_contents(resource_path('views/portal/integrations/stubs/shopify-payment-code.stub.html'));

        $code = str_replace('{{ $gatewayName }}', $gatewayName, $code);
        $code = str_replace('{{ $merchantNo }}', $merchantNo, $code);
        $code = str_replace('{{ $paymentUrl }}', $paymentUrl, $code);

        return $code;
    }
}