how to get the Following data from $_POST['encrypted-data']
EncryptedCardNumber
ExpiryMonth
ExpiryYear
EncryptedSecurityCode
I passed one Input "encrypted-data" but I want EncryptedCardNumber ,ExpiryMonth ,ExpiryYear ,EncryptedSecurityCode
Client side
<script type="text/javascript" src="https://test.adyen.com/hpp/cse/js/HWC324534556545.shtml"></script>
<form method="POST" action="payment.php" id="adyen-encrypted-form">
<input placeholder="number" type="text" size="20" data-encrypted-name="number" value="2223520443560010" />
<input placeholder="holderName" type="text" size="20" data-encrypted-name="holderName" value="Ashok" />
<input placeholder="expiryMonth" type="text" size="2" data-encrypted-name="expiryMonth" value="10" />
<input placeholder="expiryYear" type="text" size="4" data-encrypted-name="expiryYear" value="2024" />
<input placeholder="cvc" type="text" size="4" data-encrypted-name="cvc" value="737" />
<input type="hidden" value="<?php echo date('Y-m-d\TH:i:sP'); ?>" data-encrypted-name="generationtime"/>
<input type="submit" value="Pay"/>
</form>
<script>
// The form element to encrypt.
var form = document.getElementById('adyen-encrypted-form');
var options = {};
// Bind encryption options to the form.
options.name = "encrypted-data";
options.onsubmit = function(e) {
e.preventDefault();
form.submit();
};
var key = "MY Key";
var result = adyen.encrypt.createEncryptedForm(form, key, options);
</script>
processing payment payment.php
<?php
//echo $_POST['encrypted-data'];
require_once 'vendor/autoload.php';
$client = new \Adyen\Client();
$client->setXApiKey("my api key");
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setTimeout(30);
$service = new \Adyen\Service\Checkout\PaymentsApi($client);
$requestOptions['idempotencyKey'] = "c3276329-1bb1-47dc-a19a-5cc87f79de11";
// Create a PaymentMethod object.
$paymentMethod = new \Adyen\Model\Checkout\CheckoutPaymentMethod();
$paymentMethod
->setType("scheme")
->setEncryptedCardNumber("test_4111111111111111")
->setEncryptedExpiryMonth("test_03")
->setEncryptedExpiryYear("test_2030")
->setEncryptedSecurityCode("test_737");
// Create an Amount object.
$amount = new \Adyen\Model\Checkout\Amount();
$amount
->setValue(10)
->setCurrency("EUR");
// Create the PaymentRequest object.
$paymentRequest = new \Adyen\Model\Checkout\PaymentRequest();
$paymentRequest
->setMerchantAccount("myMerchantAccountCOM")
->setPaymentMethod($paymentMethod)
->setAmount($amount)
->setReference("payment-test")
->setReturnUrl("");
// Make a /payments request.
$result = $service->payments($paymentRequest, $requestOptions);
//$pspReference = $result.pspReference;
How to replace this example data
test_4111111111111111
test_03
test_2030
test_737
with the crypted data Entered by client
thanks
When performing a card payment with Adyen you have 2 options.
Use the Adyen client-side solutions that securely collect and encrypt card information. You can find an example in PHP in the adyen-examples GitHub repository.
In your example above you would integrate the Dropin in the client side.
Make a payment by sending the raw (unencrypted) card information: in this case you need to be fully PCI compliant.
In your example above you would fill the data in the form with the information entered by the shopper.