项目作者: dipnot

项目描述 :
Unofficial PHP wrapper for Direct Pay Online API
高级语言: PHP
项目地址: git://github.com/dipnot/direct-pay-online-php.git
创建时间: 2020-11-06T08:08:45Z
项目社区:https://github.com/dipnot/direct-pay-online-php

开源协议:MIT License

下载


Direct Pay Online API Wrapper for PHP

Latest Stable Version
Total Downloads

Unofficial PHP wrapper for Direct Pay Online API

Inspired by cy6erlion/direct-pay-online

Only covers createToken and verifyToken services.

Dependencies

  • PHP 5.6.36 or higher
  • ext-curl
  • ext-simplexml
  • ext-json

Installation

You can install via Composer.

  1. composer require dipnot/direct-pay-online-php

Usage

You can see the full example in examples folder.

Config

All request are needs a Config.

  1. use Dipnot\DirectPayOnline\Config;
  2. $config = new Config();
  3. $config->setCompanyToken("9F416C11-127B-4DE2-AC7F-D5710E4C5E0A");
  4. $config->setTestMode(true);

Transaction

  1. use Dipnot\DirectPayOnline\Model\Transaction;
  2. $transaction = new Transaction(100, "USD");

Service

  1. use Dipnot\DirectPayOnline\Model\Service;
  2. $service = new Service("Test Product", 3854, "2020/02/12 11:21");

“createToken” Request

Create a token to start payment process.

  1. use Dipnot\DirectPayOnline\Request\CreateTokenRequest;
  2. $createTokenRequest = new CreateTokenRequest($config);
  3. $createTokenRequest->setTransaction($transaction);
  4. $createTokenRequest->addService($service1);
  5. $createTokenRequest->addService($service2);
  6. $createToken = $createTokenRequest->execute();
  7. print_r($createToken);

“verifyToken” Request

Get the payment result by using VerifyTokenRequest.

  1. use Dipnot\DirectPayOnline\Request\VerifyTokenRequest;
  2. $verifyTokenRequest = new VerifyTokenRequest($config);
  3. $verifyTokenRequest->setTransactionToken($_GET["TransactionToken"]);
  4. $verifyToken = $verifyTokenRequest->execute();
  5. print_r($verifyToken);

Getting the payment URL

Get the payment URL with the created token to redirect the user to the payment page.

  1. $paymentUrl = $createTokenRequest->getPaymentUrl($createToken["TransToken"]);
  2. print_r($paymentUrl);

Test values

You can fill the personal info randomly in the payment page.

Value
Company token 9F416C11-127B-4DE2-AC7F-D5710E4C5E0A
Card number 5436886269848367
Card expiry date (Month/Year) 12/22
Card CVV 123

License

License: MIT