Skip to content

Create Subscription

  • Endpoint: POST /aggregate-pay/api/gateway/subscriptionCreate
  • Tags: Collection Service/Subscription Management

Description

PayerMax offers various types of subscription plans: regular subscriptions, n-day trials, and n-period promotions. The type of subscription plan can be controlled through the parameters when creating the subscription plan.

Parameters

FieldInTypeRequiredConstraintsDescription
Content-TypeheaderstringYes
signheaderstringYes签名信息请参考技术文档

Parameter Examples

  • Content-Type: "application/json"
  • sign: "FPFVT3o227JrFRbqu19boZCpVVTF9KznxyRawUmxpfXilHV/0yK46haPhAjNu1hPUMy7Vw/ILXhfzffNm4Fj0apWknlTY9OJxnSoQxS9BTFtc61tn5yV1q69x/kkBl82/qwg+XTJ4fOzy7Mar3VaC1E2PlDA6RkkKBUyNE6RYgsdB+Su7an4+4HVTNAnoe74WyvBgxTLMNg28igBTdqxaO3w/UBY6ObVp7vkqkQGdL1Y+HgmMYaAVwrM3+ALWGId0sJ+YqTY4WJ+0xCRGhaSnybiIjZsQEYyID68WNUfuavDLDsEhaMm/HfQvf5p0R1Ltovp3wwJnEbQcjY458iX5A=="

Request Body

Content-Type: application/json

FieldTypeRequiredConstraintsDescriptionEnum
versionstringYesAPI version. Current value: 1.5
keyVersionstringYesSignature Algorithm Version, Current value: 1
requestTimestringYesRequest time, compliant with rfc3339 specification, format: yyyy-MM-dd'T'HH:mm:ss.SSSXXX The time must be within two minutes of the current time
appIdstringYesMerchant AppId,The unique identifier assigned to the merchant app by PayerMax
merchantNostringNomaxLength: 32Merchant Id, the unique identifier generated when the merchant signs the contract with PayerMax
dataobjectYes
data.subscriptionRequestIdstringYesmaxLength: 64Merchant's unique request ID for creating the subscription plan.
data.userIdstringYesmaxLength: 64User ID.
data.callbackUrlstringYesmaxLength: 256Notification URL for subscription and payment deduction results.
data.subscriptionPlanobjectYesSubscription plan details.
data.subscriptionPlan.subjectstringYesmaxLength: 256Subscription title.
data.subscriptionPlan.descriptionstringNomaxLength: 256Subscription description.
data.subscriptionPlan.totalPeriodsnumberYesTotal number of subscription periods.
data.subscriptionPlan.firstPeriodStartDate ⚠️stringNoFirst payment date. Format: 2025-02-26T12:00:00+00:00
data.subscriptionPlan.periodRuleobjectNoSubscription rules. When the prices is empty, periodRule is required, when the prices is not empty, periodRule must be null.
data.subscriptionPlan.periodRule.periodUnitstringYesmaxLength: 2Subscription frequency unit: M (Month), D (Day), W (Week), Y (Year).
data.subscriptionPlan.periodRule.periodCountnumberYesSubscription frequency. Example: periodUnit=M and periodCount=1 indicates monthly payment.
data.subscriptionPlan.periodAmountobjectNoRecurring payment amount per period. When the prices is empty, periodAmount is required, when the prices is not empty, periodAmount must be null.
data.subscriptionPlan.periodAmount.amountnumberYesPayment amount.
data.subscriptionPlan.periodAmount.currencystringYesmaxLength: 3Currency code.
data.subscriptionPlan.trialPeriodConfigobjectNoTrial period configuration.
data.subscriptionPlan.trialPeriodConfig.trialPeriodCountnumberNoNumber of trial periods.
data.subscriptionPlan.trialPeriodConfig.trialPeriodAmountobjectNoTrial period payment amount.
data.subscriptionPlan.trialPeriodConfig.trialPeriodAmount.amountnumberNoTrial amount.
data.subscriptionPlan.trialPeriodConfig.trialPeriodAmount.currencystringNomaxLength: 3Currency code.
data.subscriptionPlan.trialConfigobjectNoSubscription trial for n days information
data.subscriptionPlan.trialConfig.trialAmountobjectYesTrial fee information
data.subscriptionPlan.trialConfig.trialAmount.amountnumberYesTrial fee
data.subscriptionPlan.trialConfig.trialAmount.currencystringYesTrial currency
data.subscriptionPlan.trialConfig.trialDaysnumberYesTrial days
data.subscriptionPlan.pricesarray[object]Yesprices info
data.subscriptionPlan.prices[].priceIdstringYesThe Price ID.
data.subscriptionPlan.prices[].quantitynumberYesThe Price quantity.

