twohill/silverstripe-pxpay 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

twohill/silverstripe-pxpay

Composer 安装命令:

composer require twohill/silverstripe-pxpay

包简介

Payment Express controller

README 文档

README

A module that integrates your controller with Payment Express.

Requirements

  • SilverStripe ^4
  • php-curl
  • php-simplexml

Installation

Using composer

composer require twohill/silverstripe-pxpay

License

BSD 3-Clause "New" or "Revised" License. See License

Example configuration

Configure your PxPayment details in a config yml file. You can specify different settings for dev or live modes. A useful option for doing this is to use your sandbox credentials when in dev mode.

---
Only:
  environment: 'live'
---
Twohill\PXPay\PxPaymentController:
  PxPayURL: https://sec.paymentexpress.com/pxaccess/pxpay.aspx
  PxPayUserId: MyUserID
  PxPayKey: xxxxxx

---
Only:
  environment: 'dev'
---
Twohill\PXPay\PxPaymentController:
  PxPayURL: https://sec.paymentexpress.com/pxaccess/pxpay.aspx
  PxPayUserId: MyUserID_dev
  PxPayKey: xxxxxx
  

Example usage

Return the PxPaymentController as the result of a payment method

class MyPageController extends PageController
{
    private static $allowed_actions = [
        'thankyou',
        'pay_order',
        'unsuccessful',
    ];
    
    public function thankyou(HTTPRequest $request)
    {
        $content = '';
        if ($request->getSession()->get('OrderID')) {
            $order = Order::get()->byID($request->getSession()->get('OrderID'));

            if ($order) {
           
                $payment = $order->Payment();

                if ($payment && $payment->TxnId) {
                    if ($payment->Processed) {
                        $sendEmail = false;
                    } else {
                        $payment->Processed = true;
                        $payment->write();
                    }
                } else {
                    $this->redirect($this->Link('pay-order/submit'));
                }
                $content = $this->ThankYouForPayingContent; // From MyPage $db
            }

            $request->getSession()->clear("OrderID");
            return $this->customise(new ArrayData([
                'Content' => DBField::create_field('HTMLFragment', $content),
                'Form' => ''
            ]));
        }
        return $this->redirect($this->Link());
    }
    /**
     * Process the payment
     *
     * @param HTTPRequest $request
     * @return PxPaymentController
     * @throws ValidationException
     */
    public function pay_order(HTTPRequest $request)
    {
    
        // Load the payment details somehow
        $payment = null;

        if ($request->getSession()->get('OrderID')) {
           
            $order = Order::get()->byID($request->getSession()->get('OrderID'));

            if ($order) {
                $payment = new PxPayment();
                $payment->TxnType = "Purchase";
                $payment->MerchantReference = $order->InvoiceNumber;
                $payment->TxnData1 = $order->CompanyName;
                $payment->TxnData2 = $order->Address;
                $payment->TxnData3 = $order->City;
                $payment->EmailAddress = $order->Contact()->Email;
                $payment->AmountInput = $order->Total;
                $payment->CurrencyInput = "NZD";
                $payment->InvoiceID = $order->ID;
                $payment->write();
                }
            }
        }
        return new PxPaymentController($this, $request, $payment, $this->Link("thankyou"), $this->Link("unsuccessful"));
    }

    /** 
     * Action when payment is unsuccessful. 
     */
    public function unsuccessful(HTTPRequest $request)
    {
        if ($request->getSession()->get('OrderID')) {
            $order = Order::get()->byID($request->getSession()->get('OrderID'));
            if ($order) {
                return $this->customise([
                    'Content' => DBField::create_field('HTMLFragment', $this->UnsuccessfulContent),
                    'Form' => ''
                ]);
            }
        }
        return $this->redirect($this->Link());
    }


}

Maintainers

Bugtracker

Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.

If the issue does look like a new bug:

  • Create a new issue
  • Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots and screencasts can help here.
  • Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, Operating System, any installed SilverStripe modules.

Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.

Development and contribution

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

统计信息

  • 总下载量: 476
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固