API Documentation. See how easy it can be to add 200+ payment methods to your store.

Subscriptions

G2A PAY allows receiving recurring payments as subscriptions for your service. Subscription will be set up on regular payment changing it to a periodical charge. You need to add few new parameters to your regular payment request in order to consider it as a subscription.

Activation

Before you will be able to receive payments for your subscription you need to activate it in Merchant Panel, please follow this link https://pay.g2a.com/merchant/subscriptions and complete required steps, please also keep in mind that you need to be a fully activated merchant to complete the process.

Setup

Gateway

If you use our gateway integration you need to add few new parameters to your POST body:

... other parameters ...
&subscription=1
&subscription_product_name=My+product+name+1+month
&subscription_type=product
&subscription_period=monthly
&subscription_start_date=2017-10-10

Variables

Attribute
Value
Data type
Required
Description
subscription
1
string
Required
Indicates about subscription setup
subscription_product_name
{{PRODUCT_NAME}}
string
Required
Name of your product/service
subscription_type
{{TYPE}}
string
Required
Type of subscription, allowed:
product|donation
subscription_period
{{PERIOD}}
string
Required
Subscription period, allowed:
daily,weekly,monthly,quarterly,semi-annually,annually
subscription_frequency
{{FREQUENCY}}
integer
No
Subscription frequency
default: 1
subscription_start_date
{{START_DATE}}
string
NO
Optional, if subscription should start instantly leave it empty, format: YYYY-MM-DD

Notifications

G2A PAY send separated IPNs each time customer signup/deregister to your subscription.

Create

Below you will find sample IPN when user sign up to your subscription, we send to you POST data:

type=subscription_created
&subscriptionId=ece4c304-1964-4e33-bf46-0c6bd057ce23
&transactionId=39bba099-8193-4e8c-a3c2-ade7341f8628
&userOrderId=sampleOrder_20170727145921
&subscriptionName=Subscription+product+1+month
&subscriptionType=product
&period=monthly
&frequency=1
&email=it12@g2a.com
&amount=10.00
&currency=USD
&status=active
&createdAt=2017-10-03T03:38:17+01:00
&nextChargeAt=2017-11-03T03:38:17+00:00
&hash=00ed7669a79c456dbeda6a0a248f594880bc3591fbcd6f46c12829f58710a6b8
    

Cancel

Each time subscription is being canceled you will receive IPN notification as POST data sent to your endpoint:

type=subscription_canceled
&subscriptionId=ece4c304-1964-4e33-bf46-0c6bd057ce23
&transactionId=39bba099-8193-4e8c-a3c2-ade7341f8628
&userOrderId=sampleOrder_20170727145921
&subscriptionName=Subscription+product+1+month
&subscriptionType=product
&period=monthly
&frequency=1
&email=it12@g2a.com
&amount=10.00
&currency=USD
&status=canceled
&createdAt=2017-10-03T06:27:17+01:00
&disabledAt=2017-10-17T08:53:17+01:00
&hash=00ed7669a79c456dbeda6a0a248f594880bc3591fbcd6f46c12829f58710a6b8
    

IPN Hash

In order to validate IPN data as it should be done with regular IPN payment processing we always add hash parameter, for security reasons you should compare hash generated in your application with hash received in IPN data.

Hash parameter is generated by using SHA256 algorithm on concatenation of following data:

{subscriptionId}{amount}{subscriptionName}{apiSecret}
  • subscriptionId - subscription ID from IPN data
  • amount - amount from IPN data
  • subscriptionName - subscription name from IPN data
  • apiSecret - Your store API secret, which you will find in merchant panel (Merchant -> Settings)