Example: 1

Regular subscription

json
{
  "version": "1.5",
  "keyVersion": "1",
  "requestTime": "2025-02-26T05:00:00+00:00",
  "appId": "6666c8b036a245799744912345a123456",
  "merchantNo": "010213834123456",
  "data": {
    "subscriptionRequestId": "testRequestId0001",
    "userId": "test0001",
    "callbackUrl": "http://***.com/notifyUrl/",
    "subscriptionPlan": {
      "subject": "subject",
      "description": "Regular subscription description.",
      "totalPeriods": 12,
      "periodRule": {
        "periodUnit": "M",
        "periodCount": 1
      },
      "periodAmount": {
        "amount": 404.35,
        "currency": "USD"
      }
    }
  }
}

Example: 2

N-days trial and N-periods promotion

json
{
  "version": "1.5",
  "keyVersion": "1",
  "requestTime": "2025-02-26T05:00:00+00:00",
  "appId": "6666c8b036a245799744912345a123456",
  "merchantNo": "010213834123456",
  "data": {
    "subscriptionRequestId": "testRequestId0001",
    "userId": "test0001",
    "callbackUrl": "http://***.com/notifyUrl/",
    "subscriptionPlan": {
      "subject": "subject",
      "description": "description.",
      "totalPeriods": 12,
      "periodRule": {
        "periodUnit": "M",
        "periodCount": 1
      },
      "periodAmount": {
        "amount": 404.35,
        "currency": "USD"
      },
      "trialPeriodConfig": {
        "trialPeriodAmount": {
          "amount": 10,
          "currency": "USD"
        },
        "trialPeriodCount": 2
      },
      "trialConfig": {
        "trialAmount": {
          "amount": 10,
          "currency": "USD"
        },
        "trialDays": 7
      }
    }
  }
}

Example: 3

N-period promotions

json
"{\n    \"version\": \"1.5\",\n    \"keyVersion\": \"1\",\n    \"requestTime\": \"2025-02-26T05:00:00+00:00\",\n    \"appId\": \"6666c8b036a245799744912345a123456\",\n    \"merchantNo\": \"010213834123456\",\n    \"data\": {\n        \"subscriptionRequestId\": \"testRequestId0001\",\n        \"userId\": \"test0001\",\n        \"callbackUrl\": \"http://***.com/notifyUrl/\",\n        \"subscriptionPlan\": {\n            \"subject\": \"subject\",\n            \"description\": \"PMMAX周期首期扣款。\",\n            \"totalPeriods\": 12,\n            \"periodRule\": {\n                \"periodUnit\": \"M\",\n                \"periodCount\": 1\n            },\n            \"periodAmount\": {\n                \"amount\": 404.35,\n                \"currency\": \"USD\"\n            },\n            \"trialPeriodConfig\": {\n                \"trialPeriodAmount\": {\n                    \"amount\": 10,\n                    \"currency\": \"USD\"\n                },\n                \"trialPeriodCount\": 2\n            },\n        }\n    }\n}"

Example: 4

N-days trial

json
{
  "version": "1.5",
  "keyVersion": "1",
  "requestTime": "2025-02-26T05:00:00+00:00",
  "appId": "6666c8b036a245799744912345a123456",
  "merchantNo": "010213834123456",
  "data": {
    "subscriptionRequestId": "testRequestId0001",
    "userId": "test0001",
    "callbackUrl": "http://***.com/notifyUrl/",
    "subscriptionPlan": {
      "subject": "subject",
      "description": "description.",
      "totalPeriods": 12,
      "periodRule": {
        "periodUnit": "M",
        "periodCount": 1
      },
      "periodAmount": {
        "amount": 404.35,
        "currency": "USD"
      },
      "trialConfig": {
        "trialAmount": {
          "amount": 10,
          "currency": "USD"
        },
        "trialDays": 7
      }
    }
  }
}

