This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Coupons in Recurly
Overview
The following operations allow you to work with coupons. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with coupons, see Sample configuration.
Operation | Description |
---|---|
Creates a coupon. | |
getCouponByCode | Retrieves a coupon by code. |
listCoupons | Retrieves all the coupons. |
Operation details
This section provides further details on the operations related to coupons.
Creating a coupon
The createCoupon
operation creates a coupon.
<recurly.createCoupon> <planCodes>{$ctx:planCodes}</planCodes> <hostedDescription>{$ctx:hostedDescription}</hostedDescription> <discountType>{$ctx:discountType}</discountType> <appliesForMonths>{$ctx:appliesForMonths}</appliesForMonths> <name>{$ctx:name}</name> <discountInCents>{$ctx:discountInCents}</discountInCents> <maxRedemptions>{$ctx:maxRedemptions}</maxRedemptions> <redeemByDate>{$ctx:redeemByDate}</redeemByDate> <couponCode>{$ctx:couponCode}</couponCode> <discountPercent>{$ctx:discountPercent}</discountPercent> <singleUse>{$ctx:singleUse}</singleUse> <invoiceDescription>{$ctx:invoiceDescription}</invoiceDescription> <appliesToAllPlans>{$ctx:appliesToAllPlans}</appliesToAllPlans> </recurly.createCoupon>
Properties
Required - The ID of the coupon to be created.couponCode:
Required - The name of the coupon.name:
Required - The type of the discount as percent or dollars.discountType:
The array of plan codes the coupon applies to.planCodes:
The description of the coupon on the hosted payment page.hostedDescription:
The number of months for which the coupon is valid after redemption.appliesForMonths:
The mapping of discount amounts by currency if discount_type is "dollars".discountInCents:
The maximum number of accounts for which the coupon can be used.maxRedemptions:
The last date to redeem the coupon.redeemByDate:
The discount percentage if discount_type is "percent".discountPercent:
The boolean flag indicating that the coupon can be used only once.singleUse:
The description of the coupon on the invoice.invoiceDescription:
The boolean flag indicating whether the coupon is applied for all the plans.appliesToAllPlans:
Sample request
Following is a sample REST/XML request that can be handled by the
operation.createCoupon
<createCoupon> <apiUrl>https://virasoft.recurly.com</apiUrl> <apiKey>3eee78b99ffa4206a0374615f430f50a</apiKey> <couponCode>test_coupon</couponCode> <name>Test Coupon</name> <discountType>dollars</discountType> <discountPercent></discountPercent> <discountInCents> <values> <USD>500</USD> <EUR>400</EUR> <GBP>300</GBP> </values> </discountInCents> <planCodes> <values> <plan_code>1</plan_code> <plan_code>2</plan_code> </values> </planCodes> <hostedDescription>hosted description</hostedDescription> <invoiceDescription>invoice description</invoiceDescription> <appliesForMonths>2</appliesForMonths> <maxRedemptions>10</maxRedemptions> <redeemByDate>2015-03-01</redeemByDate> <singleUse>false</singleUse> <appliesToAllPlans>false</appliesToAllPlans> </createCoupon>
Related Recurly documentation
https://docs.recurly.com/api/coupons#create-coupon
Retrieving a coupon by code
The
operation retrieves a coupon by code.getCouponByCode
<recurly.getCouponByCode> <couponCode>{$ctx:couponCode}</couponCode> </recurly.getCouponByCode>
Properties
Required - The ID of the coupon to be fetched.couponCode:
Sample request
Following is a sample REST/XML request that can be handled by the
operation.getCouponByCode
<getCouponByCode> <apiUrl>https://virasoft.recurly.com</apiUrl> <apiKey>3eee78b99ffa4206a0374615f430f50a</apiKey> <couponCode>gold_special</couponCode> </getCouponByCode>
Related Recurly documentation
https://docs.recurly.com/api/coupons#lookup-coupon
Retrieving all the coupons
The
operation retrieves all the coupons.listCoupons
<recurly.listCoupons> <cursor>{$ctx:cursor}</cursor> <state>{$ctx:state}</state> <perPage>{$ctx:perPage}</perPage> </recurly.listCoupons>
Properties
The cursor value retrieved from the Link header for requesting a specific page.cursor:
The state of the coupons.state:
The number of records to be retrieved per page.perPage:
Sample request
Following is a sample REST/XML request that can be handled by the
operation.listCoupons
<listCoupons> <apiUrl>https://virasoft.recurly.com</apiUrl> <apiKey>3eee78b99ffa4206a0374615f430f50a</apiKey> <cursor></cursor> <state>redeemable</state> <perPage>1</perPage> </listCoupons>
Related Recurly documentation
https://docs.recurly.com/api/coupons#list-coupons
Sample configuration
Following is a sample proxy service that illustrates how to connect to Recurly with the init
operation and use the
operation. The sample request for this proxy can be found in the createCoupon sample request. You can use this sample as a template for using other operations in this category.createCoupon
<proxy xmlns="http://ws.apache.org/ns/synapse" name="recurly_createCoupon" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="apiUrl" expression="//apiUrl/text()"/> <property name="apiKey" expression="//apiKey/text()"/> <property name="planCodes" expression="//planCodes/values"/> <property name="hostedDescription" expression="//hostedDescription/text()"/> <property name="discountType" expression="//discountType/text()"/> <property name="appliesForMonths" expression="//appliesForMonths/text()"/> <property name="name" expression="//name/text()"/> <property name="discountInCents" expression="//discountInCents/values"/> <property name="maxRedemptions" expression="//maxRedemptions/text()"/> <property name="redeemByDate" expression="//redeemByDate/text()"/> <property name="couponCode" expression="//couponCode/text()"/> <property name="discountPercent" expression="//discountPercent/text()"/> <property name="singleUse" expression="//singleUse/text()"/> <property name="invoiceDescription" expression="//invoiceDescription/text()"/> <property name="appliesToAllPlans" expression="//appliesToAllPlans/text()"/> <recurly.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <apiKey>{$ctx:apiKey}</apiKey> </recurly.init> <recurly.createCoupon> <planCodes>{$ctx:planCodes}</planCodes> <hostedDescription>{$ctx:hostedDescription}</hostedDescription> <discountType>{$ctx:discountType}</discountType> <appliesForMonths>{$ctx:appliesForMonths}</appliesForMonths> <name>{$ctx:name}</name> <discountInCents>{$ctx:discountInCents}</discountInCents> <maxRedemptions>{$ctx:maxRedemptions}</maxRedemptions> <redeemByDate>{$ctx:redeemByDate}</redeemByDate> <couponCode>{$ctx:couponCode}</couponCode> <discountPercent>{$ctx:discountPercent}</discountPercent> <singleUse>{$ctx:singleUse}</singleUse> <invoiceDescription>{$ctx:invoiceDescription}</invoiceDescription> <appliesToAllPlans>{$ctx:appliesToAllPlans}</appliesToAllPlans> </recurly.createCoupon> <respond/> </inSequence> <outSequence> <send/> </outSequence> </target> <description/> </proxy>