定制 sebudesign/buckaroo-json 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sebudesign/buckaroo-json

最新稳定版本:1.2.2

Composer 安装命令:

composer require sebudesign/buckaroo-json

包简介

Connect to the JSON API from Buckaroo

README 文档

README

This package will connect to the JSON API of Buckaroo, if you prefer SOAP over JSON use this package.

Packagist Packagist Code Climate

Installation

This package uses Composer as PHP dependency manager, you need to run the following command within the root of your project.

composer require sebudesign/buckaroo-json

Usage

<?php 

require 'vendor/autoload.php';

use SeBuDesign\BuckarooJson\Transaction;
use SeBuDesign\BuckarooJson\TransactionStatus;
use SeBuDesign\BuckarooJson\Parts\IpAddress;
use SeBuDesign\BuckarooJson\Parts\Service;
use SeBuDesign\BuckarooJson\Parts\OriginalTransactionReference;
use SeBuDesign\BuckarooJson\Parts\ContinueOnIncomplete;

class Foo
{
    public function startTransactionAllOptions()
    {
        // Replace your website-key and secret-key with your keys
        $transaction = new Transaction('website-key', 'secret-key');
        
        // Create a test transaction
        $transaction->putInTestMode();
        
        // Set the currency of the transaction
        $transaction->setCurrency('EUR');
        
        // Set the amount credit
        $transaction->setAmountCredit(1.99);
        
        // Set the amount debit
        $transaction->setAmountDebit(1.99);
        
        // Set the unique invoice number
        $transaction->setInvoice('UniqueInvoice');
        
        // Set the order number
        $transaction->setOrder('SetOrderNumber');
        
        // Set the description for the transaction
        $transaction->setDescription('Your transaction description');
        
        // Set the client IP
        $oIpAddress = new IpAddress();
        $oIpAddress->setAddress('127.0.0.1');
        $transaction->setClientIP($oIpAddress);
        
        // Set the client user agent
        $transaction->setClientUserAgent('google-chrome');
        
        // Set the return url
        $transaction->setReturnURL('https://google.com/');
        
        // Set the return url in case of a cancellation
        $transaction->setReturnURLCancel('https://google.com/');
        
        // Set the return url in case of an error
        $transaction->setReturnURLError('https://google.com/');
        
        // Set the return url in case of a rejection
        $transaction->setReturnURLReject('https://google.com/');
        
        // Set the original transaction object
        $oOriginalTransactionReference = new OriginalTransactionReference();
        $oOriginalTransactionReference->setType('type');
        $oOriginalTransactionReference->setReference('reference');
        $transaction->setOriginalTransactionReference($oOriginalTransactionReference);
        
        // Set the push url to push the transaction status to
        $transaction->setPushURL('https://google.com/');
       
        // Set the push url to push the transaction status in case of a failure
        $transaction->setPushURLFailure('https://google.com/');
        
        // Set the original transaction key
        $transaction->setOriginalTransactionKey('original-transaction-key');
        
        // Do you want to start a recurring payment?
        // Default: false
        $transaction->setStartRecurrent(true);
        
        // Continue on incomplete payment?
        // Default: ContinueOnIncomplete::No
        $transaction->setContinueOnIncomplete(ContinueOnIncomplete::RedirectToHTML);
        
        // Add a service
        $service = new Service();
        $service->setName('name');
        $service->setAction('action');
        $service->setVersion(3);
        
        // Service parameters
        $service->addParameter('name', 'value');
        $service->addParameter('name', 'value', 'group-id', 'group-type');
       
        $service->hasParameter('name'); // true
        $service->hasParameter('foo'); // false

        $service->getParameter('name');
        $service->removeParameter('name');
        
        $transaction->addService($service);
        
        // Add a custom parameter
        $transaction->addCustomParameter('name', 'value');
        // Has a custom parameter
        $transaction->hasCustomParameter('name');
        // Remove a custom parameter
        $transaction->removeCustomParameter('name');
        // Has a custom parameter
        $transaction->hasCustomParameter('name');
        
        // Add an additional parameter
        $transaction->addAdditionalParameter('name', 'value');
        // Has an additional parameter
        $transaction->hasAdditionalParameter('name');
        // Remove an additional parameter
        $transaction->removeAdditionalParameter('name');
        // Has an additional parameter
        $transaction->hasAdditionalParameter('name');
        
        // Add a client header
        $transaction->addClientHeader('Culture', 'nl-NL');
        // Has a specific client header
        $transaction->hasClientHeader('Culture'); // True
        $transaction->hasClientHeader('SomeCustomHeader'); // False
        // Retrieve a client header
        $transaction->getClientHeader('Culture'); // nl-NL
        $transaction->getClientHeader('SomeCustomHeader'); // null
        
        // Start the transaction
        $transactionResponse = $transaction->start();
        
        var_dump(
            $transactionResponse->getTransactionKey(),
            $transactionResponse->getOrder(),
            $transactionResponse->getIssuingCountry(),
            $transactionResponse->getInvoice(),
            $transactionResponse->getServiceCode(),
            $transactionResponse->getCurrency(),
            $transactionResponse->getAmountDebit(),
            $transactionResponse->getAmountCredit(),
            $transactionResponse->getTransactionType(),
            $transactionResponse->getMutationType(),
            $transactionResponse->getRelatedTransactions(),
            $transactionResponse->hasConsumerMessage(),
            $transactionResponse->hasToReadConsumerMessage(),
            $transactionResponse->getConsumerMessage(),
            $transactionResponse->isTest(),
            $transactionResponse->hasStartedRecurringPayment(),
            $transactionResponse->isRecurringPayment(),
            $transactionResponse->isCancelable(),
            $transactionResponse->getCustomerName(),
            $transactionResponse->getPayerHash(),
            $transactionResponse->getPaymentKey(),
            $transactionResponse->getStatusCode(),
            $transactionResponse->getStatusSubCode(),
            $transactionResponse->getDateTimeOfStatusChange(),
            $transactionResponse->hasRequiredAction(),
            $transactionResponse->getRequestedInformation(),
            $transactionResponse->hasToRedirect(),
            $transactionResponse->hasToPayRemainder(),
            $transactionResponse->getRemainderAmount(),
            $transactionResponse->getRemainderCurrency(),
            $transactionResponse->getRemainderGroupTransaction(),
            $transactionResponse->getRedirectUrl(),
            $transactionResponse->getServices(),
            $transactionResponse->getService('name'),
            $transactionResponse->getServiceParameters('name'),
            $transactionResponse->getCustomParameters(),
            $transactionResponse->getAdditionalParameters(),
            $transactionResponse->hasErrors(),
            $transactionResponse->getErrors()
        );
    }
    
