From 2b516478b917f7cc2a650347236c68c5e509b131 Mon Sep 17 00:00:00 2001 From: Erh-Li Shen Date: Fri, 16 Dec 2016 17:34:02 -0800 Subject: [PATCH] Fix registered card issue --- cards.csv | 6 +++--- gcmall.rb | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cards.csv b/cards.csv index 969411f..910cc7f 100644 --- a/cards.csv +++ b/cards.csv @@ -1,3 +1,3 @@ -Card Number,Month,Year,CVV -4551722007609849,08,25,251 -4551722003898800,08,25,158 +Card Number,Month,Year,CVV,Zip Code,Note +4551722007609849,08,25,251,,Zip code is not required if the card is not registered +4551722003898800,08,25,158,00000,Must have a zip code if the card is registered diff --git a/gcmall.rb b/gcmall.rb index e4ab9c1..663f074 100755 --- a/gcmall.rb +++ b/gcmall.rb @@ -2,9 +2,10 @@ require 'CSV' -def getBalance(card, month, year, cvv) +def getBalance(card, month, year, cvv, postal) + postal = postal == nil ? "00000" : postal url = 'https://mygift.giftcardmall.com/Card/Login?returnUrl=Transactions' - `curl -sS -c cookie --data "CardNumber=#{card}&ExpirationMonth=#{month}&ExpirationYear=#{year}&SecurityCode=#{cvv}" #{url}` + `curl -sS -c cookie --data "PostalCode=#{postal}&CardNumber=#{card}&ExpirationMonth=#{month}&ExpirationYear=#{year}&SecurityCode=#{cvv}" #{url}` response = `curl -sS -b cookie -H "Referer: #{url}" 'https://mygift.giftcardmall.com/Card/Transactions'` matches = response.scan(/<\/h6>
([\d\.\$]+)<\/h5><\/td>/i) if matches.count == 3 @@ -23,7 +24,7 @@ def getBalance(card, month, year, cvv) CSV.foreach("cards.csv", { headers: true, header_converters: :symbol }) do |row| card = row.to_hash - last4, available, initial = getBalance(card[:card_number], card[:month], card[:year], card[:cvv]) + last4, available, initial = getBalance(card[:card_number], card[:month], card[:year], card[:cvv], card[:zip_code]) if last4 printf("%13s %10s %8s\n", last4, available, initial) else