项目作者: mfauveau

项目描述 :
Safecharge driver for the Omnipay PHP payment processing library
高级语言: PHP
项目地址: git://github.com/mfauveau/omnipay-safecharge.git
创建时间: 2015-05-15T04:37:18Z
项目社区:https://github.com/mfauveau/omnipay-safecharge

开源协议:MIT License

下载


Omnipay: SafeCharge

SafeCharge Direct Gateway driver for the Omnipay PHP payment processing library

Build Status
Latest Stable Version
Total Downloads

Omnipay is a framework agnostic, multi-gateway payment
processing library for PHP 5.3+. This package implements SafeCharge Gateway support for Omnipay.

If you are looking for the “SafeCharge Cashier” implementation see Omnipay Gate2Shop. It’s the same thing except for the endpoint URL.

Installation

Omnipay is installed via Composer. To install, simply add it
to your composer.json file:

  1. {
  2. "require": {
  3. "mfauveau/omnipay-safecharge": "~2.0"
  4. }
  5. }

And run composer to update your dependencies:

  1. $ curl -s http://getcomposer.org/installer | php
  2. $ php composer.phar update

Usage

The following gateways are provided by this package:

  • SafeCharge Direct Gateway (without support for 3D secure at this time, feel free to do a PR ;))

For general usage instructions, please see the main Omnipay
repository.

Setup

  1. $gateway = Omnipay::create('Safecharge');
  2. $gateway->initialize(array(
  3. 'username' => 'AccountTestTRX',
  4. 'password' => 'password',
  5. 'testMode' => true,
  6. 'vendorId' => 'Vendor ID',
  7. 'websiteId' => 'Website ID'
  8. ));

Authorize

  1. $cardData = [
  2. 'name' => 'John Doe',
  3. 'number' => '4000021059386316',
  4. 'expiryMonth' => '06',
  5. 'expiryYear' => '2016',
  6. 'cvv' => '123'
  7. ];
  8. try {
  9. $response = $gateway->authorize([
  10. 'amount' => '100.00',
  11. 'currency' => 'USD',
  12. 'card' => $cardData
  13. ])->send();
  14. if ($response->isSuccessful()) {
  15. print_r($response->getData());
  16. } else {
  17. print $response->getMessage();
  18. }
  19. } catch (Exception $e) {
  20. print $e->getMessage();
  21. }

Purchase

  1. $cardData = [
  2. 'name' => 'John Doe',
  3. 'number' => '4000021059386316',
  4. 'expiryMonth' => '06',
  5. 'expiryYear' => '2016',
  6. 'cvv' => '123'
  7. ];
  8. try {
  9. $response = $gateway->purchase([
  10. 'amount' => '100.00',
  11. 'currency' => 'USD',
  12. 'card' => $cardData
  13. ])->send();
  14. if ($response->isSuccessful()) {
  15. print_r($response->getData());
  16. } else {
  17. print $response->getMessage();
  18. }
  19. } catch (Exception $e) {
  20. print $e->getMessage();
  21. }

Purchase using a Token

  1. try {
  2. $response = $gateway->purchase([
  3. 'amount' => '100.00',
  4. 'currency' => 'USD',
  5. 'token' => 'XXXXXXXXXXXXXXXXXXXXX',
  6. 'transactionId' => '123456789'
  7. ])->send();
  8. if ($response->isSuccessful()) {
  9. print_r($response->getData());
  10. } else {
  11. print $response->getMessage();
  12. }
  13. } catch (Exception $e) {
  14. print $e->getMessage();
  15. }

Void

  1. try {
  2. $response = $gateway->void([
  3. 'amount' => '100.00',
  4. 'currency' => 'USD',
  5. 'token' => 'XXXXXXXXXXXXXXXXXXXXX',
  6. 'transactionId' => '123456789',
  7. 'authCode' => '12345',
  8. 'expMonth' => '06',
  9. 'expYear' => '2016'
  10. ])->send();
  11. if ($response->isSuccessful()) {
  12. print_r($response->getData());
  13. } else {
  14. print $response->getMessage();
  15. }
  16. } catch (Exception $e) {
  17. print $e->getMessage();
  18. }

Refund

  1. try {
  2. $response = $gateway->refund([
  3. 'amount' => '100.00',
  4. 'currency' => 'USD',
  5. 'token' => 'XXXXXXXXXXXXXXXXXXXXX',
  6. 'transactionId' => '123456789',
  7. 'authCode' => '12345',
  8. 'expMonth' => '06',
  9. 'expYear' => '2016'
  10. ])->send();
  11. if ($response->isSuccessful()) {
  12. print_r($response->getData());
  13. } else {
  14. print $response->getMessage();
  15. }
  16. } catch (Exception $e) {
  17. print $e->getMessage();
  18. }

Support

If you are having general issues with Omnipay, we suggest posting on
Stack Overflow. Be sure to add the
omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project,
or ask more detailed questions, there is also a mailing list which
you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker,
or better yet, fork the library and submit a pull request.