b0y-101 Mini Shell


Current Path : E:/www/b-group.old/spfin/paymentall/
File Upload :
Current File : E:/www/b-group.old/spfin/paymentall/p6.php

<?php
use Jose\Component\Encryption\Algorithm\KeyEncryption\RSAOAEP256;
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512;
use Jose\Component\Encryption\JWEBuilder;
use Jose\Component\Encryption\Serializer\CompactSerializer;
use Jose\Component\Core\JWK;


$secret_keysp=file_get_contents('key/spfinpublickey.txt');
// Load PACO Encryption Public Key
$pacoEncryptionPublicKey = file_get_contents('key/PACOEncryptionPublic.txt');

// Load PACO Signing Public Key
$pacoSigningPublicKey = file_get_contents('key/PACOSigningPublic.txt');

// Set your API Key
$apiKey = '7068c343afa741ea978abe75a1b22d51';

// Credit Card Data
$creditCardData = [
    'card_number' => '4111111111111111',
    'card_expiry_month' => '12',
    'card_expiry_year' => '2025',
    'card_cvv' => '123',
];

// Merchant Data
$merchantData = [
    'merchant_id' => '2206',
    'secret_key' => '$secret_keysp',
];

// Payment Data
$paymentData = [
    'amount' => 100.00,
    'currency' => 'USD',
    'description' => 'Payment for Order #123',
];

// Create a JWK instance for PACO Encryption Public Key
$pacoEncryptionKey = JWK::createFromKey($pacoEncryptionPublicKey, null, ['alg' => 'RSA-OAEP-256', 'use' => 'enc']);

// Create a JWK instance for PACO Signing Public Key
$pacoSigningKey = JWK::createFromKey($pacoSigningPublicKey, null, ['alg' => 'RS256', 'use' => 'sig']);

// Build the JSON Payload
$payload = [
    'merchant_id' => $merchantData['merchant_id'],
    'order_id' => uniqid(),
    'invoice_no' => uniqid(),
    'amount' => $paymentData['amount'],
    'currency' => $paymentData['currency'],
    'description' => $paymentData['description'],
    'pan' => $creditCardData['card_number'],
    'expiry_month' => $creditCardData['card_expiry_month'],
    'expiry_year' => $creditCardData['card_expiry_year'],
    'security_code' => $creditCardData['card_cvv'],
];

// Encrypt the Payload using PACO Encryption Public Key
$jweBuilder = new JWEBuilder();
$jwe = $jweBuilder
    ->create()
    ->withPayload(json_encode($payload))
    ->withEncryptionKey($pacoEncryptionKey)
    ->addRecipient($pacoEncryptionKey)
    ->withHeader('alg', 'RSA-OAEP-256')
    ->withHeader('enc', 'A256CBC-HS512')
    ->build();

// Sign the Payload using Merchant's Signing Private Key
$signature = '';
openssl_sign($jwe->getPayload(), $signature, $merchantData['secret_key'], OPENSSL_ALGO_SHA256);

// Attach the Encrypted Payload and Signature to your API request
$requestData = [
    'api_key' => $apiKey,
    'payload' => (new CompactSerializer())->serialize($jwe),
    'signature' => base64_encode($signature),
];



// Send the API request to 2C2P Payment Gateway
// ...?>

Copyright © 2019 by b0y-101