evolutionscript / metamaskipn

接受来自 Metamask 钱包的 Binance Smart Chain (BSC) 代币支付,可用于法定货币或其他加密货币。

1.0.2 2022-07-09 05:08 UTC

This package is auto-updated.

Last update: 2024-09-09 09:53:54 UTC


README

MetamaskIPN 允许您在每次从 Metamask 钱包收到支付时,在您的网站上接收即时支付通知 (IPN)。

这个库允许您将法定货币或其他加密货币转换为 MetamaskIPN 的支持的代币,并生成支付按钮或购物车链接。

安装

composer require evolutionscript/metamaskipn

使用方法

use EvolutionScript\MetamaskIPN as MetamaskIPN;
//Initialize MetamaskIPN Class
$metamaskIPN = new MetamaskIPN\MetamaskIPN();

//Specify cache directory to save data from FIAT rates and make a request once per day. It is optional but prevents exceeding the API usage limit. 
$metamaskIPN->cacheDirectory(__DIR__.'/cache');

//Connect with Currency Layer and as optional connect with OpenExchangeRates. The optional provider is useful if the primary provider fails.
$metamaskIPN->currencyProviders(
	new \EvolutionScript\CurrencyAPI\Providers\CurrencyLayer('CURRENCY_LAYER_API'),
	new \EvolutionScript\CurrencyAPI\Providers\OpenExchangeRates('OPEN_EXCHANGE_RATES_API')
);


//If we are going to use fiat and deposit will be in Litecoin (LTC):
$button_code = $metamaskIPN->from_fiat(10, 'PEN')
	->to_crypto('LTC')
	->site_id(0)
	->custom_1('my_optional_parameter')
	->custom_2('other_option_parameter')
	->custom_3('another_option_parameter')
	->lang('en') //For supported languages go to https://metamaskipn.com/docs
	->button_code('Pay Now');

echo $button_code;

//If we are going to use a cryptocurrency like Solana (SOL) and deposit in in BTCB (BTC)
$button_code_2 = $metamaskIPN->from_crypto(1,'SOL')
	->to_crypto('BTCB')
	->site_id(0)
	->custom_1('custom_parameter')
	->lang('es')
	->button_code();
echo $button_code_2;

//If we are going to use the shopping cart URL, then we can specify item name and other items.
$shopping_car_url = $metamaskIPN->from_crypto(55,'XRP')
	->to_crypto('BNB')
	->site_id(0)
	->custom_1('custom_parameter')
	->lang('en')
	->item_name('Make a donation')
	->item_description('Support our project')
	->logo('https://www.evolutionscript.com/assets/evolution/images/logo.png') //URL of your logo
	->cancel_url('https://mysite.com/cart')
	->success_url('https://mysite.com/success')
	->shopping_cart();
echo '<br><a href="'.$shopping_car_url.'">Click here to redirect to shopping cart</a>';