1 mins read

Identifying credit card expiry date

Omise

Many of your customers may have chosen to save their cards with Omise. Reminding them of their credit card expiry date is another way to prevent failed charges. Here's a quick tip from us on how you can search for your customer's card expiry date (default card) using Pry and Omise’s Ruby library.


# Run pry
pry

# Read out Omise
requires "omise"

# Set the API key
Omise.api_key = "secret key"

# Update the description and retrieve Customer
customer_id = "cust_test_xxxxx"
customer = Omise::Customer.retrieve(customer_id)

# Retrieve the expiry date of the Customer's default card
expiration_month = customer.default_card.expiration_month
expiration_year = customer.default_card.expiration_year
expiration = "#{expiration_month}/#{expiration_year}"

# Input the default card’s expiry date in the description
customer.update({description: expiration})

# Searching for a Customer with the default card 
search_result = Omise::Search.execute(scope: "customer", query: expiration)
search_result.data.each do |customer|

# ここで有効期限が切れそうなcustomerへ何かをする処理をいれる。

end

Now you can notify your customers before their card expires. And since you can list all Customers Omise::Customer.list, you can update all descriptions in one go.

We hope you find this useful! For questions or feedback, dont hesitate to get in touch. Email us at support@omise.co

Translated from 決済APIでカードの有効期限切れの対応ってどうするの? written by Akira Narita, Lead Deverloper at Omise.

More from us

7 mins read

How PayNow improves payment experiences

3 mins read

Why PayNow matters

Subscribe to receive the latest updates from Omise
Thank you!

You are subscribed.

Omise uses cookies to improve your overall site experience and collect information on your visits and browsing behavior. By continuing to browse our website, you agree to our Privacy Policy. Learn more