deepay/deepay-php

DeePay library for PHP

1.0.0 2018-11-23 02:51 UTC

This package is auto-updated.

Last update: 2024-05-23 15:16:24 UTC


README

This is a PHP library fo DeePay API. Merchant ID and API key are needed for authenication. Sign up here.

Install

With composer (Recommended)

Install the package via Composer:

composer require deepay/deepay-php

Manual download

Download the package and include it in your code.

require_once('deepay-php-master/deepay.php');

Getting Started

Initialize

Generate an instance of DeePay\DeePay, which will be used to call the API.

use DeePay\DeePay;

$deepay = new DeePay('Merchant ID', 'Api Key');

Create Order

$params = array(
  'out_trade_id' => 'E201809123',
  'price_amount' => 10.0001,
  'price_currency' => 'CNY',
  'notify_url' => 'http://example.com/notify',
  'callback_url' => 'http://example.com/',
  'title' => 'iPhone X',
  'attach' => 'additional info'
);

$order = $deepay->createOrder($params);

// $order is an instance of \DeePay\Order
var_dump($order->toArray());

Checkout Order

$order = $deepay->checkoutOrder(array(
  'transaction_id' => '20181121113652525198',
  // or use out_trade_id
  // 'out_trade_id' => 'E52525198',
  'pay_currency' => 'BTC',
  'email' => 'info@example.com',
));

var_dump($order->toArray());

Query Order

$order = $deepay->checkoutOrder('20181121113652525198');
// or use out_trade_id
$order = $deepay->checkoutOrder('E113652525198');

var_dump($order->toArray());

Get Exchange Rate

$rate = \DeePay\DeePay::getExchangeRate('ETH', 'CNY');
var_dump($rate);

Payment Notification

$order = $_POST;
if ($deepay->checkSign($order) {
	if ($order['status'] == 'confirmed') {
		// process the order according to status
	}
	
	// echo 'ok' when you finish the job
	exit('ok');
} else {
	echo 'Notifycation is invalid';
}