Jump to content

Commerce REST API - POST SupportRequest - No email?


IPCommerceFan

Recommended Posts

I just started experimenting with REST along with Commerce Rules:

To fire custom PHP when a purchase is generated.

I got it to do exactly what I want, which is to create a new support request when there is a purchase, containing further instructions for our customers.

The only issue, though, is it seems SR's created this way do not generate an email the way they do when you go to AdminCP Commerce -> Customer -> New Support Request. 

So I'm reporting this to see if this is the intended functionality (no email notification for REST API created support requests), or if its perhaps a bug/oversight?

Heres some context:

//<?php

//Purchase Data
$p_id = $purchase->id;
$member = $purchase->member->member_id;
$email = $purchase->member->email;

//REST API URL and KEY

$communityUrl = '<...>';
$apiKey = '<...>';

//Create Support Requst

$endpoint_request = '/nexus/supportrequests';
	
$curl_request = curl_init( $communityUrl . 'api' . $endpoint_request );

$message = '<...>';

$curl_post_data_request = array(
        'title' => 'Support request via REST',
        'department' => 1,
        'staff' => 1,
        'account' => $member,
        'email' => $email,
        'message' => $message,
  		'purchase' => $p_id
  );

curl_setopt_array( $curl_request, array(
	CURLOPT_RETURNTRANSFER	=> TRUE,
	CURLOPT_HTTPAUTH	=> CURLAUTH_BASIC,
	CURLOPT_USERPWD		=> "{$apiKey}:",
  	CURLOPT_POST		=> TRUE,
  	CURLOPT_POSTFIELDS  => $curl_post_data_request
  	
) );
$response_request = curl_exec( $curl_request );

// Grab Support Reply ID for firstMessage of Request

$request = json_decode($response_request);

$request_id = $request->firstMessage->id;

// Change Support Request Author to Staff 

$endpoint_reply = '/nexus/supportreplies/' . $request_id;

$curl_reply = curl_init( $communityUrl . 'api' . $endpoint_reply );

$curl_post_data_reply = array(
        'author' => 1
  );

curl_setopt_array( $curl_reply, array(
	CURLOPT_RETURNTRANSFER	=> TRUE,
	CURLOPT_HTTPAUTH	=> CURLAUTH_BASIC,
	CURLOPT_USERPWD		=> "{$apiKey}:",
  	CURLOPT_POST		=> TRUE,
  	CURLOPT_POSTFIELDS  => $curl_post_data_reply
  	
) );
$response_reply = curl_exec( $curl_reply );

return "action complete";

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...