I am using Braintree for payment gateway.
I have a requirement where I need to store only last 4 digits of credit card, expiry date (As per PCI Complaince).
I have implemented front-end code in javascript and on sending data to server, credit card information is encrypted.
Is there anyway I can get last four digits, expiry date and card type at backend or can I decrypt it?
<form name="paymentForm" action="/createtransaction" method="post" id="braintree-payment-form">
<p>
<label style="color:white">Card Number</label>
<input type="text" size="20" ng-model="userDetails.number" autocomplete="off" data-encrypted-name="number" />
</p>
<p>
<label style="color:white">CVV</label>
<input type="text" size="4" ng-model="userDetails.cvv" autocomplete="off" data-encrypted-name="cvv" />
</p>
<p>
<label style="color:white">Expiration (MM/YYYY)</label>
<input type="text" size="2" ng-model="userDetails.month" data-encrypted-name="month" /> / <input type="text" size="4" ng-model="userDetails.year" data-encrypted-name="year" />
</p>
<input type="submit" id="submit" />
(Disclosure, I work for Braintree)
Since you're using client-side encryption you won't be able to get the information as it is encrypted before the transaction is created. However, once you've made the transaction, the result object will contain the first six / last four digits of the cards number and the expiration date. You can then store those values in your database.
It would look something like:
Result<Transaction> result = gateway.transaction().sale(
...
);
Transaction transaction = result.getTarget();
CreditCard creditCart = transaction.getCreditCard();
String last4 = creditCard.getLast4();
String expiration = creditCard.getExpirationDate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With