jinomdeveloper/payment-php-sdk

此包的最新版本(1.0.0)没有可用的许可证信息。

金诺支付网关

1.0.0 2023-11-03 02:37 UTC

This package is not auto-updated.

Last update: 2024-09-21 05:18:35 UTC


README

安装

composer require jinomdeveloper/payment-php-sdk

环境

您可以为 SERVER_KEYIs it Production 设置 JinomPayment

示例

$jinom_payment = new \Jinom\Payment\JinomPayment('YOUR SERVER_KEY', 'IS PRODUCTION');

或者

如果您使用 Laravel,请使用此配置并将其保存为 jinompay.php

<?php

return [

    "server_key" => env("JINOM_PAYMENT_KEY", ""),

    "is_production" => env("JINOM_PAYMENT_IS_PRODUCTION", false),

    "base_url" => env("JINOM_PAYMENT_IS_PRODUCTION", false) ? "https://payment.jinom.net" : "https://va.sandbox.jinom.net",
];  

不要忘记将其添加到 .env 文件中。

JINOM_PAYMENT_KEY=
JINOM_PAYMENT_IS_PRODUCTION=
JINOM_PAYMENT_IS_PRODUCTION=

实现配置

$jinom_payment = new \Jinom\Payment\JinomPayment(config('jinompay.server_key'), config('jinompay.is_production'));

使用方法

<?php
...
use Jinom\Payment\JinomPayment;
use Jinom\Payment\Transaction;
... 

class TransactionController extends Controller {
  ...
  public function topUp(Request $request)
  {
      $nominal = 350000;
      $jinom_payment = new JinomPayment('YOUR SERVER_KEY', 'IS PRODUCTION');

      // Automatic Generate Order ID with Time combination
      $order_id = $jinom_payment->generate_order_id("TOPUP"); 

      $transaction = new Transaction();
      $transaction->setTransactionDetails(
          $transaction->createTransactionDetail($order_id, $nominal)
      );

      $transaction->setCustomerDetails($transaction->createCustomerDetail("John Doe", "john@doe.com", "083119030777"));

      $items = [];

      // Item name, price, quantity
      $items[] = $transaction->createItemDetail("Apple", 350000, 1);

      $transaction->setItemDetails($items);

      $charge = $jinom_payment->charge($transaction, [
          'payment_type' => 'bank_transfer',
          'bank_transfer' => [
            'bank' => 'bri', // required |  It can be bri, bni, bca
            'va_number' => '88888888' // optional
          ]
      ]);

      return response()->json([
          'charge' => $charge
      ]);
  }
}

...