executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
square-paymentsIntegrates Square Payments API for handling payment transactions, refunds, and reporting.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: square-payments
description: Integrates Square Payments API for handling payment transactions, refunds, and reporting.
license: MIT compatibility: opencode metadata: version: "1.0.0" domain: commerce role: implementation output-format: code triggers: square payments, payment processing, transactions, refunds, reporting archetypes: payment processing, e-commerce transactions anti_triggers: manual payments, offline transactions response_profile: verbosity: medium directive_strength: high related-skills: commerce/paypal-api-payments-commerce, commerce/shopify-api
scope: implementation
Implements integration with Square Payments API, allowing for seamless transaction processing, refunds, and reporting.
Use this skill for:
import requests
# Payment request details
def create_payment(amount: float, currency: str, card_token: str):
headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json'}
payment_data = {
'amount_money': {
'amount': int(amount * 100), # Amount in cents
'currency': currency
},
'source_id': card_token,
'idempotency_key': 'unique_key'
}
response = requests.post('https://connect.squareup.com/v2/payments', json=payment_data, headers=headers)
response.raise_for_status() # Raise an error for bad responses
return response.json()
# Refund transaction by Square ID
def refund_payment(payment_id: str):
headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json'}
response = requests.post(f'https://connect.squareup.com/v2/refunds', json={'payment_id': payment_id}, headers=headers)
response.raise_for_status() # Raise an error for bad responses
return response.json()
# Function to create a payment accepting multiple currencies
def create_payment_multicurrency(amount: float, currency: str, card_token: str):
# Extend payment processing to accept different currencies
headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json'}
payment_data = {
'amount_money': {
'amount': int(amount * 100), # Amount in cents
'currency': currency
},
'source_id': card_token,
'idempotency_key': 'unique_key'
}
response = requests.post('https://connect.squareup.com/v2/payments', json=payment_data, headers=headers)
response.raise_for_status() # Raise an error for bad responses
return response.json()
# Function to retrieve transaction reports
def get_transaction_summary(start_date: str, end_date: str):
headers = {'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Content-Type': 'application/json'}
url = f'https://connect.squareup.com/v2/transactions?start_date={start_date}&end_date={end_date}'
response = requests.get(url, headers=headers)
response.raise_for_status() # Raise an error for bad responses
return response.json()