I have added this code but this is not working. I want the promocodes to be saved in infusionsoft
$carray = array(
php_xmlrpc_encode($app->key),
php_xmlrpc_encode($contactId),
php_xmlrpc_encode($creditCardId),
php_xmlrpc_encode($payPlanId),
php_xmlrpc_encode(array($productId1, $productId2)),
php_xmlrpc_encode(array($subscriptionPlanId1, $subscriptionPlanId2)),
php_xmlrpc_encode($processSpecials),
php_xmlrpc_encode(array($promoCode1, $promoCode2)) // array of strings
);
$app->methodCaller("OrderService.placeOrder", $carray);
Promo Codes are read-only. This means that, while they can be used during orders and applied to invoices, you can't add new Promo Codes via the API.
This is an unfortunate limitation of the InfusionSoft API. Read more in the Table Documentation.
Related
Recurly Create Subscription. It doesn’t seem like they allow multiple coupons to be allowed added to the account during creation, but am I wrong? Or is there another way to add a coupon to the account subscription?
I already have multiple coupons setting in Recurly turned on, I'm just not sure how to apply them. I'm also using the PHP library if that makes any difference.
I found out you can actually create subscription with multiple coupons at once. All you need to do is organize coupon codes into comma separated list.
You must use the redeem subscription endpoint (rather than the create subscription endpoint) if you wish to apply multiple coupons
<?php
$coupon = Recurly_Coupon::get('special');
$redemption = $coupon->redeemCoupon('1', 'USD');
?>
More information here
You should work with Redeem a Coupon on an Account
Definition
https://:subdomain.recurly.com/v2/coupons/:coupon_code/redeem
PHP Examples
<?php
$coupon = Recurly_Coupon::get('special');
$redemption = $coupon->redeemCoupon('1', 'USD');
?>
Result Format
<redemption href="https://your-subdomain.recurly.com/v2/accounts/1/redemptions/316a4213e8fa9e97390aff4995bda9e6">
<coupon href="https://your-subdomain.recurly.com/v2/coupons/special"/>
<account href="https://your-subdomain.recurly.com/v2/accounts/1"/>
<subscription href="https://your-subdomain.recurly.com/v2/subscriptions/315fbd7a25b04f1333ea9f4418994fb5"/>
<uuid>316a4213e8fa9e97390aff4995bda9e6</uuid>
<single_use type="boolean">false</single_use>
<total_discounted_in_cents type="integer">0</total_discounted_in_cents>
<currency>USD</currency>
<state>active</state>
<created_at type="datetime">2015-09-23T17:13:30Z</created_at>
</redemption>
Objective: Autopopulate some values using the tabLabel/value key pair for server templates, using the beta Docusign PHP Client.
I've looked at quite a few stackoverflow posts and unfortunately the one that seems to be the closest related to me seems unanswered: Docusign API - prefilling tab values on envelope created from template
I was unable to find this "SecureField" option in any sort of preferences.
Currently, the name field fills in automatically just because of the template role being set accurately. I didn't have to do this with the tabLabel key, this was done automatically. I have tried creating a company tab, and that fails to autopopulate, so does a random text tab I have tried.
I have currently forked the library and made it PSR-4 compatible, and to achieve this objective I changed the following files:
TemplateRole Model: Modified the constructor to include $tabs, and set $this->tabs if $tabs is set. I added two functions getTabs()/setTabs($tabs) that behave the same as get/set RoleName, Name, Email, etc.
RequestSignatureResource: In the foreach ($templateRoles as $templateRole) I added a 'tabs' key to the array_pusy, and put $templateRole->getTabs().
I created a new TemplateRole('role name', 'person name', 'email', $tabs).
I can see the tabs in the JSON request data. Is there anything I'm missing?
I should also note that I used this post for inspiration, too: How to pre-fill tabs on a server template with the DocuSign API. The issue with this is that if I put textTabs:{text:{tabLabel:"something", value:"some value"}} then I get a response from the API that my request was invalid. I can provide that specific error upon request if needed.
The following worked for me :
$templateRole = new DocuSign\eSign\Model\TemplateRole();
$templateRole->setClientUserId($email);
$templateRole->setEmail($email);
$templateRole->setName($recipientName);
$templateRole->setRoleName($templateRoleName);
$textTab = new \DocuSign\eSign\Model\Text();
// I added this text field manually on docuSign site.
$textTab->setTabLabel("Field Label");
$textTab->setValue('Value');
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setTextTabs(array($textTab));
$templateRole->setTabs($tabs);
I am currently building an ecommerce website that is used for 5 separate companies using woocommerce and authorize.net for the payment.
So far the authorization is working great for a single vendor, the issue comes in that once I have selected the vendor by location, I need to change the api_transaction_key and api_login_id to the correct vendor before payment is processed.
I have been searching the files for hours now and cannot find where the key and id are set.
Can someone help me find where I can overwrite the key and id values to what I need?
or would it be better to create a new payment gateway for each of the vendors and copy all of the authorize.net gateway information except the key and id?
This answer is here for if anyone is curious on how I was able to make this work.in the Authorize.net woocommerce payment gateway you'll find a file called
class-wc-authorize-net-cim-api.php
and it is in this file's contruct function that your hook needs to be placed.
public function __construct( $api_user_id, $api_transaction_key, $environment ) {
// File default code
}
This needs the follow three lines of code to be placed BEFORE the default file code
$custom_auth_info = apply_filters('get_custom_auth', $custom_auth_info );
$api_user_id = $custom_auth_info['api_user_id'];
$api_transaction_key = $custom_auth_info['api_transaction_key'];
The apply_filters refers to the following function that is placed in my plugin
add_filter('get_custom_auth', 'select_distributor_by_state');
function select_distributor_by_state($custom_auth_info = []) {
global $wpdb;
//Your Query is here to select the proper distributor from the DB
//and retrieve their custom Authorize.net ID and Transaction Key
$custom_auth_info['api_user_id'] = $your_query[0]['api_loginid'];
$custom_auth_info['api_transaction_key'] = $your_query[0]['api_transactionkey'];
$_SESSION['dealer'] = $vendor[0]['id'];
return $custom_auth_info;
}
This filter allows you to hook in, grab the data you need, then return it and apply it directly into the code before the payment is processed.
I'm using Stripe's php library to create a customer with a subscription that contains a coupon. I don't want to add the coupon at the customer level, I want to add it at the subscription level. The below code is what I'm currently using and according to their support, this should work, but it doesn't. I was hoping someone will be able to help.
$params = array(
'card'=>'SOME_TOKEN_FROM_JS_LIBRARY',
'plan'=>'valid_plan_id',
'coupon'=>'valid_coupon_id'
);
$c = Stripe_Customer::create($params);
if(!empty($params['coupon'])){
$c->updateSubscription(array(
'plan'=>$params['plan'],
'coupon'=>$params['coupon']
));
}
This successfully creates the customer and charges the card with the coupon applied.
Ended up going with the code below, it does what I want it to do. Also, the goal with the code below is to delete the customer if the charge fails for whatever reason, so I'm not left with customers that don't belong anywhere.
$_c = Stripe_Customer::create($params);
try{
$_c->subscriptions->create(array('plan'=>$plan, 'coupon'=>$coupon));
}catch(Exception $e){
$_c->delete();
throw new Exception($e->getMessage());
}
$c = Stripe_Customer::retrieve($_c->id); //to get the customer object with the latest data
I am trying to write a module that syncs my newsletter subscribers in Magento with a external database. I need to be able to update the subscription status in Magento programmatically but I am having diffuculty getting the "setStatus" method in Magento to work. It does not throw any errors but the code does not seem to have any effect. Below is the code where I call the method:
$collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo();
foreach ($collection as $cust) {
$cust->setStatus(1);
}
In theory, this should set the status of all of my subscribers to "subscribed". I could optionally change the argument sent to "setStatus" to any of the below ints for a different status.
1: Subscribed
2: Status Not Active
3: Unsubscribed
How to best change the subscriber status or get this code working?
Here an import script:
<?php
require_once("./app/Mage.php");
Mage::app();
$subscribers = array('email1#server1.com', 'email2#server2.com');
foreach ($subscribers as $email) {
# create new subscriber without send an confirmation email
Mage::getModel('newsletter/subscriber')->setImportMode(true)->subscribe($email);
# get just generated subscriber
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
# change status to "subscribed" and save
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
$subscriber->save();
}
?>
It seems that newsletter subscribers are also stored elsewhere. What you are setting is just a check in the customer base for some other use.
You need to do the following for each customer as well.
Mage::getModel('newsletter/subscriber')->subscribe($email);
See this link for a complete reference.
Thanks to the link #Ozair shared I was able to figure out what I needed to do.
I was successfully setting the status of the subscriber in the Magento subscriber object but I was not saving the object. I needed to call Magento's save method so it would call the ORM and write it to the database. All I need to do was add
$cust->save();
in the for loop. Below is the whole code snippet.
$collection = Mage::getResourceModel('newsletter/subscriber_collection')->showStoreInfo()->showCustomerInfo();
foreach ($collection as $cust) {
$cust->setStatus(1);
$cust->save();
}
I Hope this helps someone in the future. I needed it for a Constant Contact - Magento Synchronization extension I was making: http://www.freelunchlabs.com/store/constant-contact-and-magento-sync.html