omnilesolutions/theteller-php-sdk

theteller支付系统的PHP SDK

v0.0.12 2022-04-23 02:13 UTC

This package is auto-updated.

Last update: 2024-09-23 07:33:05 UTC


README

theteller Payments API的PHP SDK

介绍

要使用此SDK,您需要从TheTeller获取一个账户。如果您还没有账户,请在此处创建一个。此外,此SDK遵循TheTeller文档https://www.theteller.net/documentation

安装

您可以使用composer安装此SDK。

composer require omnilesolutions/theteller-php-sdk

认证

TheTeller使用基本HTTP认证。您需要API用户名和密钥,这些可以在TheTeller账户仪表板中的“我的账户”部分找到。

TheTeller结账

要执行结账,您首先需要使用订单有效载荷获取一个支付令牌。

// Get the teller instance.

$teller = new TheTeller\TheTeller($username, $apiKey)

// There is a third argument for mode which is LIVE by default. If you want to
// use this sdk in test mode, instantiate the teller as
// $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST)

// Create order payload
$order = [
   'merchant_id' => 'YOUR-MERCHANT-ID', // available on TheTeller dashboard, under My Account.
   'transaction_id' => 'A UNIQUE TRANSACTION ID',
   'desc' => 'DESCRIPTION OF YOUR ORDER',
   'amount' => '20', // Amount to charge the customer
   'redirect_url' => 'YOUR REDIRECT URL',
   'email' => 'EMAIL ADDRESS OF CUSTOMER'
];

// Process the checkout
$checkout = $teller->requestPaymentToken($order);

// If successful, the returned $checkout will be an instance of TheTeller\Checkout\Checkout

// You now have to redirect the customer to TheTeller to make payment.
// This will take the customer to TheTeller.
$checkout->proceedToPayment();

// When the payment is completed by the customer, TheTeller will
// redirect them back to your provided 'redirect_url' in the order
// with query parameters indicating the status of the payment.

// The response looks like this:
// https://redirect_url?code=000&status=successful&reason=transaction20%successful&transaction_id=000000000000

TheTeller资金转账

您可以从TheTeller仪表板创建的商家浮动账户中转账资金。更多信息在此处

移动货币转账

// Get the teller instance.

$teller = new TheTeller\TheTeller($username, $apiKey);
// There is a third argument for mode which is LIVE by default. If you want to
// use this sdk in test mode, instantiate the teller as
// $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST)

// Create transfer payload
$payload = [
    'amount' => '20', // The transfer amount
    'merchant_id' => 'YOUR-MERCHANT-ID', // available on TheTeller dashboard, under My Account.
    'account_number' => '0240000000', // The mobile account number
    'account_issuer' => 'MTN', // The mobile money network
    'transaction_id' => 'A UNIQUE TRANSACTION ID',
    'desc' => 'DESCRIPTION OF TRANSFER',
    'pass_code' => 'UNIQUE FLOAT ACCOUNT PASSCODE'
]

// Process the transfer
try{

    $teller->transfer('mobile-money', $payload);

    // Transfer is successful

}catch(\Exception $e){
    var_dump($e->getMessage()); // The reason for the failure
}

银行转账

// Get the teller instance.

$teller = new TheTeller\TheTeller($username, $apiKey);
// There is a third argument for mode which is LIVE by default. If you want to
// use this sdk in test mode, instantiate the teller as
// $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST)

// Create transfer payload
$payload = [
    'amount' => '20', // The transfer amount
    'merchant_id' => 'YOUR-MERCHANT-ID', // available on TheTeller dashboard, under My Account.
    'account_bank' => 'GCB', // List of supported banks [here](https://theteller.net/documentation#theTeller_Standard)
    'account_number' => '0082000141685300', // The bank account number
    'transaction_id' => 'A UNIQUE TRANSACTION ID',
    'desc' => 'DESCRIPTION OF TRANSFER',
    'pass_code' => 'UNIQUE FLOAT ACCOUNT PASSCODE'
]

// Process the transfer
try{

    // This step performs an enquiry of the bank account

    $transfer = $teller->transfer('bank', $payload);

    // Enquiry was successfull.
    // You can get the bank account name to ensure
    // that the transfer is going to the intended account.
    $name = $transfer->getAccountName();

    // Complete the transfer
    $transfer->confirm($merchantId); // Your TheTeller Merchant ID

}catch(\Exception $e){
    var_dump($e->getMessage()); // The reason for the failure
}

获取交易状态

// Get the teller instance.

$teller = new TheTeller\TheTeller($username, $apiKey);
// There is a third argument for mode which is LIVE by default. If you want to
// use this sdk in test mode, instantiate the teller as
// $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST)

// Get status
try{

    $response = $teller->getTransactionStatus($transactionId, $merchantId);

}catch(\Exception $e){
    var_dump($e->getMessage()); // The reason for the failure
}

先决条件

贡献

欢迎贡献!请提交一个包含任何错误修复的PR,或者通过brightantwiboasiako@aol.com与我联系,以进行长期承诺。

许可

此开源项目遵循MIT许可