フロントエンドのテンプレートで、購入に使用したクレジットカードの最後の4桁を表示したいと思います。データはJSON形式の
craft_commerce_transactions
テーブルの
reference
列のdbにあります。
{
"approvalCode":"PNRABL",
"transId":"60007205645",
"card": {
"number":"1234",
"expiry":"112318"
}
}
Craft Commerceがこのデータをユーザーアカウント領域に表示する方法はありますか?
ベストアンサー
Brad氏のもう1つのアプローチは、トランザクションの時点で注文のフィールドに4桁の数字を保存することです…後で検索しやすくするためです。私たちは私たちのゲートウェイの私たちが私たちに与える詐欺のスコアでこれを行う…
//Save the Beagle Anti-Fraud Score to the order
craft()->on('commerce_transactions.onSaveTransaction', function ($event)
{
$transaction = $event->params['transaction'];
$order = $transaction->order;
//Transactions are saved before responses too....
if($transaction->response){
BusinessLogicPlugin::log($transaction->response);
if (array_key_exists("BeagleScore",$transaction->response)){
$score = (string) $transaction->response['BeagleScore'];
BusinessLogicPlugin::log("Beagle score found: $score");
$order->setContentFromPost(["beagleScore"=>$score]);
craft()->commerce_orders->saveOrder($order);
}
}
});