bennetgallein/pay.g2a.com-php-sdk

此包最新版本(v0.1.1)没有可用的许可信息。

适用于G2A.com支付网关的PHP SDK

v0.1.1 2020-04-26 12:48 UTC

README

License: MIT Twitter: bennetgallein

这是一个简化与G2A支付网关交互的SDK

🏠 主页

安装

composer require bennetgallein/pay.g2a.com-php-sdk

用法

以下是一个快速示例,说明如何使用此SDK生成支付并重定向用户。

use G2APay\G2APay;
use G2APay\Types\Enums\Environment;
use G2APay\Types\Item;
use Tracy\Debugger;

$g2a = new G2APay(
    "test@example.com", // your merchants email address
    '12345678-1234-12345-12345-123456789012', // your API hash
    'GDG#*)G*Wd#80Ggd*)G#80db380bnf3ijf3iW()#hb[pwai4u3f4b4UU3#$(%ubUb#', // your API secret
    Environment::SANBDOX // which env to use. Can be Environment::SANDBOX or Environment::PRODUCTION. Default is production
);

$payment = $g2a->createPayment() // initiates a new payment class
    ->addItem((new Item()) // add an item to it
        ->setSku("sku") // set the sku for the item
        ->setName("Test Product") // set the name for the item
        ->setAmount(20.00) // the the total price (quantity * price)
        ->setQuantity(2) // quantity of the item
        ->setId(1) // item id, this is internal to your system
        ->setPrice(10.00) // price per one item
        ->setUrl('https://test.com/product') // url to the product
    )
    ->setOrderId(1) // order id, this is internal to you system
    ->setAmount(20.00) // total amount of the transaction
    ->setCurrency('EUR') // ISO 4217 conform currency code
    ->setEmail('me@bennetgallein.de') // customers email
    ->setFailureUrl('https://test.com/failed') // callback url on failed payment (user abort for example)
    ->setOkUrl('https://test.com/success') // return url if the user approves. get-Parameter "transactionId" contains the transactionId
    ->setCustomerIPAddress('123.123.123.123') // customers ipv4 address
    ->create(); // create the payment

$checkoutUrl = $g2a->getCheckoutUrl($payment->token); // get the checkout url from token
header("Location: ${checkoutUrl}"); // redirect the user

获取交易信息

$payment = $g2a->createPayment()->getPayment("paymentId");

作者

👤 Bennet Gallein

展示您的支持

如果此项目对您有帮助,请给予 ⭐️。

此README是由 readme-md-generator 使用 ❤️ 生成的