b5s / maxipago
Requires
- php: >=8.1
- ext-dom: *
- ext-simplexml: *
- guzzlehttp/guzzle: 7.*
- monolog/monolog: ^3.1
Requires (Dev)
- roave/security-advisories: dev-latest
README
PIX Maxipago
有关库的运作方式、字段和值的更多信息,请参阅 https://www.maxipago.com/developers/pix/
实例化maxipago\pix\Pix类,并在构造函数中指定storeId和merchantKey以及执行模式。只有在需要时才修改API版本,以及debugMode。
默认情况下,库使用API版本3.1.1.15。
new maxipago\pix\Pix(storeId: 'xxxx', merchantKey: 'yyyy');
默认情况下,库在测试环境中运行,以避免在开发过程中意外执行,要切换到生产环境,只需在maxipago\pix\Pix类的构造函数中指定或调用productionMode方法并将参数标记为true。
new maxipago\pix\Pix(storeId: 'xxxx', merchantKey: 'yyyy', productionMode: true);
或者
$pix = new maxipago\pix\Pix(storeId: 'xxxx', merchantKey: 'yyyy');
$pix->productionMode(true);
当库在调试模式下运行时,不会调用Maxipago的任何API。
支付链接:要生成通过支付链接的PIX请求,请使用paymentLink方法,该方法接受maxipago\pix\paymentLink\PaymentLink类的实例作为参数。
$paymentLink = new PaymentLink(
consumerAuthentication: maxipago\pix\Enums\YesOrNoEnum::No,
referenceNum: '2009171040',
fraudCheck: maxipago\pix\Enums\YesOrNoEnum::No,
billing: new \maxipago\pix\paymentLink\Billing(
email: 'dev@maxipago.com',
language: 'pt',
firstName: 'Dev'
),
transactionDetail: new \maxipago\pix\paymentLink\TransactionDetail(
description: 'pagamento Smart TV',
emailSubject: 'Favor efetuar o pagamento',
expirationDate: '06/17/2022',
amount: 2.00,
acceptPix: maxipago\pix\Enums\YesOrNoEnum::Yes
)
);
$pix = new maxipago\pix\Pix(storeId: 'xxxx', merchantKey: 'yyyy');
$pix->paymentLink($paymentLink);
将返回一个maxipago\pix\dto\PaymentLink实例。
Checkout支付:要在Checkout模式中完成PIX支付,请使用checkout方法,该方法接受maxipago\pix\checkout\Sale类的实例作为参数。
$sale = new Sale(
processorId: '200',
referenceNum: 'MXP_PIX_130120211126',
fraudCheck: 'N',
payment: new maxipago\pix\checkout\Payment(totalPrice: 10005.00),
costumerIdExt: '37568256634',
billing: new maxipago\pix\checkout\Billing(
name: 'maxipixPago',
address: 'Avenida Paulista 123',
address2: '1 Andar',
district: 'Paraiso',
city: 'Sao Paulo',
state: 'SP',
postalcode: '01311000',
country: 'BR',
phone: '36925873229',
email: 'testepix@testepix.com',
documents: [
new maxipago\pix\checkout\Document(documentType: 'CPF', documentValue: '99907514047'),
]
),
transactionDetail: new maxipago\pix\checkout\TransactionDetail(
pixExpirationTime: 86400,
purchaseDescription: 'Smart TV LG 65´ 8K IPS NanoCell, Conexão WiFi e Bluetooth',
extraInfo: [
new maxipago\pix\checkout\PurchaseInformation(name: 'TV8k', value: 10000.00),
new maxipago\pix\checkout\PurchaseInformation(name: 'Garantia Estendida', value: 5.00),
]
)
);
$pix->checkout($sale);
将返回一个maxipago\pix\dto\GeneratedPix实例。
退款:要执行退款操作,请使用chargeback方法,该方法接受maxipago\pix\estorno\PixReturn类的实例作为参数。
$sale = new Sale(
processorId: '200',
referenceNum: 'MXP_PIX_130120211126',
fraudCheck: 'N',
payment: new Payment(totalPrice: 10005.00),
costumerIdExt: '37568256634',
billing: new Billing(
name: 'maxipixPago',
address: 'Avenida Paulista 123',
address2: '1 Andar',
district: 'Paraiso',
city: 'Sao Paulo',
state: 'SP',
postalcode: '01311000',
country: 'BR',
phone: '36925873229',
email: 'testepix@testepix.com',
documents: [
new Document(documentType: 'CPF', documentValue: '99907514047'),
]
),
transactionDetail: new TransactionDetail(
pixExpirationTime: 86400,
purchaseDescription: 'Smart TV LG 65´ 8K IPS NanoCell, Conexão WiFi e Bluetooth',
extraInfo: [
new PurchaseInformation(name: 'TV8k', value: 10000.00),
new PurchaseInformation(name: 'Garantia Estendida', value: 5.00),
]
)
);
$result = $pix->checkout($sale);
$chargeback = new PixReturn(
orderId: $result->getOrderId(),
referenceNum: $result->getReferenceNum(),
chargeTotal: 10005.00
);
$pix->chargeback($chargeback);
将返回一个maxipago\pix\dto\GeneratedPix实例。
PIX取消(VOID)
要执行取消PIX操作,请使用voidPix方法,并将要取消的PIX的transactionId作为参数。
$paymentLink = new PaymentLink(
consumerAuthentication: maxipago\pix\Enums\YesOrNoEnum::No,
referenceNum: '2009171040',
fraudCheck: maxipago\pix\Enums\YesOrNoEnum::No,
billing: new \maxipago\pix\paymentLink\Billing(
email: 'dev@maxipago.com',
language: 'pt',
firstName: 'Dev'
),
transactionDetail: new \maxipago\pix\paymentLink\TransactionDetail(
description: 'pagamento Smart TV',
emailSubject: 'Favor efetuar o pagamento',
expirationDate: '06/17/2022',
amount: 2.00,
acceptPix: 'S'
)
);
$pix = new maxipago\pix\Pix(storeId: 'xxxx', merchantKey: 'yyyy');
$result = $pix->paymentLink($paymentLink);
$pix->voidPix(transactionId: $result->getTransactionId());
将返回一个maxipago\pix\dto\GeneratedPix实例。