Recurring payment declined

Highlighted
Tourist
3 0 2

Sir, I have integrated recurring payment but, when i declined payment. It takes me to the index page of the app but Not showing declined message. When next time, i go for payment without clicking on cancel. It is showing me *payment declined* message. Why declined message is showing in the second attempt of payment while  I have not clicked on the cancel button.

declined.png

0 Likes
Shopify Staff
Shopify Staff
202 23 22

 

Hi @akashbro 

 

Are you using REST or GraphQL for the billing? Is the redirect URL set correctly? Can you share your code where you have implemented this? The more information you can provide the better we can assist. 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes
Tourist
3 0 2

I am using REST.

1ST Function:

function createCharge($charge_data)
{
$url = 'https://'.$_SESSION['api_key'].':'.$_SESSION['access_token'].'@'.$_SESSION['shop'].'/admin/recurring_application_charges.json';
$data = array('recurring_application_charge'=>array('name'=>$charge_data['plan'], 'price'=>$charge_data['price'], 'return_url'=>$charge_data['url']));
if($this->test_mode)
{
$data['recurring_application_charge']['test'] = true;
}
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
 
if ($result === FALSE) {
return;
}

$result = json_decode($result);

if($result->recurring_application_charge->confirmation_url)
redirect($result->recurring_application_charge->confirmation_url, true);
}
 
2ND Function : 
 
function activateCharge($charge_details)
{
$url = 'https://'.$_SESSION['api_key'].':'.$_SESSION['access_token'].'@'.$_SESSION['shop'].'/admin/recurring_application_charges/'.$charge_details->recurring_application_charge->id.'/activate.json';
//echo "<pre>";print_r($url);exit;
$data = $charge_details;
 
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
return;
}

$result = json_decode($result);
return $result;
}
1 Like
Tourist
3 0 2
@sir, please reply me as early as possible. Because, we are about to submit
our app.

I am using REST.

*1ST Function:*
function createCharge($charge_data)
{
$url = 'https://'.$_SESSION['api_key'].':'.$_SESSION['access_token'].'@'.
$_SESSION['shop'].'/admin/recurring_application_charges.json';
$data = array('recurring_application_charge'=>array('name'=>$charge_data[
'plan'], 'price'=>$charge_data['price'], 'return_url'=>$charge_data['url'
]));
if($this->test_mode)
{
$data['recurring_application_charge']['test'] = true;
}
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result === FALSE) {
return;
}

$result = json_decode($result);

if($result->recurring_application_charge->confirmation_url)
redirect($result->recurring_application_charge->confirmation_url, true);
}

*2ND Function : *

function activateCharge($charge_details)
{
$url = 'https://'.$_SESSION['api_key'].':'.$_SESSION['access_token'].'@'.
$_SESSION['shop'].'/admin/recurring_application_charges/'.$charge_details->
recurring_application_charge->id.'/activate.json';
//echo "
";print_r($url);exit;
$data = $charge_details;

// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
return;
}

$result = json_decode($result);
return $result;
}
1 Like
New Member
1 0 0

Please let us know the solution for this question at the earliest, as we have got the feedback from Shopify App validation team to fix this behavior.  

We are waiting for your inputs on the same.

 

Thanks,

Sampath

0 Likes