ChargeBee - PHP create subscription breaks PHP loading the page - php

Working on a Chargebee integration, using their suggest PHP library.
I have the include statement at the top of the page, to include the library.
And I set the environment variables with test server information copy-pasted from the control panel.
No matter what I try, when I use their sample code, my page load breaks and I get a white screen. Without this block of code, the page loads fine and all dbase calls works perfectly.
Is there more to know about the Chargebee library that I'm not catching?
(in the top of the php)
include("/app/includes/chargebee-php-master/lib/ChargeBee.php");
ChargeBee_Environment::configure("SERVERNAME-test",
"test_KEYFROMCONTROLPANEL");
(inline code in a function)
$result = ChargeBee_Subscription::create(array(
"planId" => "pond_ripple",
"customer" => array(
"email" => "john#user.com",
"firstName" => "John",
"lastName" => "Doe",
"phone" => "+1-949-999-9999"
),
"billing_address" => array(
"firstName" => "John",
"lastName" => "Doe",
"line1" => "PO Box 9999",
"city" => "Walnut",
"state" => "CA",
"zip" => "91789",
"country" => "US"
)
));
$subscription = $result->subscription();
$customer = $result->customer();
$card = $result->card();
$invoice = $result->invoice();
$sampleString = $customer["id"];

Is your include path correct?
include("/app/includes/chargebee-php-master/lib/ChargeBee.php");
Can you crosscheck whether it starts from a base directory? ie. /app/includes/chargebee-php-master/lib/ChargeBee.php or is it relative? i.e app/includes/chargebee-php-master/lib/ChargeBee.php
If your path is right (full path), can you provide the error log to debug further? Also you need to access ChargeBee customer object as $customer->id and not as an array.

Related

Zammad API: Create ticket with tag

For those who don't want to read the whole question:
I'm looking for the index in the API-Request (Zammad) to set a tag while creating a ticket.
Details:
I'm using PHP to make an API-Request to my server where Zammad is installed. The following shows the data i sent via curl:
json_encode([
"title" => $title,
"group_id" => 2,
"priority_id" => 2,
"category" => 'Some Category',
"state_id" => 1,
"type" => "Some Type",
"customer" => $userID,
"article" => [
"body" => $htmlBody,
"type" => "note",
"content_type" => "text/html",
],
"tag_list" => [ // <-- The question is about this segment
"The tag i want to add",
],
]);
After converting the data to JSON, im sending it via POST to http://<myServerIP>/api/v1/tickets
What I've tried so far:
I tried guessing the index of the tag at which i failed.
The first full example is shown above.
Secondly:
...
"tag_id" => 9, // I've check its the actual ID of the tag i want to add
And Finally:
...
"tag" => "The tag i want to add",
Needless to say that i didn't succeed. Sometimes i get an error id (im assuming its because the index doesn't exist [who would have thought that? :)]), sometimes i get nothing and Zammad just creates the ticket without the tag. What do i mean when i say sometimes? I refer my tries specified above.
What I've also tried:
Searching for some answer on the web. The thing that comes close to what i want is this. But i would rather create the ticket with the tag instead of making another request just to add the tag.
I've looked inside the code, its written in ruby. The index is 'tags' and needs to be sperated by ,.
Basicly:
json_encode([
"title" => $title,
"group_id" => 2,
"priority_id" => 2,
"category" => 'Some Category',
"state_id" => 1,
"type" => "Some Type",
"customer" => $userID,
"article" => [
"body" => $htmlBody,
"type" => "note",
"content_type" => "text/html",
],
"tags" => "tag1,tag2,tag3", // or simply "tags" => "tag1"
]);
It might help someone in the future ...

Trying to Stream music while connecting Nexmo NCCO

I tried to stream music while connecting the agent into the phone call.
but it's stuck in the stream and then calling.
anyone used it before? I'm sure that's impossible to make this.
Code:
$array[] = array(
"action" => "stream",
"streamUrl" => array("https://pbx.makeapp.co.il/wait.mp3"),
);
$array[] = array(
"action" => "connect",
"eventType" => "synchronous",
"eventUrl" => array("https://pbx.makeapp.co.il/config.json?step=1"),
"timeout" => 30,
"from" => "YOUR_NEXMO_PHONE",
"endpoint" => array(array(
"type" => "sip",
"uri" => "sip:your_sip#sip.antisip.com",
)
)
);
You are correct, it is not possible to have 2 actions running at the same time using an NCCO. When you add a stream action to the start of your NCCO, this must be completed before it moves onto the next action. An NCCO array is actioned from top to bottom, and only moves onto the next action when the current one has finished. You can find out some more info in the concepts of an NCCO section of the documentation: https://developer.nexmo.com/voice/voice-api/ncco-reference

Ionic Firebase push notification icon is not visible on all devices

