How to Delay Credit Card Payments Like Groupon Using APIs

One of the keys to Groupon’s success is its innovative approach to payment processing—specifically, delaying credit card payments to improve cash flow and manage risk. This strategy, known as ‘payment authorization and delayed capture,’ involves authorizing a payment but not capturing the funds until a later date. It’s a common practice in e-commerce, and it’s possible using popular payment gateways like PayPal, Amazon, and Google Checkout. This article will provide a step-by-step guide on how to achieve this.

How to Delay Credit Card Payments Like Groupon Using APIs

One of the keys to Groupon’s success is its innovative approach to payment processing—specifically, delaying credit card payments to improve cash flow and manage risk. This strategy, known as “payment authorization and delayed capture,” involves authorizing a payment but not capturing the funds until a later date. It’s a common practice in e-commerce, and it’s possible using popular payment gateways like PayPal, Amazon, and Google Checkout. This article will provide a step-by-step guide on how to achieve this.

What is Payment Authorization and Delayed Capture?

Payment authorization and delayed capture is a two-step process:

  1. Authorization: This involves validating the customer’s credit card details and checking if they have sufficient funds. The amount is put on hold but not yet charged.
  2. Capture: This is when the funds are actually transferred from the customer’s account to the merchant’s account.

This scheme allows businesses like Groupon to ensure that customers are able to pay before providing a service, without immediately charging them.

How to Implement Delayed Capture With PayPal API

PayPal’s API provides specific methods for implementing delayed capture. Here is a simplified example:

import paypalrestsdk
# Configure SDK
paypalrestsdk.configure({
  "mode": "sandbox", # sandbox or live
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET" })

# Create payment object
payment = paypalrestsdk.Payment({
  "intent": "authorize",
  "payer": {...},
  "transactions": [{...}]})

# Create authorization
if payment.create():
  print("Payment[%s] created successfully"%(payment.id))
else:
  print(payment.error)

# Capture payment after delay
for transaction in payment.transactions:
  authorization = paypalrestsdk.Authorization.find(transaction['related_resources'][0]['authorization']['id'])
  if authorization.capture({ "amount": { "currency": "USD", "total": "1.00" } }):
    print("Capture[%s] completed successfully"%(authorization.id))
  else:
    print(authorization.error)

Remember to replace "YOUR_CLIENT_ID" and "YOUR_CLIENT_SECRET" with your PayPal app’s actual client ID and secret.

How to Use Amazon Pay API for Delayed Capture

Amazon Pay also supports authorization and capture. Here’s how to implement it:

import boto3

# Create a client
client = boto3.client(
    'amazonpay',
    aws_access_key_id = 'YOUR_ACCESS_KEY',
    aws_secret_access_key = 'YOUR_SECRET_KEY',
    region_name = 'us-west-2'
)

# Authorize payment
response = client.authorize_on_billing_agreement(
    AmazonBillingAgreementId='YOUR_AMAZON_BILLING_AGREEMENT_ID',
    AuthorizationReferenceId='YOUR_AUTHORIZATION_REFERENCE_ID',
    AuthorizationAmount={
        'Amount':'10',
        'CurrencyCode':'USD'
    },
    TransactionTimeout=0
)

# Capture payment after delay
capture_response = client.capture(
    AmazonAuthorizationId=response['AuthorizeOnBillingAgreementResult']['AuthorizationDetails']['AmazonAuthorizationId'],
    CaptureReferenceId='YOUR_CAPTURE_REFERENCE_ID',
    CaptureAmount={
        'Amount':'10',
        'CurrencyCode':'USD'
    },
)

Replace the placeholders with your actual Amazon Pay details.

Implementing Delayed Capture with Google Checkout

As of my knowledge cutoff in September 2021, Google Checkout was discontinued and replaced by Google Pay, which unfortunately doesn’t support the delayed capture feature directly. However, you could use a workaround by creating an order with a PENDING state and changing it to CONFIRMED when you’re ready to capture the payment.

In conclusion, the ability to delay credit card payments is a crucial tool for businesses that wish to manage their cash flow more effectively, manage risk, or provide a more lenient payment policy to their customers. By leveraging the APIs offered by payment gateways like PayPal and Amazon Pay, this functionality can be easily implemented.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.