recurly / recurly-client-php

Recurly PHP Client
http://recurly.com
MIT License
172 stars 93 forks source link

Add header to API Call #824

Open bobalbert opened 2 weeks ago

bobalbert commented 2 weeks ago

Warning: Github issues are not an official support channel for Recurly. If you have an urgent request we suggest you contact us through an official channel: support@recurly.com or https://recurly.zendesk.com

I've contacted Recurly support but having issues getting someone with any knowledge of or experience with the PHP client.

We just did an account billing migration from one Recurly account another Recurly account and now i'm trying to create no card/billing trials to setup the subscriptions from the old Recurly account. option 2 free trial method: https://docs.recurly.com/docs/customer-imports#3-create-subscriptions

The Migration team has told me I need to make sure not to do any card validation when creating these subs by adding a special header to the API call to tell Recurly to skip authorization on the card which they have provided. this is to make sure migrated CIT/NTID data is not overwritten.

I don't see anyway to pass/add headers to the _sendRequest() method in client.php via my $subscription->create() call and support is unable to help me and doesn't seem to know how to do it either.

It seems like I have to manually add this to the method's curl header setup as another value? This is kind of a one off, so I assume this is really the only way to do it? client.php ~ line 164 through 184 curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=utf-8', 'Accept: application/xml', Recurly_Client::__userAgent(), 'Accept-Language: ' . $this->_acceptLanguage, 'X-Api-Version: ' . Recurly_Client::$apiVersion, 'Recurly-Skip-Authorization: true'

Or is their another preferred way?

I have done the manual option and it seems to work but i get in consistent behavior where some subscriptions are created but others are failing a validation of the card: [recurly_validationerror] => Array ( [0] => Your card number is not valid. Please update your card number. )

i'm doing a very basic call.. create a sub - $subscription = new Recurly_Subscription(); set the plan_code, currency the trial_at_end - $subscription->trial_ends_at = $next_payment_date; setup an account - $account = new Recurly_Account(); set the recurly_account_id, email, name address then set the account to the sub - $subscription->account = $account; then create the sub - $subscription->create();

Thoughts? Advice? Thanks, Bob

douglasmiller commented 1 week ago

@bobalbert, you can include headers, with an associative array of header name => value pairs, in the options of any client operation.

I'll see about having this behavior documented better in the readme.