    public function getTransactionStatus()
    {
        $transactionStatus = new TransactionStatus('website-key', 'secret-key');
        $transactionResponse = $transactionStatus->get('transaction-key');
        
        var_dump(
            $transactionResponse->getTransactionKey(),
            $transactionResponse->getOrder(),
            $transactionResponse->getIssuingCountry(),
            $transactionResponse->getInvoice(),
            $transactionResponse->getServiceCode(),
            $transactionResponse->getCurrency(),
            $transactionResponse->getAmountDebit(),
            $transactionResponse->getAmountCredit(),
            $transactionResponse->getTransactionType(),
            $transactionResponse->getMutationType(),
            $transactionResponse->getRelatedTransactions(),
            $transactionResponse->hasConsumerMessage(),
            $transactionResponse->hasToReadConsumerMessage(),
            $transactionResponse->getConsumerMessage(),
            $transactionResponse->isTest(),
            $transactionResponse->hasStartedRecurringPayment(),
            $transactionResponse->isRecurringPayment(),
            $transactionResponse->isCancelable(),
            $transactionResponse->getCustomerName(),
            $transactionResponse->getPayerHash(),
            $transactionResponse->getPaymentKey(),
            $transactionResponse->getStatusCode(),
            $transactionResponse->getStatusSubCode(),
            $transactionResponse->getDateTimeOfStatusChange(),
            $transactionResponse->hasRequiredAction(),
            $transactionResponse->getRequestedInformation(),
            $transactionResponse->hasToRedirect(),
            $transactionResponse->hasToPayRemainder(),
            $transactionResponse->getRemainderAmount(),
            $transactionResponse->getRemainderCurrency(),
            $transactionResponse->getRemainderGroupTransaction(),
            $transactionResponse->getRedirectUrl(),
            $transactionResponse->getServices(),
            $transactionResponse->getService('name'),
            $transactionResponse->getServiceParameters('name'),
            $transactionResponse->getCustomParameters(),
            $transactionResponse->getAdditionalParameters(),
            $transactionResponse->hasErrors(),
            $transactionResponse->getErrors()
        );
    }
    
