PHP code example of rockbuzz / sdk-yapay
1. Go to this page and download the library: Download rockbuzz/sdk-yapay library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rockbuzz / sdk-yapay example snippets
use Rockbuzz\SDKYapay\PaymentBoletoFactory;
$params = [
'store_code' => 1234,
'username' => 'your_user',
'password' => 'your_pass',
'endpoint' => 'https://sandbox.gateway.yapay.com.br/checkout/api/v3/transacao',
'transaction_number' => 1234,
'transaction_value' => 1598,
'transaction_due_date' => new \Datetime(),
'transaction_notification_url' => 'http://notificationUrl.com',
'items' => [
[
'id' => 1234,
'name' => 'Product Name',
'price_in_cents' => 15987,
'quantity' => 1
],
[
'id' => 2345,
'name' => 'Product Name',
'price_in_cents' => 15990,
'quantity' => 1
]
],
'customer_id' => 1234,
'customer_name' => 'Customer Name',
'customer_document' => 12345678900,
'email' => '[email protected] ',
'street' => 'Street',
'number' => 123,
'postal_code' => '16985152',
'neighborhood' => 'Center',
'city' => 'City',
'state' => 'UF',
'complement' => '',
'country' => 'BR'
];
try {
$payment = PaymentBoletoFactory::fromArray($params);
$result = $payment->done();
} catch (\Exception $e) {
//
}
use Rockbuzz\SDKYapay\PaymentCreditCardFactory;
$params = [
'store_code' => 1234,
'username' => 'your_user',
'password' => 'your_pass',
'endpoint' => 'https://sandbox.gateway.yapay.com.br/checkout/api/v3/transacao',
'transaction_number' => 1234,
'transaction_value' => 1598,
'transaction_installments' => 5,
'transaction_notification_url' => 'http://notificationUrl.com',
'creditcard_name' => 'Holder Name',
'creditcard_number' => 0000000000000000,
'creditcard_code' => 123,
'creditcard_month' => 10,
'creditcard_year' => 2020,
'items' => [
[
'id' => 1234,
'name' => 'Product Name',
'price_in_cents' => 15987,
'quantity' => 1
],
[
'id' => 2345,
'name' => 'Product Name',
'price_in_cents' => 15990,
'quantity' => 1
]
],
'customer_id' => 1234,
'customer_name' => 'Customer Name',
'customer_document' => 12345678900,
'email' => '[email protected] ',
'street' => 'Street',
'number' => 123,
'postal_code' => '16985152',
'neighborhood' => 'Center',
'city' => 'City',
'state' => 'UF',
'complement' => '',
'country' => 'BR'
];
try {
$payment = PaymentCreditCardFactory::fromArray($params);
$result = $payment->done();
} catch (\Exception $e) {
//
}
use Rockbuzz\SDKYapay\Transactions;
$config = [
'store_code' => 1234,
'username' => 'your_user',
'password' => 'your_pass',
'endpoint' => 'https://sandbox.gateway.yapay.com.br/checkout/api/v3/transacao'
];
try {
$transactions = Transactions::make($config);
$result = $transactions->findByNumber(123);
} catch (\Exception $e) {
//
}
$result->isSuccess();
$about = $result->about();
$jsonAbout = json_encode($about);
\DomainException::class
Rockbuzz\SDKYapay\Exception\YapayException::class
Rockbuzz\SDKYapay\Exception\YapayException::class