Responses

200

FieldTypeRequiredConstraintsDescriptionEnum
codestringYesReturn code, ‘APPLY_SUCCESS’ means success
msgstringYesReturn message, ‘Success.’
dataobjectYes
data.subscriptionRequestIdstringYesmaxLength: 64Merchant's unique request ID for creating the subscription plan.
data.subscriptionPlanobjectYes
data.subscriptionPlan.subscriptionNostringYesPayerMax subscription plan management order number
data.subscriptionPlan.subscriptionStatusstringYesmaxLength: 32Subscription plan status. INACTIVE: Not activated ACTIVE_FAILED: Activation failed ACTIVE: Activation is successful EXPIRED: Expired and not activated FINISH: Subscription Completed CANCEL: Subscription Cancel TERMINATE: Subscription termination
data.subscriptionPlan.subjectstringNosubscription topic, required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.descriptionstringNosubscription description, required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.totalPeriodsstringNototal subscription periods. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.periodRuleobjectNosubscription rules
data.subscriptionPlan.periodRule.periodUnitstringYessubscription deduction cycle, deduct by month (M), day (D), week (W), year (Y). Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.periodRule.periodCountstringYessubscription deduction frequency. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.periodAmountobjectNofixed period deduction amount. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.periodAmount.amountnumberYesfixed period deduction amount. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.periodAmount.currencystringYesfixed period deduction currency. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.trialPeriodConfigobjectNodiscount period rules
data.subscriptionPlan.trialPeriodConfig.trialPeriodCountstringYesdiscount period count.
data.subscriptionPlan.trialPeriodConfig.trialPeriodAmountobjectYesdiscount deduct amount.
data.subscriptionPlan.trialPeriodConfig.trialPeriodAmount.amountnumberNodiscount deduct amount. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.trialPeriodConfig.trialPeriodAmount.currencystringNodiscount deduct currency. Required when payment method is APPLEPAY or GOOGLEPAY and merchant manages subscription plan
data.subscriptionPlan.trialConfigobjectNoSubscription trial for n days information
data.subscriptionPlan.trialConfig.trialAmountobjectYesTrial fee information
data.subscriptionPlan.trialConfig.trialAmount.amountnumberYesTrial fee
data.subscriptionPlan.trialConfig.trialAmount.currencystringYesTrial currency
data.subscriptionPlan.trialConfig.trialDaysnumberYesTrial days
data.subscriptionPlan.pricesarray[object]NoThe price info.
data.subscriptionPlan.prices[].priceIDstringYesThe price ID.
data.subscriptionPlan.prices[].quantitynumberYesThe price quantity.

Response Example

json
{
  "code": "APPLY_SUCCESS",
  "msg": "Success.",
  "data": {
    "subscriptionRequestId": "testRequestId0001",
    "subscriptionPlan": {
      "subscriptionStatus": "INACTIVE",
      "subscriptionNo": "SUB26052902512201000064003",
      "subject": "subject",
      "trialConfig": {
        "trialDays": 3,
        "trialAmount": {
          "amount": 100,
          "currency": "KRW"
        }
      },
      "description": "PMMAX周期首期扣款",
      "totalPeriods": 4,
      "trialPeriodConfig": {
        "trialPeriodCount": 2,
        "trialPeriodAmount": {
          "amount": 200,
          "currency": "KRW"
        }
      },
      "periodAmount": {
        "amount": 4000,
        "currency": "KRW"
      },
      "periodRule": {
        "periodCount": 1,
        "periodUnit": "M"
      },
      "prices": [
        {
          "quantity": 1,
          "priceId": "PRICE0029177685919882013650001"
        },
        {
          "quantity": 2,
          "priceId": "PRICE0060177727844403510340001"
        }
      ]
    }
  }
}

Was this page helpful?

Thank you for your help in improving PayerMax Product Docs!

Released under the MIT License.