You can host the Adyen checkout form at your end and still use Chargebee for managing the subscription cycles. Once the checkout process is completed, you can pass the final result of Adyen Hosted Payment Page response to Chargebee via API.
Adyen payment fields: https://docs.adyen.com/developers/hpp-manual#hpppaymentfields
Adyen HPP response: https://docs.adyen.com/developers/hpp-manual#hpppaymentresponse
Only the following endpoints accept Adyen checkout response:
Note: You need to pass both payment_method[type] and payment_method[gateway_account_id] params. Make sure you’ve also set the payment_method[type] value to generic.
Additional Parameters:
- payment_method[adyen_auth_result] -- Enumerated String
Required: true
Possible values: authorised, pending
Desc: Outcome of the payment. This value maps to the Adyen HPP response authResult attribute.
- payment_method[adyen_psp_reference] -- String
Required: false
Max chars: 50
Desc: Adyen transaction id. This value maps to the Adyen HPP response pspReference attribute.
- payment_method[adyen_shopper_reference] -- String
Required: true
Max chars: 100
Desc: A reference to uniquely identify the shopper. This value maps to the shopperReference payment field.
- payment_method[adyen_merchant_reference] -- String
Required: true
Max chars: 64
Desc: A reference to uniquely identify the payment. This value maps to the merchantReference payment field.
- payment_method[adyen_brand_code] -- String
Required: true
Max chars: 30
Desc: Payment method used in the transaction. This value maps to the Adyen HPP response paymentMethod attribute.
Supported brand codes: mc, visa, amex, discover, diners, jcb, alipay, cup, unionpay, wechatpay
- payment_method[adyen_payment_amount] -- Integer ( In cents )
Required: true
Min val: 0
Desc: Payment amount. This value maps to the paymentAmount payment field.
- payment_method[adyen_currency_code] -- String (ISO 4217 format)
Required: true
Max chars: 3
Desc: Payment currency. This value maps to the currencyCode payment field
- payment_method[adyen_recurring] - Boolean
Required: true
Possible values: true, false
Desc: Whether the payment is recurring or not. If the value is false, the payment method in Chargebee will be marked as Invalid.
Note: Alipay and WeChat Pay only support one time payments at the moment and therefore, you should pass the recurring parameter as 'false'.
Sample API Calls:
1) Create a subscription:
curl https://{site}.chargebee.com/api/v2/subscriptions \ -u {site_api_key}: \ -d customer[email]="john@user.com" \ -d customer[first_name]="John" \ -d customer[last_name]="Doe" \ -d customer[locale]="fr-CA" \ -d customer[phone]="+1-949-999-9999" \ -d plan_id="no-trial" \ -d billing_address[first_name]="John" \ -d billing_address[last_name]="Doe" \ -d billing_address[line1]="PO Box 9999" \ -d billing_address[city]="Walnut" \ -d billing_address[state]="California" \ -d billing_address[zip]="91789" \ -d billing_address[country]="US" \ -d payment_method[type]="generic" \ -d payment_method[gateway_account_id]="gw_Hu0gpoeQE47X2W1" \ -d payment_method[adyen_auth_result]="AUTHORISED" \ -d payment_method[adyen_psp_reference]="8524913819097242" \ -d payment_method[adyen_shopper_reference]="348367627" \ -d payment_method[adyen_merchant_reference]="3Nl8GHMQ9VbIqN5e" \ -d payment_method[adyen_brand_code]="cup" \ -d payment_method[adyen_currency_code]="USD" \ -d payment_method[adyen_payment_amount]="900" \ -d payment_method[adyen_recurring]="true" \
2) Update a subscription:
curl https://{site}.chargebee.com/api/v2/subscriptions/HtZEwWAQFttuv41 \ -u {site_api_key}: \ -d plan_id="no-trial" \ -d billing_address[first_name]="John" \ -d billing_address[last_name]="Doe" \ -d billing_address[line1]="PO Box 9999" \ -d billing_address[city]="Walnut" \ -d billing_address[state]="California" \ -d billing_address[zip]="91789" \ -d billing_address[country]="US" \ -d payment_method[type]="generic" \ -d payment_method[gateway_account_id]="gw_Hu0gpoeQE47X2W1" \ -d payment_method[adyen_auth_result]="AUTHORISED" \ -d payment_method[adyen_psp_reference]="8524913819097242" \ -d payment_method[adyen_shopper_reference]="348367627" \ -d payment_method[adyen_merchant_reference]="3Nl8GHMQ9VbIqN5e" \ -d payment_method[adyen_brand_code]="cup" \ -d payment_method[adyen_currency_code]="USD" \ -d payment_method[adyen_payment_amount]="900" \ -d payment_method[adyen_recurring]="true" \
3) Create a customer:
curl https://{site}.chargebee.com/api/v2/customers \ -u {site_api_key}: \ -d first_name="John" \ -d last_name="Doe" \ -d email="john@test.com" \ -d locale="fr-CA" \ -d billing_address[first_name]="John" \ -d billing_address[last_name]="Doe" \ -d billing_address[line1]="PO Box 9999" \ -d billing_address[city]="Walnut" \ -d billing_address[state]="California" \ -d billing_address[zip]="91789" \ -d billing_address[country]="US" \ -d payment_method[type]="generic" \ -d payment_method[gateway_account_id]="gw_Hu0gpoeQE47X2W1" \ -d payment_method[adyen_auth_result]="AUTHORISED" \ -d payment_method[adyen_psp_reference]="8524913819097242" \ -d payment_method[adyen_shopper_reference]="348367627" \ -d payment_method[adyen_merchant_reference]="3Nl8GHMQ9VbIqN5e" \ -d payment_method[adyen_brand_code]="alipay" \ -d payment_method[adyen_currency_code]="USD" \ -d payment_method[adyen_payment_amount]="0" \ -d payment_method[adyen_recurring]="false" \
4) Update payment method for a customer:
curl https://{site}.chargebee.com/api/v2/customers/4gkYnd21ouvW/update_payment_method \ -u {site_api_key}: \ -d payment_method[type]="generic" \ -d payment_method[gateway_account_id]="gw_Hu0gpoeQE47X2W1" \ -d payment_method[adyen_auth_result]="AUTHORISED" \ -d payment_method[adyen_psp_reference]="8524913819097242" \ -d payment_method[adyen_shopper_reference]="348367627" \ -d payment_method[adyen_merchant_reference]="3Nl8GHMQ9VbIqN5e" \ -d payment_method[adyen_brand_code]="alipay" \ -d payment_method[adyen_currency_code]="USD" \ -d payment_method[adyen_payment_amount]="0" \ -d payment_method[adyen_recurring]="false" \
5) Collect Payment for a Customer:
curl https://{site}.chargebee.com/api/v2/customers/4gkYnd21ouvW/collect_payment \ -X POST \ -u {site_api_key}:\ -d payment_method[gateway_account_id]="gw___dev__KyVoa5QVh8lS11z"\ -d payment_method[type]="generic"\ -d payment_method[adyen_auth_result]="AUTHORISED" \ -d payment_method[adyen_psp_reference]="test12345" \ -d payment_method[adyen_shopper_reference]="348367627" \ -d payment_method[adyen_merchant_reference]="merchantRef2" \ -d payment_method[adyen_brand_code]="alipay" \ -d payment_method[adyen_currency_code]="USD" \ -d payment_method[adyen_payment_amount]="900" \ -d payment_method[adyen_recurring]="false"\ -d invoice_allocations[invoice_id][0]="__demo_inv__35" -d invoice_allocations[invoice_id][1]="__demo_inv__36" -d invoice_allocations[allocation_amount][0]=”1200” -d invoice_allocations[allocation_amount][1]=”2400”