I have an Ionic app (v 2.0.2) consisting Firebase Push notification. I am having some issues. Stating them here.
I am getting the Notification Icon to appear on Xiaomi device but can not get it to show on Samsung. I have used following php code
$message_for_push = array(
"data" => array(
"title" => "New Content Published!",
"body" => $message['title'],
"icon" => "file://assets/img/firebase_push_icon.png", //also tried "icon" => "myicon",
"color" => "#e81010",
'sound' => 'mySound',
"type" => $message['type'],
"section_id" => $message['section_id'],
"isPush" => 1,
"subdomain" => $subdomain, //dynamiic
"id" => $message['id'],
"other_key" => true
),
"registration_ids" => $registrationIds
);
it takes the default icon (not transparent) on Xiaomi but not on Samsung.
I have generated the icons from http://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit and put all in mipmap-* folders having name firebase_push_icon.png.
I have also tried with the transparent Icon, does not work either. (I found that I have to provide transparent icon)
Only shows a round circle.
My questions are
where should I put the transparent Icon?
what should be the file name of the Icon?
what should I put on "icon" in php end?
When I use both data and notification, I get two notification, why is this?
Thanks in advance.

How to set Affects Version field via JIRA REST API - PHP

I would like to update the affects versions field via JIRA REST API. But I'm getting an error:
{"errorMessages":[],"errors":{"versions":"Affects Version/s is required."}}
I have the following code:
public function requestBug($summary, $components, $affectsVersions, $fixVersions, $assignee, $environment, $description)
{
$json = Array ( "fields" => Array (
"project" => Array( "id" => 10051),
"summary" => $summary,
"issuetype" => Array ( "name" => "Bug" ),
"components" =>Array(0 => Array("id" => $components)),
"versions" =>Array(0 =>Array("affectsVersion" => $affectsVersions)),
"versions" =>Array(0 =>Array("fixVersion" =>$fixVersions)),
"assignee" => Array("name" => "$assignee"),
"environment" => "$environment",
"description" =>$description
)
);
return $json;
}
Please assist. I came across this link, but doesnt work for me
I had the same problem and the given answer (even with links provided) did not help me much. I played around with all sorts of variations and finally this piece of JSON worked to change the affected version of an item to "Version 2.0.0":
"versions":
[
{ "Affects Version/s" : "Version 2.0.0"
},
{ "name": "Version 2.0.0"
}
]
Meta data looks like this:
"versions":{"required":true,"schema":
{"type":"array","items":"version","system":"versions"},"name":"Affects Version/s",....
Especially irritating and inconsistent is the fact that the very same field is exported by JIRA as <version>Version 2.0.0</version> in XML and for queries affectedVersion is to be used.
There are a few example of "edit issue" requests here.
You want to send a json that includes something like this:
{
"fields":
{
"versions":["1.0.0","1.1.0"],
"fixVersions":["2.0.0"]
}
}
In your code you use the key "versions" both for "Fix version(s)" and "Affected version(s)", which won't work. Also, you don't have to use additional "affectsVersion" or "fixVersion" keys.
You can also get more info about which fields you can edit and which values they allow using this REST call:
GET /rest/api/2/issue/{issueIdOrKey}/editmeta
Try it out for an issue you want to edit and it should put you on the right track. The output will also show that the "versions" key corresponds to the "Affected version(s)" field.
from jira import JIRA
auth_jira = JIRA('jira.your-oraganizsation.com', auth=('username', 'password'))
new_issue = auth_jira.create_issue(project='project_name', summary='jira_summary', description='jira_description', issuetype={'name': 'Defect'}, fields={'versions': [{'name': '1.0.0'}, {'name': '18.8.0'}] })

DocuSign REST API (PHP) - pre-fill custom tags

I am working on project in which I need to use DocuSign API (PHP). This is my first experience with DocuSign and I successfully made template in DocuSign Console with roleName = signer. There I also made Custom Text Tags: address, city, state and phone and drag them to the desired location in my template. I want there to put my customer (signer) information from project database.
From my project I successfully made connection with DocuSign via PHP API and receive Embedded Singing View URL which opens my template where the user can sign document without problem.
But... all my custom text tags are empty and signer can type into them. I need to pre-fill them with signer personal data which is coming from database. I triple check custom tag label spelling, upper/lower case in my DocuSign Console and in my code as well as roleName->tagLabel relation. My PHP code is below.
Can someone, please, tell me what I am doing wrong?
I lost two days on it.
$data = array(
"accountId" => $accountId,
"emailSubject" => $this->_emailSubject,
"templateId" => $templateId,
"templateRoles" => array(
array(
"email" => $email,
"name" => $recipientName,
"clientUserId" => $clientUserId,
"roleName" => "signer",
"customFields" => array(
"textCustomFields" => array (
array (
"name" => "address",
"value" => "Address from DB",
"show" => "true",
),
array (
"name" => "city",
"value" => "City from DB",
"show" => "true",
),
array (
"name" => "state",
"value" => "State from DB",
"show" => "true",
),
array (
"name" => "phone",
"value" => "Phone from DB",
"show" => "true",
),
),
),
),
),
"status" => "sent"
);
You need to use the textTabs type in your JSON, not customFields which is used for something else. For instance, if you drag a Data Field from the UI onto the document and give it name address, to pre-fill that field you would need to reference it's tabLabel and value fields like this:
"roleName" => "signer",
"tabs" => array(
"textTabs" => array(
array(
"tabLabel"=> "address",
"value" => "123 Main St."
)
)
)

Categories