2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-pxpay

Payment Express controller

image

twohill/silverstripe-pxpay

Payment Express controller

  • Tuesday, April 10, 2018
  • by twohill
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 17 % Grown

The README.md

silverstripe-pxpay

A module that integrates your controller with Payment Express., (*1)

Requirements

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

Installation

Using composer, (*2)

composer require twohill/silverstripe-pxpay

License

BSD 3-Clause "New" or "Revised" License. See License, (*3)

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., (*4)


--- 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, (*5)


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., (*6)

If the issue does look like a new bug:, (*7)

  • 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., (*8)

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., (*9)

The Versions

10/04 2018

dev-master

9999999-dev https://github.com/twohill/silverstripe-pxpay

Payment Express controller

  Sources   Download

BSD-3-Clause

The Requires

 

by Al Twohill

silverstripe paymentexpress