amzn/amazon-pay-sdk-php

What is the best way to manage recurring payments

Closed this issue · 3 comments

I was wondering what would be the best way to schedule future AuthorizeOnBillingAgreement calls for exiting billing agreements.

The simplest way that comes to mind is a cron job that queries the database daily for buyer records that need to be charged that day, list them and call AuthorizeOnBillingAgreement with an interval.

I could not find anything on the docs, the forum, stackoverflow, or the web, so I decided to make an issue here that might be of benefits to others as well.

Apologies if this issue is out of scope for this repo.

Hey @ahmadabdolsaheb - definitely great to have here, thanks for posting! It might be beneficial to also post this over on stackoverflow.com, and tag use the amazon-pay tag so that other developers can find the details.

Another option, if you're interested in a serverless option, you could use AWS services to trigger this on a cron-like basis - more details available in the AWS Lambda documentation. There's also a great re:Invent talk on using Lambda as Cron from 2015 about this.

Additional options could also include using one of our recurring billing solution providers (FoxyCart, Chargebee, Recurly, Zuora, etc).

Thanks, @islandskater43 this is gold :)

I have posted on stack overflow, asked on Amazon Seller Forums, contacted support, etc., so this was my last reserve.

I looked at your other posts too, @ahmadabdolsaheb, and wanted to make sure you were also aware of the AuthorizeOnBillingAgreement API call with the CaptureNow parameter set to true. This will automatically perform a capture call on your authorization once the auth is successful. I'd also recommend, since this is a rebilling workflow, that you specify a TransactionTimeout value of 1440 (or don't pass it at all as 1440 is the default). This will allow for as much time as possible for the auth to go through (1440 = 24 hours), and will result in the highest probability of auth success.

Closing this issue, feel free to reopen if you have further questions.