# Create subscription POST https://api-sandbox.payabli.com/api/Subscription/add Content-Type: application/json Creates a subscription or scheduled payment to run at a specified time and frequency. Reference: https://docs.payabli.com/developers/api-reference/subscription/create-a-subscription-or-scheduled-payment ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create Subscription version: endpoint_subscription.NewSubscription paths: /Subscription/add: post: operationId: new-subscription summary: Create Subscription description: >- Creates a subscription or scheduled payment to run at a specified time and frequency. tags: - - subpackage_subscription parameters: - name: forceCustomerCreation in: query required: false schema: $ref: '#/components/schemas/type_:ForceCustomerCreation' - name: requestToken in: header required: true schema: type: string - name: idempotencyKey in: header required: false schema: $ref: '#/components/schemas/type_:IdempotencyKey' responses: '200': description: Success content: application/json: schema: $ref: '#/components/schemas/type_subscription:AddSubscriptionResponse' '400': description: Bad request/ invalid data content: {} '401': description: Unauthorized request. content: {} '500': description: Internal API Error content: {} '503': description: Database connection error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/type_subscription:SubscriptionRequestBody' components: schemas: type_:ForceCustomerCreation: type: boolean type_:IdempotencyKey: type: string type_:AdditionalData: type: object additionalProperties: type: object additionalProperties: description: Any type type_:BillingAddressNullable: type: string type_:BillingAddressAddtlNullable: type: string type_:BillingCityNullable: type: string type_:BillingCountryNullable: type: string type_:Email: type: string format: email type_:PhoneNumber: type: string type_:BillingStateNullable: type: string type_:BillingZip: type: string type_:CustomerId: type: integer format: int64 type_:CustomerNumberNullable: type: string type_:Identifierfields: type: array items: type: string type_:Shippingaddress: type: string type_:Shippingaddressadditional: type: string type_:Shippingcity: type: string type_:Shippingcountry: type: string type_:Shippingstate: type: string type_:Shippingzip: type: string type_:PayorDataRequest: type: object properties: additionalData: $ref: '#/components/schemas/type_:AdditionalData' billingAddress1: $ref: '#/components/schemas/type_:BillingAddressNullable' billingAddress2: $ref: '#/components/schemas/type_:BillingAddressAddtlNullable' billingCity: $ref: '#/components/schemas/type_:BillingCityNullable' billingCountry: $ref: '#/components/schemas/type_:BillingCountryNullable' billingEmail: $ref: '#/components/schemas/type_:Email' billingPhone: $ref: '#/components/schemas/type_:PhoneNumber' billingState: $ref: '#/components/schemas/type_:BillingStateNullable' billingZip: $ref: '#/components/schemas/type_:BillingZip' description: >- Customer's billing ZIP code. For Pay In functions, this field supports 5-digit and 9-digit ZIP codes and alphanumeric Canadian postal codes. For example: "37615-1234" or "37615". company: type: string description: Customer's company name. customerId: $ref: '#/components/schemas/type_:CustomerId' customerNumber: $ref: '#/components/schemas/type_:CustomerNumberNullable' firstName: type: string description: Customer/Payor first name. identifierFields: $ref: '#/components/schemas/type_:Identifierfields' lastName: type: string description: Customer/Payor last name. shippingAddress1: $ref: '#/components/schemas/type_:Shippingaddress' shippingAddress2: $ref: '#/components/schemas/type_:Shippingaddressadditional' shippingCity: $ref: '#/components/schemas/type_:Shippingcity' shippingCountry: $ref: '#/components/schemas/type_:Shippingcountry' shippingState: $ref: '#/components/schemas/type_:Shippingstate' shippingZip: $ref: '#/components/schemas/type_:Shippingzip' type_:Entrypointfield: type: string type_:AdditionalDataMap: type: object additionalProperties: type: string type_:FileContentFtype: type: string enum: - value: pdf - value: doc - value: docx - value: jpg - value: jpeg - value: png - value: gif - value: txt type_:FileContent: type: object properties: fContent: type: string description: >- Content of file, Base64-encoded. Ignored if furl is specified. Max upload size is 30 MB. filename: type: string description: The name of the attached file. ftype: $ref: '#/components/schemas/type_:FileContentFtype' description: The MIME type of the file (if content is provided) furl: type: string description: Optional URL provided to show or download the file remotely type_:Attachments: type: array items: $ref: '#/components/schemas/type_:FileContent' type_:Discount: type: number format: double type_:DutyAmount: type: number format: double type_:FreightAmount: type: number format: double type_:Frequency: type: string enum: - value: onetime - value: weekly - value: every2weeks - value: every6months - value: monthly - value: every3months - value: annually type_:InvoiceAmount: type: number format: double type_:Datenullable: type: string format: date type_:InvoiceNumber: type: string type_:Invoicestatus: type: integer type_:InvoiceType: type: integer type_:ItemCommodityCode: type: string type_:ItemDescription: type: string type_:ItemProductCode: type: string type_:ItemProductName: type: string type_:ItemUnitofMeasure: type: string type_:BillItem: type: object properties: itemCategories: type: array items: type: string description: Array of tags classifying item or product. itemCommodityCode: $ref: '#/components/schemas/type_:ItemCommodityCode' itemCost: type: number format: double description: Item or product price per unit. itemDescription: $ref: '#/components/schemas/type_:ItemDescription' itemMode: type: integer description: >- Internal class of item or product: value '0' is only for invoices , '1' for bills and, '2' common for both. itemProductCode: $ref: '#/components/schemas/type_:ItemProductCode' itemProductName: $ref: '#/components/schemas/type_:ItemProductName' itemQty: type: integer description: Quantity of item or product. itemTaxAmount: type: number format: double description: Tax amount applied to item or product. itemTaxRate: type: number format: double description: Tax rate applied to item or product. itemTotalAmount: type: number format: double description: Total amount in item or product. itemUnitOfMeasure: $ref: '#/components/schemas/type_:ItemUnitofMeasure' required: - itemCost type_:BillDataPaymentTerms: type: string enum: - value: PIA - value: CIA - value: UR - value: NET10 - value: NET20 - value: NET30 - value: NET45 - value: NET60 - value: NET90 - value: EOM - value: MFI - value: 5MFI - value: 10MFI - value: 15MFI - value: 20MFI - value: 2/10NET30 - value: UF - value: 10UF - value: 20UF - value: 25UF - value: 50UF type_:PurchaseOrder: type: string type_:ShippingFromZip: type: string type_:SummaryCommodityCode: type: string type_:Tax: type: number format: double type_:TermsConditions: type: string type_:BillData: type: object properties: AdditionalData: $ref: '#/components/schemas/type_:AdditionalDataMap' attachments: $ref: '#/components/schemas/type_:Attachments' company: type: string description: Company name of the recipient of the invoice. discount: $ref: '#/components/schemas/type_:Discount' dutyAmount: $ref: '#/components/schemas/type_:DutyAmount' firstName: type: string description: First name of the recipient of the invoice. freightAmount: $ref: '#/components/schemas/type_:FreightAmount' frequency: $ref: '#/components/schemas/type_:Frequency' description: Frequency of scheduled invoice. invoiceAmount: $ref: '#/components/schemas/type_:InvoiceAmount' invoiceDate: $ref: '#/components/schemas/type_:Datenullable' description: 'Invoice date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY.' invoiceDueDate: $ref: '#/components/schemas/type_:Datenullable' description: >- Invoice due date in one of the accepted formats: YYYY-MM-DD, MM/DD/YYYY. invoiceEndDate: $ref: '#/components/schemas/type_:Datenullable' description: >- Indicate the date to finish a scheduled invoice cycle (`invoiceType`` = 1) in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY. invoiceNumber: $ref: '#/components/schemas/type_:InvoiceNumber' description: Invoice number. Identifies the invoice under a paypoint. invoiceStatus: $ref: '#/components/schemas/type_:Invoicestatus' invoiceType: $ref: '#/components/schemas/type_:InvoiceType' items: type: array items: $ref: '#/components/schemas/type_:BillItem' description: Array of line items included in the invoice. lastName: type: string description: Last name of the recipient of the invoice. notes: type: string description: Notes included in the invoice. paymentTerms: $ref: '#/components/schemas/type_:BillDataPaymentTerms' purchaseOrder: $ref: '#/components/schemas/type_:PurchaseOrder' shippingAddress1: $ref: '#/components/schemas/type_:Shippingaddress' shippingAddress2: $ref: '#/components/schemas/type_:Shippingaddressadditional' shippingCity: $ref: '#/components/schemas/type_:Shippingcity' shippingCountry: $ref: '#/components/schemas/type_:Shippingcountry' shippingEmail: $ref: '#/components/schemas/type_:Email' description: Shipping recipient's contact email address. shippingFromZip: $ref: '#/components/schemas/type_:ShippingFromZip' shippingPhone: type: string description: Recipient phone number. shippingState: $ref: '#/components/schemas/type_:Shippingstate' shippingZip: $ref: '#/components/schemas/type_:Shippingzip' summaryCommodityCode: $ref: '#/components/schemas/type_:SummaryCommodityCode' tax: $ref: '#/components/schemas/type_:Tax' termsConditions: $ref: '#/components/schemas/type_:TermsConditions' type_:PaymentCategories: type: object properties: amount: type: number format: double description: Price/cost per unit of item or category. description: type: string description: Description of item or category label: type: string description: Name of item or category. qty: type: integer default: 1 description: Quantity of item or category required: - amount - label type_:SplitFundingContent: type: object properties: accountId: type: string description: The accountId for the account the split should be sent to. amount: type: number format: double description: Amount from the transaction to sent to this recipient. description: type: string description: A description for the split. recipientEntryPoint: type: string description: The entrypoint the split should be sent to. type_:SplitFunding: type: array items: $ref: '#/components/schemas/type_:SplitFundingContent' type_:PaymentDetail: type: object properties: categories: type: array items: $ref: '#/components/schemas/type_:PaymentCategories' description: >- Array of payment categories/line items describing the amount to be paid. **Note**: These categories are for information only and aren't validated against the total amount provided. checkImage: type: object additionalProperties: description: Any type description: Object containing image of paper check. checkNumber: type: string description: >- A check number to be used in the ach transaction. **Required** for payment method = 'check'. currency: type: string description: >- The currency for the transaction, `USD` or `CAD`. If your paypoint is configured for CAD, you must send the `CAD` value in this field, otherwise it defaults to USD, which will cause the transaction to fail. serviceFee: type: number format: double description: >- Service fee to be deducted from the total amount. This amount must be a number, percentages aren't accepted. If you are using a percentage-based fee schedule, you must calculate the value manually. splitFunding: $ref: '#/components/schemas/type_:SplitFunding' description: >- Split funding instructions for the transaction. See [Split a Transaction](/developers/developer-guides/money-in-split-funding) for more. totalAmount: type: number format: double description: >- Total amount to be charged. If a service fee is sent, then this amount should include the service fee." required: - totalAmount type_:Cardcvv: type: string type_:Cardexp: type: string type_:Cardholder: type: string type_:Cardnumber: type: string type_:Cardzip: type: string type_:Initiator: type: string type_:SaveIfSuccess: type: boolean type_:PayMethodCredit: type: object properties: cardcvv: $ref: '#/components/schemas/type_:Cardcvv' cardexp: $ref: '#/components/schemas/type_:Cardexp' cardHolder: $ref: '#/components/schemas/type_:Cardholder' cardnumber: $ref: '#/components/schemas/type_:Cardnumber' cardzip: $ref: '#/components/schemas/type_:Cardzip' initiator: $ref: '#/components/schemas/type_:Initiator' method: type: string enum: - type: stringLiteral value: card description: >- Method to use for the transaction. For transactions with a credit or debit card, or a tokenized card, use `card`. saveIfSuccess: $ref: '#/components/schemas/type_:SaveIfSuccess' required: - cardexp - cardnumber - method type_:Achaccount: type: string type_:Achaccounttype: type: string enum: - value: Checking - value: Savings type_:AchSecCode: type: string type_:AchHolder: type: string type_:AchHolderType: type: string enum: - value: personal - value: business default: personal type_:Achrouting: type: string type_:Device: type: string type_:PayMethodACH: type: object properties: achAccount: $ref: '#/components/schemas/type_:Achaccount' description: Bank account number. This field is **required** when method = 'ach'. achAccountType: $ref: '#/components/schemas/type_:Achaccounttype' description: Bank account type. This field is **required** when method = 'ach'. achCode: $ref: '#/components/schemas/type_:AchSecCode' achHolder: $ref: '#/components/schemas/type_:AchHolder' achHolderType: $ref: '#/components/schemas/type_:AchHolderType' achRouting: $ref: '#/components/schemas/type_:Achrouting' description: >- ABA/routing number of bank account. This field is **required** when method = 'ach'. device: $ref: '#/components/schemas/type_:Device' method: type: string enum: - type: stringLiteral value: ach required: - achAccount - achHolder - achRouting - method type_:Storedmethodid: type: string type_:StoredMethodUsageType: type: string type_subscription:RequestSchedulePaymentMethodInitiator: type: object properties: initiator: $ref: '#/components/schemas/type_:Initiator' storedMethodId: $ref: '#/components/schemas/type_:Storedmethodid' description: Payabli identifier of a tokenized payment method. storedMethodUsageType: $ref: '#/components/schemas/type_:StoredMethodUsageType' type_subscription:RequestSchedulePaymentMethod: oneOf: - $ref: '#/components/schemas/type_:PayMethodCredit' - $ref: '#/components/schemas/type_:PayMethodACH' - $ref: >- #/components/schemas/type_subscription:RequestSchedulePaymentMethodInitiator type_:ScheduleDetail: type: object properties: endDate: type: string description: >- Subscription end date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY or the value `untilcancelled` to indicate a scheduled payment with infinite cycle. frequency: $ref: '#/components/schemas/type_:Frequency' description: Frequency of the subscription. planId: type: integer description: >- This field is for future development, leave null. Identifier of subscription plan applied in the scheduled payment/subscription. startDate: type: string description: >- Subscription start date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY. This must be a future date. type_subscription:SetPause: type: boolean type_:Source: type: string type_:Subdomain: type: string type_subscription:SubscriptionRequestBody: type: object properties: customerData: $ref: '#/components/schemas/type_:PayorDataRequest' description: Object describing the customer/payor. entryPoint: $ref: '#/components/schemas/type_:Entrypointfield' invoiceData: $ref: '#/components/schemas/type_:BillData' description: Object describing an Invoice linked to the subscription. paymentDetails: $ref: '#/components/schemas/type_:PaymentDetail' description: >- Object describing details of the payment. To skip the payment, set the `totalAmount` to 0. Payments will be paused until the amount is updated to a non-zero value. When `totalAmount` is set to 0, the `serviceFee` must also be set to 0. paymentMethod: $ref: '#/components/schemas/type_subscription:RequestSchedulePaymentMethod' description: >- Information about the payment method for the transaction. Required and recommended fields for each payment method type are described in each schema below. scheduleDetails: $ref: '#/components/schemas/type_:ScheduleDetail' description: Object describing the schedule for subscription. setPause: $ref: '#/components/schemas/type_subscription:SetPause' source: $ref: '#/components/schemas/type_:Source' subdomain: $ref: '#/components/schemas/type_:Subdomain' type_:ResponseText: type: string type_:IsSuccess: type: boolean type_subscription:AddSubscriptionResponse: type: object properties: customerId: $ref: '#/components/schemas/type_:CustomerId' responseText: $ref: '#/components/schemas/type_:ResponseText' isSuccess: $ref: '#/components/schemas/type_:IsSuccess' responseData: type: integer description: The identifier of the newly created subscription. required: - responseText - responseData ``` ## SDK Code Examples ```python CardSubscription from payabli import ( PaymentDetail, PayMethodCredit, PayorDataRequest, ScheduleDetail, payabli, ) client = payabli( api_key="YOUR_API_KEY", ) client.subscription.new_subscription( customer_data=PayorDataRequest( customer_id=4440, ), entry_point="f743aed24a", payment_details=PaymentDetail( service_fee=0.0, total_amount=100.0, ), payment_method=PayMethodCredit( cardcvv="123", cardexp="02/25", card_holder="John Cassian", cardnumber="4111111111111111", cardzip="37615", initiator="payor", ), schedule_details=ScheduleDetail( end_date="03-20-2025", frequency="weekly", plan_id=1, start_date="09-20-2024", ), ) ``` ```typescript CardSubscription import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.subscription.newSubscription({ body: { customerData: { customerId: 4440 }, entryPoint: "f743aed24a", paymentDetails: { serviceFee: 0, totalAmount: 100 }, paymentMethod: { cardcvv: "123", cardexp: "02/25", cardHolder: "John Cassian", cardnumber: "4111111111111111", cardzip: "37615", initiator: "payor", method: "card" }, scheduleDetails: { endDate: "03-20-2025", frequency: "weekly", planId: 1, startDate: "09-20-2024" } } }); ``` ```go CardSubscription import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Subscription.NewSubscription( context.TODO(), &sdkgo.RequestSchedule{ Body: &sdkgo.SubscriptionRequestBody{ CustomerData: &sdkgo.PayorDataRequest{ CustomerId: sdkgo.Int64( 4440, ), }, EntryPoint: sdkgo.String( "f743aed24a", ), PaymentDetails: &sdkgo.PaymentDetail{ ServiceFee: sdkgo.Float64( 0, ), TotalAmount: 100, }, PaymentMethod: &sdkgo.RequestSchedulePaymentMethod{ PayMethodCredit: &sdkgo.PayMethodCredit{ Cardcvv: sdkgo.String( "123", ), Cardexp: "02/25", CardHolder: sdkgo.String( "John Cassian", ), Cardnumber: "4111111111111111", Cardzip: sdkgo.String( "37615", ), Initiator: sdkgo.String( "payor", ), }, }, ScheduleDetails: &sdkgo.ScheduleDetail{ EndDate: sdkgo.String( "03-20-2025", ), Frequency: sdkgo.FrequencyWeekly, PlanId: sdkgo.Int( 1, ), StartDate: sdkgo.String( "09-20-2024", ), }, }, }, ) ``` ```csharp CardSubscription using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Subscription.NewSubscriptionAsync( new RequestSchedule { Body = new SubscriptionRequestBody { CustomerData = new PayorDataRequest { CustomerId = 4440 }, EntryPoint = "f743aed24a", PaymentDetails = new PaymentDetail { ServiceFee = 0, TotalAmount = 100 }, PaymentMethod = new PayMethodCredit { Cardcvv = "123", Cardexp = "02/25", CardHolder = "John Cassian", Cardnumber = "4111111111111111", Cardzip = "37615", Initiator = "payor", Method = "card", }, ScheduleDetails = new ScheduleDetail { EndDate = "03-20-2025", Frequency = Frequency.Weekly, PlanId = 1, StartDate = "09-20-2024", }, }, } ); ``` ```ruby CardSubscription require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Subscription/add") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"customerData\": {\n \"customerId\": 4440\n },\n \"entryPoint\": \"f743aed24a\",\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"paymentMethod\": {\n \"cardcvv\": \"123\",\n \"cardexp\": \"02/25\",\n \"cardHolder\": \"John Cassian\",\n \"cardnumber\": \"4111111111111111\",\n \"cardzip\": \"37615\",\n \"initiator\": \"payor\",\n \"method\": \"card\"\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java CardSubscription HttpResponse response = Unirest.post("https://api-sandbox.payabli.com/api/Subscription/add") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"customerData\": {\n \"customerId\": 4440\n },\n \"entryPoint\": \"f743aed24a\",\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"paymentMethod\": {\n \"cardcvv\": \"123\",\n \"cardexp\": \"02/25\",\n \"cardHolder\": \"John Cassian\",\n \"cardnumber\": \"4111111111111111\",\n \"cardzip\": \"37615\",\n \"initiator\": \"payor\",\n \"method\": \"card\"\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}") .asString(); ``` ```php CardSubscription request('POST', 'https://api-sandbox.payabli.com/api/Subscription/add', [ 'body' => '{ "customerData": { "customerId": 4440 }, "entryPoint": "f743aed24a", "paymentDetails": { "totalAmount": 100, "serviceFee": 0 }, "paymentMethod": { "cardcvv": "123", "cardexp": "02/25", "cardHolder": "John Cassian", "cardnumber": "4111111111111111", "cardzip": "37615", "initiator": "payor", "method": "card" }, "scheduleDetails": { "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" } }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift CardSubscription import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = [ "customerData": ["customerId": 4440], "entryPoint": "f743aed24a", "paymentDetails": [ "totalAmount": 100, "serviceFee": 0 ], "paymentMethod": [ "cardcvv": "123", "cardexp": "02/25", "cardHolder": "John Cassian", "cardnumber": "4111111111111111", "cardzip": "37615", "initiator": "payor", "method": "card" ], "scheduleDetails": [ "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python ACHSubscription from payabli import ( PaymentDetail, PayMethodAch, PayorDataRequest, ScheduleDetail, payabli, ) client = payabli( api_key="YOUR_API_KEY", ) client.subscription.new_subscription( customer_data=PayorDataRequest( customer_id=4440, ), entry_point="f743aed24a", payment_details=PaymentDetail( service_fee=0.0, total_amount=100.0, ), payment_method=PayMethodAch( ach_account="3453445666", ach_account_type="Checking", ach_code="PPD", ach_holder="John Cassian", ach_holder_type="personal", ach_routing="021000021", ), schedule_details=ScheduleDetail( end_date="03-20-2025", frequency="weekly", plan_id=1, start_date="09-20-2024", ), ) ``` ```typescript ACHSubscription import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.subscription.newSubscription({ body: { customerData: { customerId: 4440 }, entryPoint: "f743aed24a", paymentDetails: { serviceFee: 0, totalAmount: 100 }, paymentMethod: { achAccount: "3453445666", achAccountType: "Checking", achCode: "PPD", achHolder: "John Cassian", achHolderType: "personal", achRouting: "021000021", method: "ach" }, scheduleDetails: { endDate: "03-20-2025", frequency: "weekly", planId: 1, startDate: "09-20-2024" } } }); ``` ```go ACHSubscription import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Subscription.NewSubscription( context.TODO(), &sdkgo.RequestSchedule{ Body: &sdkgo.SubscriptionRequestBody{ CustomerData: &sdkgo.PayorDataRequest{ CustomerId: sdkgo.Int64( 4440, ), }, EntryPoint: sdkgo.String( "f743aed24a", ), PaymentDetails: &sdkgo.PaymentDetail{ ServiceFee: sdkgo.Float64( 0, ), TotalAmount: 100, }, PaymentMethod: &sdkgo.RequestSchedulePaymentMethod{ PayMethodCredit: &sdkgo.PayMethodCredit{ Cardcvv: sdkgo.String( "123", ), Cardexp: "02/25", CardHolder: sdkgo.String( "John Cassian", ), Cardnumber: "4111111111111111", Cardzip: sdkgo.String( "37615", ), Initiator: sdkgo.String( "payor", ), }, }, ScheduleDetails: &sdkgo.ScheduleDetail{ EndDate: sdkgo.String( "03-20-2025", ), Frequency: sdkgo.FrequencyWeekly, PlanId: sdkgo.Int( 1, ), StartDate: sdkgo.String( "09-20-2024", ), }, }, }, ) ``` ```csharp ACHSubscription using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Subscription.NewSubscriptionAsync( new RequestSchedule { Body = new SubscriptionRequestBody { CustomerData = new PayorDataRequest { CustomerId = 4440 }, EntryPoint = "f743aed24a", PaymentDetails = new PaymentDetail { ServiceFee = 0, TotalAmount = 100 }, PaymentMethod = new PayMethodAch { AchAccount = "3453445666", AchAccountType = Achaccounttype.Checking, AchCode = "PPD", AchHolder = "John Cassian", AchHolderType = AchHolderType.Personal, AchRouting = "021000021", Method = "ach", }, ScheduleDetails = new ScheduleDetail { EndDate = "03-20-2025", Frequency = Frequency.Weekly, PlanId = 1, StartDate = "09-20-2024", }, }, } ); ``` ```ruby ACHSubscription require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Subscription/add") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"customerData\": {\n \"customerId\": 4440\n },\n \"entryPoint\": \"f743aed24a\",\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"paymentMethod\": {\n \"achAccount\": \"3453445666\",\n \"achAccountType\": \"Checking\",\n \"achCode\": \"PPD\",\n \"achHolder\": \"John Cassian\",\n \"achHolderType\": \"personal\",\n \"achRouting\": \"021000021\",\n \"method\": \"ach\"\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java ACHSubscription HttpResponse response = Unirest.post("https://api-sandbox.payabli.com/api/Subscription/add") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"customerData\": {\n \"customerId\": 4440\n },\n \"entryPoint\": \"f743aed24a\",\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"paymentMethod\": {\n \"achAccount\": \"3453445666\",\n \"achAccountType\": \"Checking\",\n \"achCode\": \"PPD\",\n \"achHolder\": \"John Cassian\",\n \"achHolderType\": \"personal\",\n \"achRouting\": \"021000021\",\n \"method\": \"ach\"\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}") .asString(); ``` ```php ACHSubscription request('POST', 'https://api-sandbox.payabli.com/api/Subscription/add', [ 'body' => '{ "customerData": { "customerId": 4440 }, "entryPoint": "f743aed24a", "paymentDetails": { "totalAmount": 100, "serviceFee": 0 }, "paymentMethod": { "achAccount": "3453445666", "achAccountType": "Checking", "achCode": "PPD", "achHolder": "John Cassian", "achHolderType": "personal", "achRouting": "021000021", "method": "ach" }, "scheduleDetails": { "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" } }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift ACHSubscription import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = [ "customerData": ["customerId": 4440], "entryPoint": "f743aed24a", "paymentDetails": [ "totalAmount": 100, "serviceFee": 0 ], "paymentMethod": [ "achAccount": "3453445666", "achAccountType": "Checking", "achCode": "PPD", "achHolder": "John Cassian", "achHolderType": "personal", "achRouting": "021000021", "method": "ach" ], "scheduleDetails": [ "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python StoredMethodSubscription from payabli import PaymentDetail, PayorDataRequest, ScheduleDetail, payabli from payabli.subscription import RequestSchedulePaymentMethodInitiator client = payabli( api_key="YOUR_API_KEY", ) client.subscription.new_subscription( customer_data=PayorDataRequest( customer_id=4440, ), entry_point="f743aed24a", payment_details=PaymentDetail( service_fee=0.0, total_amount=100.0, ), payment_method=RequestSchedulePaymentMethodInitiator( initiator="merchant", stored_method_id="4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323", stored_method_usage_type="recurring", ), schedule_details=ScheduleDetail( end_date="03-20-2025", frequency="weekly", plan_id=1, start_date="09-20-2024", ), ) ``` ```typescript StoredMethodSubscription import { PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.subscription.newSubscription({ body: { customerData: { customerId: 4440 }, entryPoint: "f743aed24a", paymentDetails: { serviceFee: 0, totalAmount: 100 }, paymentMethod: { initiator: "merchant", storedMethodId: "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323", storedMethodUsageType: "recurring" }, scheduleDetails: { endDate: "03-20-2025", frequency: "weekly", planId: 1, startDate: "09-20-2024" } } }); ``` ```go StoredMethodSubscription import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Subscription.NewSubscription( context.TODO(), &sdkgo.RequestSchedule{ Body: &sdkgo.SubscriptionRequestBody{ CustomerData: &sdkgo.PayorDataRequest{ CustomerId: sdkgo.Int64( 4440, ), }, EntryPoint: sdkgo.String( "f743aed24a", ), PaymentDetails: &sdkgo.PaymentDetail{ ServiceFee: sdkgo.Float64( 0, ), TotalAmount: 100, }, PaymentMethod: &sdkgo.RequestSchedulePaymentMethod{ PayMethodCredit: &sdkgo.PayMethodCredit{ Cardcvv: sdkgo.String( "123", ), Cardexp: "02/25", CardHolder: sdkgo.String( "John Cassian", ), Cardnumber: "4111111111111111", Cardzip: sdkgo.String( "37615", ), Initiator: sdkgo.String( "payor", ), }, }, ScheduleDetails: &sdkgo.ScheduleDetail{ EndDate: sdkgo.String( "03-20-2025", ), Frequency: sdkgo.FrequencyWeekly, PlanId: sdkgo.Int( 1, ), StartDate: sdkgo.String( "09-20-2024", ), }, }, }, ) ``` ```csharp StoredMethodSubscription using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Subscription.NewSubscriptionAsync( new RequestSchedule { Body = new SubscriptionRequestBody { CustomerData = new PayorDataRequest { CustomerId = 4440 }, EntryPoint = "f743aed24a", PaymentDetails = new PaymentDetail { ServiceFee = 0, TotalAmount = 100 }, PaymentMethod = new RequestSchedulePaymentMethodInitiator { Initiator = "merchant", StoredMethodId = "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323", StoredMethodUsageType = "recurring", }, ScheduleDetails = new ScheduleDetail { EndDate = "03-20-2025", Frequency = Frequency.Weekly, PlanId = 1, StartDate = "09-20-2024", }, }, } ); ``` ```ruby StoredMethodSubscription require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Subscription/add") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"customerData\": {\n \"customerId\": 4440\n },\n \"entryPoint\": \"f743aed24a\",\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"paymentMethod\": {\n \"initiator\": \"merchant\",\n \"storedMethodId\": \"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323\",\n \"storedMethodUsageType\": \"recurring\"\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java StoredMethodSubscription HttpResponse response = Unirest.post("https://api-sandbox.payabli.com/api/Subscription/add") .header("requestToken", "") .header("Content-Type", "application/json") .body("{\n \"customerData\": {\n \"customerId\": 4440\n },\n \"entryPoint\": \"f743aed24a\",\n \"paymentDetails\": {\n \"totalAmount\": 100,\n \"serviceFee\": 0\n },\n \"paymentMethod\": {\n \"initiator\": \"merchant\",\n \"storedMethodId\": \"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323\",\n \"storedMethodUsageType\": \"recurring\"\n },\n \"scheduleDetails\": {\n \"endDate\": \"03-20-2025\",\n \"frequency\": \"weekly\",\n \"planId\": 1,\n \"startDate\": \"09-20-2024\"\n }\n}") .asString(); ``` ```php StoredMethodSubscription request('POST', 'https://api-sandbox.payabli.com/api/Subscription/add', [ 'body' => '{ "customerData": { "customerId": 4440 }, "entryPoint": "f743aed24a", "paymentDetails": { "totalAmount": 100, "serviceFee": 0 }, "paymentMethod": { "initiator": "merchant", "storedMethodId": "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323", "storedMethodUsageType": "recurring" }, "scheduleDetails": { "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" } }', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift StoredMethodSubscription import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = [ "customerData": ["customerId": 4440], "entryPoint": "f743aed24a", "paymentDetails": [ "totalAmount": 100, "serviceFee": 0 ], "paymentMethod": [ "initiator": "merchant", "storedMethodId": "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323", "storedMethodUsageType": "recurring" ], "scheduleDetails": [ "endDate": "03-20-2025", "frequency": "weekly", "planId": 1, "startDate": "09-20-2024" ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```