    public function getTransactionStatuses()
    {
        $transactionStatus = new TransactionStatus('website-key', 'secret-key');
        
        $transactionStatus->addTransactionByKey('transaction-key');
        $transactionStatus->addTransactionByInvoice('invoice');
        
        $transactionResponses = $transactionStatus->get();
        
        $transactionStatus = new TransactionStatus('website-key', 'secret-key');
                    
        $transactionStatus->addTransactionByKey('transaction-key');
        $transactionStatus->addTransactionByKey('transaction-key');
        
        $transactionResponses = $transactionStatus->get();
        
        $transactionStatus = new TransactionStatus('website-key', 'secret-key');
                    
        $transactionStatus->addTransactionByKey('invoice');
        $transactionStatus->addTransactionByKey('invoice');
        
        $transactionResponses = $transactionStatus->get();
        
        foreach ($transactionResponses as $transactionResponse) {
            var_dump(
                $transactionResponse->getTransactionKey(),
                $transactionResponse->getOrder(),
                $transactionResponse->getIssuingCountry(),
                $transactionResponse->getInvoice(),
                $transactionResponse->getServiceCode(),
                $transactionResponse->getCurrency(),
                $transactionResponse->getAmountDebit(),
                $transactionResponse->getAmountCredit(),
                $transactionResponse->getTransactionType(),
                $transactionResponse->getMutationType(),
                $transactionResponse->getRelatedTransactions(),
                $transactionResponse->hasConsumerMessage(),
                $transactionResponse->hasToReadConsumerMessage(),
                $transactionResponse->getConsumerMessage(),
                $transactionResponse->isTest(),
                $transactionResponse->hasStartedRecurringPayment(),
                $transactionResponse->isRecurringPayment(),
                $transactionResponse->isCancelable(),
                $transactionResponse->getCustomerName(),
                $transactionResponse->getPayerHash(),
                $transactionResponse->getPaymentKey(),
                $transactionResponse->getStatusCode(),
                $transactionResponse->getStatusSubCode(),
                $transactionResponse->getDateTimeOfStatusChange(),
                $transactionResponse->hasRequiredAction(),
                $transactionResponse->getRequestedInformation(),
                $transactionResponse->hasToRedirect(),
                $transactionResponse->hasToPayRemainder(),
                $transactionResponse->getRemainderAmount(),
                $transactionResponse->getRemainderCurrency(),
                $transactionResponse->getRemainderGroupTransaction(),
                $transactionResponse->getRedirectUrl(),
                $transactionResponse->getServices(),
                $transactionResponse->getService('name'),
                $transactionResponse->getServiceParameters('name'),
                $transactionResponse->getCustomParameters(),
                $transactionResponse->getAdditionalParameters(),
                $transactionResponse->hasErrors(),
                $transactionResponse->getErrors()
            );
        }
    }
}

统计信息

  • 总下载量: 16.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固