AlipayHK Preapproval Request

Definition: POST /v1/preapprovals

To initiate a preapproval, you must create a preapproval object. The parameters of the preapproval are sent in the message body as a JSON object. See below an example of a preapproval request for AlipayHK (1143).

Request:

POST https://paytest.smart2pay.com/v1/preapprovals
Authorization: Basic MzAyMDE6KzlLZUd6S0Y3VzhTLzc5YTVSMzNZSlVnN0U3V0ZOY1piakdmekxWM2JYU25GQ095RnQ=

{
 "Preapproval": {
   "MerchantPreapprovalID": "s2ptest_alipayhk1",
   "Currency": "HKD",
   "Description": "1 year subscription",
   "ReturnURL": "http://demo.smart2pay.com/redirect.php",
   "MethodID": 1145,
   "Customer": {
      "FirstName": "John",
      "LastName": "Doe",
      "Email": "jdoe@gmail.com"
     },
   "BillingAddress": {
      "Country": "HK"
      }
   }
}

Response:

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8

{
    "Preapproval": {
        "ID": 28082,
        "Created": "20210202165209",
        "MethodID": 1145,
        "SiteID": 30201,
        "MerchantPreapprovalID": "s2ptest_alipayhk1",
        "RecurringPeriod": 0,
        "PreapprovedMaximumAmount": null,
        "Currency": "HKD",
        "ReturnURL": "http://demo.smart2pay.com/redirect.php",
        "Description": "1 year subscription",
        "Customer": {
            "ID": 2625948,
            "MerchantCustomerID": null,
            "Email": "jdoe@gmail.com",
            "FirstName": "John",
            "LastName": "Doe",
            "Gender": null,
            "SocialSecurityNumber": null,
            "Phone": null,
            "Company": null,
            "DateOfBirth": null
        },
        "BillingAddress": {
            "ID": 986,
            "City": null,
            "ZipCode": null,
            "State": null,
            "Street": null,
            "StreetNumber": null,
            "HouseNumber": null,
            "HouseExtension": null,
            "Country": "HK"
        },
        "Status": {
            "ID": 1,
            "Info": "Pending",
            "Reasons": null
        },
        "RedirectURL": "https://europaytest.smart2pay.com/AlipayOSP/Preapproval/PreapprovalLanding.aspx?ID=23265&Hash=030CBF27F3759B369266CCBC5D84C98A",
        "MethodOptionID": 0,
        "PreapprovedFrequency": null,
        "MandateReference": null,
        "Details": null
    }
}

AlipayHK Preapproval Flow

AlipayHK Test Data
Data Value
Phone Number: Enter any 10 digit number. Example: 1234567812
Verification code: Enter any 6 digit number. Example: 123456
Payment password: Enter any 6 digit number. Example: 123456
  1. The customer is redirected to AlipayHK page. The customer needs to add their phone number attached to the AlipayHK wallet.
    1 Add phone number
  2. The customer enters the SMS verification code received via mobile phone.
    1 Verification Code
  3. The customer sees the preapproval details, agrees with the AlipayHK Terms and Conditions and confirms the auto-debit user agreement.
    1 Confirm agreement
  4. The customer enters the payment password. For testing purposes, enter any 6 digit number eg. 123456.
    1 Confirm agreement
  5. The customer is redirected to the AlipayHK confirmation page.
    1 Confirmation page
  6. Upon completion of the payment flow, the customer is redirected to your ReturnUrl.1 Return page when the redirection status is processing

AlipayHK Preapproval Notification

We will notify you about the new status of the preapproval to the Notification URL you setup in the Merchant Dashboard. The format of the received notification has the same structure as the response of the initial request.

You need to respond with HTTP code 204 (No Content)!

Preapproval notification format:

Authorization: Basic MzAyMDE6KzlLZUd6S0Y3VzhTLzc5YTVSMzNZSlVnN0U3V0ZOY1piakdmekxWM2JYU25GQ095RnQ=



{
  "Preapproval": {
    "ID": 28082,
    "Created": "20210202165209",
    "MethodID": 1145,
    "SiteID": 30201,
    "MerchantPreapprovalID": "s2ptest_alipayhk1",
    "RecurringPeriod": null,
    "PreapprovedMaximumAmount": null,
    "Currency": null,
    "ReturnURL": "http://demo.smart2pay.com/redirect.php",
    "Description": "1 year subscription",
    "Customer": {
      "ID": 2625948,
      "MerchantCustomerID": null,
      "Email": "jdoe@gmail.com",
      "FirstName": "John",
      "LastName": "Doe",
      "Gender": null,
      "SocialSecurityNumber": null,
      "Phone": null,
      "Company": null,
      "DateOfBirth": null
    },
    "BillingAddress": {
      "ID": 986,
      "City": null,
      "ZipCode": null,
      "State": null,
      "Street": null,
      "StreetNumber": null,
      "HouseNumber": null,
      "HouseExtension": null,
      "Country": "HK"
    },
    "Status": {
      "ID": 2,
      "Info": null,
      "Reasons": null
    },
    "RedirectURL": null,
    "MethodOptionID": null,
    "PreapprovedFrequency": null,
    "MandateReference": null,
    "Details": null
  }
}

