PHP code example of bayonet / bayonet-php
1. Go to this page and download the library: Download bayonet/bayonet-php 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/ */
bayonet / bayonet-php example snippets
$bayonet = new Bayonet\EcommerceClient([
'api_key' => 'your_api_key',
'version' => 2
]);
$bayonet->consult([
'body' => [
'channel' => 'ecommerce',
'email' => '[email protected] ',
'consumer_name' => 'Example name',
'consumer_internal_id' => '<your internal ID for this consumer>',
'cardholder_name' => 'Example name',
'telephone' => '1234567890',
'card_number' => '4111111111111111',
'transaction_amount' => 999.00,
'currency_code' => 'MXN',
'shipping_address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'billing_address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'payment_method' => 'card',
'order_id' => '<your internal ID for this order>',
'transaction_id' => '<your internal ID for this transaction>',
'payment_gateway' => 'stripe',
'coupon' => 'discount_buen_fin',
'expedited_shipping' => true,
'products' => [
[
'product_id' => '1',
'product_name' => 'product_1',
'product_price' => 500.00,
'product_category' =>'example category'
],
[
'product_id' => '2',
'product_name' => 'product_2',
'product_price' => 499.00,
'product_category' =>'example category'
]
],
'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>'
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet->update_transaction([
'body' => [
'transaction_status' => 'success',
'transaction_id' => '<your internal ID for this transaction (as sent in the consult step)>',
...
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet->feedback_historical([
'body' => [
'channel' => 'ecommerce',
'email' => '[email protected] ',
'consumer_name' => 'Example name',
'consumer_internal_id' => '<your internal ID for this consumer>',
'cardholder_name' => 'Example name',
'telephone' => '1234567890',
'card_number' => '4111111111111111',
'transaction_amount' => 999.00,
'currency_code' => 'MXN',
'shipping_address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'billing_address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'payment_method' => 'card',
'transaction_id' => '<your internal ID for this transaction>',
'payment_gateway' => 'stripe',
'coupon' => 'discount_buen_fin',
'expedited_shipping' => true,
'products' => [
[
'product_id' => '1',
'product_name' => 'product_1',
'product_price' => 500.00,
'product_category' =>'example category'
],
[
'product_id' => '2',
'product_name' => 'product_2',
'product_price' => 499.00,
'product_category' =>'example category'
]
],
'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
'transaction_time' => 1476012879,
'transaction_status' => 'success',
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet = new Bayonet\LendingClient([
'api_key' => 'your_api_key',
'version' => 2
]);
$bayonet->report_transaction([
'body' => [
'email' => '[email protected] ',
'consumer_name' => 'Example name',
'consumer_internal_id' => '<your internal ID for this consumer>',
'telephone_fixed' => '1234567890',
'telephone_mobile' => '1234567891',
'telephone_reference_1' => '1234567892',
'telephone_reference_2' => '1234567893',
'telephone_reference_3' => '1234567894',
'rfc' => 'Example RFC',
'curp' => 'Example CURP',
'clabe' => 'Example CLABE',
'address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
'transaction_category' => 'p2p_lending',
'transaction_id' => '<your internal ID for this transaction>',
'transaction_time' => 1476012879
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet->report_transaction_and_consult([
'body' => [
'email' => '[email protected] ',
'consumer_name' => 'Example name',
'consumer_internal_id' => '<your internal ID for this consumer>',
'telephone_fixed' => '1234567890',
'telephone_mobile' => '1234567891',
'telephone_reference_1' => '1234567892',
'telephone_reference_2' => '1234567893',
'telephone_reference_3' => '1234567894',
'rfc' => 'Example RFC',
'curp' => 'Example CURP',
'clabe' => 'Example CLABE',
'address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
'transaction_category' => 'p2p_lending',
'transaction_id' => '<your internal ID for this transaction>',
'transaction_time' => 1476012879
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet->consult([
'body' => [
'transaction_id' => '<transaction ID that you used when reporting the transaction or solicitud>'
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet->feedback([
'body' => [
'transaction_id' => '<transaction ID that you used when reporting the transaction or solicitud>',
'actions' => [
'alert' => true,
'block' => true
]
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet->feedback_historical([
'body' => [
'email' => '[email protected] ',
'consumer_name' => 'Example name',
'consumer_internal_id' => '<your internal ID for this consumer>',
'telephone_fixed' => '1234567890',
'telephone_mobile' => '1234567891',
'telephone_reference_1' => '1234567892',
'telephone_reference_2' => '1234567893',
'telephone_reference_3' => '1234567894',
'rfc' => 'Example RFC',
'curp' => 'Example CURP',
'clabe' => 'Example CLABE',
'address' => [
'line_1' => 'example line 1',
'line_2' => 'example line 2',
'city' => 'Mexico City',
'state' => 'Mexico DF',
'country' => 'MEX',
'zip_code' => '64000'
],
'bayonet_fingerprint_token' => '<token generated by Bayonet fingerprinting JS>',
'transaction_category' => 'p2p_lending',
'transaction_id' => '<your internal ID for this transaction>',
'transaction_time' => 1476012879,
'actions' => [
'alert' => true,
'block' => true
]
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
$bayonet = new Bayonet\DeviceFingerprintClient([
'api_key' => 'your_api_key',
'version' => 2
]);
$bayonet->get_fingerprint_data([
'body' => [
'bayonet_fingerprint_token' => 'fingerprint-token-generated-by-JS-snipppet'
],
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
// make the request
$bayonet -> <EVENT>([
'body' => ...,
'on_success' => function($response) {
print_r($response);
},
'on_failure' => function($response) {
print_r($response);
}
]);
" ...
"bayonet/bayonet-php": "2.0.*"
...
}