AlipayHK Recurring Payment

Definition: POST /v1/payments/recurrent

A recurring payment is created in the same manner a one-off payment is created. In addition, you need to send the PreapprovalID (the PreapprovalID received when you created/opened a preapproval) and the information specific to each payment method.

For AlipayHK (1145), you need to send the PreapprovalID (the PreapprovalID received when you created/opened a preapproval) and the Amount to be captured.

Checkout the below example of a recurring payment request for AlipayHK (1145) that is based on the PreapprovalID. Please send in the payment request the Description parameter and Country parameter that should be the same with the one sent in the Preapproval request.

Request:

POST https://paytest.smart2pay.com/v1/payments/recurrent
Authorization: Basic MzAyMDE6KzlLZUd6S0Y3VzhTLzc5YTVSMzNZSlVnN0U3V0ZOY1piakdmekxWM2JYU25GQ095RnQ=

{
  "Payment": {
    "PreapprovalID": 28082,
    "MerchantTransactionID": "s2ptest_alipayhk2",
    "Amount": 100,
    "Currency": "HKD",
    "MethodID": 1145,
    "Description": "Recurring payment",
    "BillingAddress": {
    "Country": "HK"
    } 
  }
}

Response:

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8

{
    "Payment": {
        "ID": 5879765,
        "SkinID": null,
        "ClientIP": null,
        "Created": "20210202171203",
        "MerchantTransactionID": "s2ptest_alipayhk2",
        "OriginatorTransactionID": null,
        "Amount": "100",
        "Currency": "HKD",
        "CapturedAmount": null,
        "ReturnURL": null,
        "Description": "Recurring payment",
        "MethodID": 1145,
        "MethodOptionID": null,
        "IncludeMethodIDs": null,
        "ExcludeMethodIDs": null,
        "PrioritizeMethodIDs": null,
        "SiteID": 30201,
        "NotificationDateTime": null,
        "Customer": null,
        "BillingAddress": {
            "ID": 986,
            "City": null,
            "ZipCode": null,
            "State": null,
            "Street": null,
            "StreetNumber": null,
            "HouseNumber": null,
            "HouseExtension": null,
            "Country": "HK"
        },
        "ShippingAddress": null,
        "Articles": null,
        "Details": null,
        "ReferenceDetails": null,
        "CustomParameters": null,
        "PreapprovalID": 28082,
        "Status": {
            "ID": 1,
            "Info": "Open",
            "Reasons": null
        },
        "Fraud": null,
        "MethodTransactionID": null,
        "TokenLifetime": null,
        "Capture": null,
        "PreapprovalDetails": null,
        "RedirectURL": null,
        "Splits": null
    }
}

We will notify you about the new status of the payment to the Notification URL you setup in the Merchant Dashboard. The format of the received notification has the same structure as the response of the initial request.

You need to respond with HTTP code 204 (No Content)!

Payment notification format:

Authorization: Basic MzAyMDE6KzlLZUd6S0Y3VzhTLzc5YTVSMzNZSlVnN0U3V0ZOY1piakdmekxWM2JYU25GQ095RnQ=

{
  "Payment": {
    "ID": 5879765,
    "SkinID": null,
    "ClientIP": null,
    "Created": "20210202171203",
    "MerchantTransactionID": "s2ptest_alipayhk2",
    "OriginatorTransactionID": null,
    "Amount": "100",
    "Currency": "HKD",
    "CapturedAmount": null,
    "ReturnURL": "",
    "Description": "Recurring payment",
    "MethodID": 1145,
    "MethodOptionID": null,
    "IncludeMethodIDs": null,
    "ExcludeMethodIDs": null,
    "PrioritizeMethodIDs": null,
    "SiteID": 30201,
    "NotificationDateTime": null,
    "Customer": null,
    "BillingAddress": {
      "ID": 986,
      "City": null,
      "ZipCode": null,
      "State": null,
      "Street": null,
      "StreetNumber": null,
      "HouseNumber": null,
      "HouseExtension": null,
      "Country": "HK"
    },
    "ShippingAddress": null,
    "Articles": null,
    "Details": null,
    "ReferenceDetails": null,
    "CustomParameters": null,
    "PreapprovalID": 28082,
    "Status": {
      "ID": 2,
      "Info": "Success",
      "Reasons": null
    },
    "Fraud": null,
    "MethodTransactionID": null,
    "TokenLifetime": null,
    "Capture": null,
    "PreapprovalDetails": null,
    "RedirectURL": null,
    "Splits": null
  }
}