I read some question and I didn't solve my problem I was use array_column() but I am confused of this silly problem
I have an array $product
$product = array(
0 => array(
'id' => '123',
'name' => 'Facebook status robot',
'description'=> 'Post your wall in your given time',
'quantity' => '1',
'unitPrice' => '120',
'taxable' => 'true'
),
1 => array(
'id' => '123',
'name' => 'Facebook status robot',
'description'=> 'Post your wall in your given time',
'quantity' => '1',
'unitPrice' => '120',
'taxable' => 'true'
),
2 => array(
'id' => '123',
'name' => 'Facebook status robot',
'description'=> 'Post your wall in your given time',
'quantity' => '1',
'unitPrice' => '120',
'taxable' => 'true'
)
);
Now I want remove two elements unitPrice and description
$customProduct = array(
0 => array(
'id' => '123',
'name' => 'Facebook status robot',
'quantity' => '1',
'taxable' => 'true'
),
1 => array(
'id' => '123',
'name' => 'Facebook status robot',
'quantity' => '1',
'taxable' => 'true'
),
2 => array(
'id' => '123',
'name' => 'Facebook status robot',
'quantity' => '1',
'taxable' => 'true'
)
);
The PHP command you need is unset(array[key]), you can access individual indexes in your array by iterating over it.
The basic solution would look like the following. Please be aware that this would modify your original array. If that is not what you want assign the product array to another variable first (2nd example below):
foreach($product as &$data) {
unset($data['unitPrice']);
unset($data['description']);
}
var_dump($product);
would become:
$customProduct = $product;
foreach($customProduct as &$data) {
unset($data['unitPrice']);
unset($data['description']);
}
var_dump($customProduct);
// $product will have its original value.
foreach($product as $key => $prod) {
unset($product[$key]['unitPrice']);
unset($product[$key]['description']);
}
The functional approach, as counterbalance to all the other options:
$customProduct = array_map(function (array $product) {
return array_diff_key($product, array_flip(['unitPrice', 'description']));
}, $product);
$customProduct=array();
foreach($product as $p){
if(isset($p['description'])){
unset($p['description']);
}
if(isset($p['unitPrice'])){
unset($p['unitPrice']);
}
array_push($customProduct,$p);
}
Try my updated answer
foreach($product as &$products) {
unset($products['unitPrice']);
unset($products['description']);
}
print_r($product);
output
Array
(
[0] => Array
(
[id] => 123
[name] => Facebook status robot
[quantity] => 1
[taxable] => true
)
[1] => Array
(
[id] => 123
[name] => Facebook status robot
[quantity] => 1
[taxable] => true
)
[2] => Array
(
[id] => 123
[name] => Facebook status robot
[quantity] => 1
[taxable] => true
)
)
Just run a loop .use the code below
<?php
$product = array(
0 => array(
'id' => '123',
'name' => 'Facebook status robot',
'description'=> 'Post your wall in your given time',
'quantity' => '1',
'unitPrice' => '120',
'taxable' => 'true'
),
1 => array(
'id' => '123',
'name' => 'Facebook status robot',
'description'=> 'Post your wall in your given time',
'quantity' => '1',
'unitPrice' => '120',
'taxable' => 'true'
),
2 => array(
'id' => '123',
'name' => 'Facebook status robot',
'description'=> 'Post your wall in your given time',
'quantity' => '1',
'unitPrice' => '120',
'taxable' => 'true'
)
);
$p= count($product);
for($i=0;$i<=$p;$i++){
unset($product[$i]["description"]);
unset($product[$i]["unitPrice"]);
}
print_r($product);
Hope this helps you
Related
I'm trying to loop through and return data ('rank' from 'rank_details') from a returned JSON response.
Here is a snippet of the JSON response (what I'm getting from: $array = json_decode($apiResponse); )
(object) array(
'obj' =>
array (
0 =>
(object) array(
'name' => 'I\'m a HellRazor (feat. Crucifix)',
'id' => 13859011,
'data' =>
array (
0 =>
(object) array(
'timestp' => '2019-10-27T00:00:00.000Z',
'score' => 1.9610844011276853,
'rank_details' =>
array (
0 =>
(object) array(
'rank' => 191,
'country' => 'RU',
'score' => 1.9610844011276853,
'genre' => 'Country',
),
),
),
1 =>
(object) array(
'timestp' => '2019-12-04T00:00:00.000Z',
'score' => 14.70808550760029,
'rank_details' =>
array (
0 =>
(object) array(
'rank' => 9,
'country' => 'CH',
'score' => 14.70808550760029,
'genre' => 'Country',
),
),
),
2 =>
(object) array(
'timestp' => '2020-03-18T00:00:00.000Z',
'score' => 13.299189761918104,
'rank_details' =>
array (
0 =>
(object) array(
'rank' => 5,
'country' => 'RU',
'score' => 13.299189761918104,
'genre' => 'Country',
),
),
),
3 =>
(object) array(
'timestp' => '2020-07-12T00:00:00.000Z',
'score' => 19.02841337415393,
'rank_details' =>
array (
0 =>
(object) array(
'rank' => 77,
'country' => 'DE',
'score' => 19.02841337415393,
'genre' => 'Country',
),
),
),
4 =>
(object) array(
'timestp' => '2020-10-02T00:00:00.000Z',
'score' => 2.631257456412845,
'rank_details' =>
array (
0 =>
(object) array(
'rank' => 154,
'country' => 'RU',
'score' => 2.631257456412845,
'genre' => 'Country',
),
),
),
5 =>
(object) array(
'timestp' => '2020-10-03T00:00:00.000Z',
'score' => 1.896575572629275,
'rank_details' =>
array (
0 =>
(object) array(
'rank' => 195,
'country' => 'RU',
'score' => 1.896575572629275,
'genre' => 'Country',
),
),
),
),
),.....
Here is a snippet of my code:
$apiResponse = curl_exec($cc);
$array = json_decode($apiResponse);
foreach ($array as $key => $arrays) { // This will search in the 2 jsons
foreach($arrays as $key => $value) {
echo "\n Record ID: " . $value->id;
echo "\n Record Name: " . $value->name;
echo "\n Record Rank: " . $value->obj->data->rank_details->rank;
echo "\n";
}
}
Record Name and ID come over fine, but anything not in the "top level" isn't coming over. Any help is GREATLY appreciated.
You have to index into the data and rank_details arrays even if there's only one entry.
This worked for me:
echo "\n Record Rank: " . $value->data[0]->rank_details[0]->rank;
I have this code (created from the admin side) in my wordpress Database postmeta table.
a:28:{s:12:"featuredItem";s:1:"0";s:10:"headerType";s:5:"image";s:11:"headerImage";s:60:"https://rocks---.de/wp-content/uploads/2018/08/IMG_2051.jpg";s:16:"headerImageAlign";s:10:"image-left";s:3:"map";a:7:{s:7:"address";s:6:"Goslar";s:8:"latitude";s:10:"51.9059531";s:9:"longitude";s:18:"10.428996299999994";s:10:"streetview";s:1:"0";s:9:"swheading";s:2:"90";s:7:"swpitch";s:1:"5";s:6:"swzoom";s:1:"1";}s:9:"telephone";s:4:"0221";s:19:"telephoneAdditional";a:3:{i:0;a:1:{s:6:"number";s:12:"111111111111";}i:1;a:1:{s:6:"number";s:13:"2222222222222";}i:2;a:1:{s:6:"number";s:13:"3333333333333";}}s:5:"email";s:20:"goslarEmail#email.de";s:9:"showEmail";s:1:"1";s:15:"contactOwnerBtn";s:1:"1";s:3:"web";s:27:"https://musicheadquarter.de";s:12:"webLinkLabel";s:17:"Label of the Link";s:19:"displayOpeningHours";s:1:"1";s:18:"openingHoursMonday";s:2:"12";s:19:"openingHoursTuesday";s:2:"12";s:21:"openingHoursWednesday";s:2:"12";s:20:"openingHoursThursday";s:2:"12";s:18:"openingHoursFriday";s:2:"12";s:20:"openingHoursSaturday";s:2:"12";s:18:"openingHoursSunday";s:2:"12";s:16:"openingHoursNote";s:26:"Text zu den Öffnungsziten";s:18:"displaySocialIcons";s:1:"1";s:26:"socialIconsOpenInNewWindow";s:1:"1";s:11:"socialIcons";a:2:{i:0;a:4:{s:5:"image";s:0:"";s:4:"icon";s:18:"fa-facebook-square";s:9:"iconColor";s:7:"#00FF00";s:4:"link";s:22:"http://rocks---.de";}i:1;a:4:{s:5:"image";s:0:"";s:4:"icon";s:12:"fa-instagram";s:9:"iconColor";s:7:"#00FF00";s:4:"link";s:20:"https://rocks---.de";}}s:14:"displayGallery";s:1:"1";s:7:"gallery";a:3:{i:0;a:2:{s:5:"title";s:6:"Bild 1";s:5:"image";s:60:"https://rocks---.de/wp-content/uploads/2019/01/IMG_8797.jpg";}i:1;a:2:{s:5:"title";s:6:"Bild 2";s:5:"image";s:60:"https://rocks---.de/wp-content/uploads/2019/01/IMG_8443.jpg";}i:2;a:2:{s:5:"title";s:6:"Bild 3";s:5:"image";s:60:"https://rocks---.de/wp-content/uploads/2018/08/IMG_8545.jpg";}}s:15:"displayFeatures";s:1:"1";s:8:"features";a:2:{i:0;a:3:{s:4:"icon";s:0:"";s:4:"text";s:15:"Feature Titel 1";s:4:"desc";s:28:"Feature Titel Beschreibung 1";}i:1;a:3:{s:4:"icon";s:0:"";s:4:"text";s:15:"Feature Titel 2";s:4:"desc";s:28:"Feature Titel Beschreibung 2";}}}
Now I tried to create the code for this ARRAY or what it is called. Everything works fine, exept the ARRAY in an ARRAY thing. Like, the list of social icons, image galelry and telephone numbers.
This is what I have so far:
$data = array(
'subtitle' => 'Utertitel',
'featuredItem' => '0',
'headerType' => 'image',
'headerImage' => 'https://rocks---.de/wp-content/uploads/slide3___beach-2179183_1920.jpg',
'headerHeight' => '375',
'map' => array(
'address' => $adresse,
'latitude' => $lat,
'longitude' => $lng,
'streetview' => '0',
'swheading' => '90',
'swpitch' => '5',
'swzoom' => '14'
),
'telephone' => '0221',
'telephoneAdditional' => '0228',
'email' => 'meister#rocks---.de',
'showEmail' => '1',
'contactOwnerBtn' => '1',
'web' => 'https://musicheadquarter.de',
'webLinkLabel' => '',
'displayOpeningHours' => '1',
'openingHoursMonday' => '12-17',
'openingHoursTuesday' => '12-17',
'openingHoursWednesday' => '12-17',
'openingHoursThursday' => '12-17',
'openingHoursFriday' => '12-17',
'openingHoursSaturday' => '12-17',
'openingHoursSunday' => '12-17',
'openingHoursNote' => 'Zusatzinfos zu den Öffnungszeiten',
'displaySocialIcons' => '0',
'socialIconsOpenInNewWindow' => '1',
'socialIcons' => array(
'icon' => 'fa-facebook-square',
'link' => 'https://rocks---.de'
),
'displayGallery' => '0',
'gallery' => array(
'title' => 'Titel des Bildes',
'image' => 'https://rocks---.de/wp-content/uploads/slide3___beach-2179183_1920.jpg'
),
'displayFeatures' => '0',
'features' => '0'
);
/* $data = maybe_serialize( $data ); */
update_post_meta( $post_id, '_ait-item_item-data', $data );
HOw do I create the ARRAY for the Images, social icons and telephone numbers.
I unserialized the Field Data and it shows the ARRAY, great!
array (
'featuredItem' => '0',
'headerType' => 'image',
'headerImage' => 'https://rockspots.de/wp-content/uploads/2018/08/IMG_2051.jpg',
'headerImageAlign' => 'image-left',
'map' =>
array (
'address' => 'Goslar',
'latitude' => '51.9059531',
'longitude' => '10.428996299999994',
'streetview' => '0',
'swheading' => '90',
'swpitch' => '5',
'swzoom' => '1',
),
'telephone' => '0221',
'telephoneAdditional' =>
array (
0 =>
array (
'number' => '111111111111',
),
1 =>
array (
'number' => '2222222222222',
),
2 =>
array (
'number' => '3333333333333',
),
),
'email' => 'goslarEmail#email.de',
'showEmail' => '1',
'contactOwnerBtn' => '1',
'web' => 'https://musicheadquarter.de',
'webLinkLabel' => 'Label of the Link',
'displayOpeningHours' => '1',
'openingHoursMonday' => '12',
'openingHoursTuesday' => '12',
'openingHoursWednesday' => '12',
'openingHoursThursday' => '12',
'openingHoursFriday' => '12',
'openingHoursSaturday' => '12',
'openingHoursSunday' => '12',
'openingHoursNote' => 'Text zu den Öffnungsziten',
'displaySocialIcons' => '1',
'socialIconsOpenInNewWindow' => '1',
'socialIcons' =>
array (
0 =>
array (
'image' => '',
'icon' => 'fa-facebook-square',
'iconColor' => '#00FF00',
'link' => 'http://festivaldate.de',
),
1 =>
array (
'image' => '',
'icon' => 'fa-instagram',
'iconColor' => '#00FF00',
'link' => 'https://rockspots.de',
),
),
'displayGallery' => '1',
'gallery' =>
array (
0 =>
array (
'title' => 'Bild 1',
'image' => 'https://rockspots.de/wp-content/uploads/2019/01/IMG_8797.jpg',
),
1 =>
array (
'title' => 'Bild 2',
'image' => 'https://rockspots.de/wp-content/uploads/2019/01/IMG_8443.jpg',
),
2 =>
array (
'title' => 'Bild 3',
'image' => 'https://rockspots.de/wp-content/uploads/2018/08/IMG_8545.jpg',
),
),
'displayFeatures' => '1',
'features' =>
array (
0 =>
array (
'icon' => '',
'text' => 'Feature Titel 1',
'desc' => 'Feature Titel Beschreibung 1',
),
1 =>
array (
'icon' => '',
'text' => 'Feature Titel 2',
'desc' => 'Feature Titel Beschreibung 2',
),
),
)
Now I need to know, how to create this part of the array. The number of images for the gallery is not fixed.
'gallery' =>
array (
0 =>
array (
'title' => 'Bild 1',
'image' => 'https://rockspots.de/wp-content/uploads/2019/01/IMG_8797.jpg',
),
1 =>
array (
'title' => 'Bild 2',
'image' => 'https://rockspots.de/wp-content/uploads/2019/01/IMG_8443.jpg',
),
2 =>
array (
'title' => 'Bild 3',
'image' => 'https://rockspots.de/wp-content/uploads/2018/08/IMG_8545.jpg',
),
),
Thanks for some tips,
Denis
Hopping some of you can help me with this, since a few days back I'm trying to get a list like a carousel, displayed in my FaceBook bot using the following code:
public function returnCarousel(){
$messagearray = array (
'message' =>
array (
'attachment' =>
array (
'type' => 'list',
'payload' =>
array (
'template_type' => 'list',
'top_element_style' => 'compact',
'elements' =>
array (
0 =>
array (
'title' => 'Classic T-Shirt Collection',
'subtitle' => 'See all our colors',
'image_url' => 'https://peterssendreceiveapp.ngrok.io/img/collection.png',
'buttons' =>
array (
0 =>
array (
'title' => 'View',
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/collection',
'messenger_extensions' => true,
'webview_height_ratio' => 'tall',
'fallback_url' => 'https://peterssendreceiveapp.ngrok.io/',
),
),
),
1 =>
array (
'title' => 'Classic White T-Shirt',
'subtitle' => 'See all our colors',
'default_action' =>
array (
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/view?item=100',
'messenger_extensions' => false,
'webview_height_ratio' => 'tall',
),
),
2 =>
array (
'title' => 'Classic Blue T-Shirt',
'image_url' => 'https://peterssendreceiveapp.ngrok.io/img/blue-t-shirt.png',
'subtitle' => '100% Cotton, 200% Comfortable',
'default_action' =>
array (
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/view?item=101',
'messenger_extensions' => true,
'webview_height_ratio' => 'tall',
'fallback_url' => 'https://peterssendreceiveapp.ngrok.io/',
),
'buttons' =>
array (
0 =>
array (
'title' => 'Shop Now',
'type' => 'web_url',
'url' => 'https://peterssendreceiveapp.ngrok.io/shop?item=101',
'messenger_extensions' => true,
'webview_height_ratio' => 'tall',
'fallback_url' => 'https://peterssendreceiveapp.ngrok.io/',
),
),
),
),
'buttons' =>
array (
0 =>
array (
'title' => 'View More',
'type' => 'postback',
'payload' => 'payload',
),
),
),
),
),
);
$this->sendMessage($messagearray);
}
public function sendMessage($parameters) {
echo json_encode($parameters);
}
No carousel is displayed and no error is returnes intead I get in my ngrok console this:
{"message":{"attachment":{"type":"list","payload":{"template_type":"list","top_element_style":"compact","elements":[{"title":"Classic T-Shirt Collection","subtitle":"See all our colors","image_url":"https://peterssendreceiveapp.ngrok.io/img/collection.png","buttons":[{"title":"View","type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/collection","messenger_extensions":true,"webview_height_ratio":"tall","fallback_url":"https://peterssendreceiveapp.ngrok.io/"}]},{"title":"Classic White T-Shirt","subtitle":"See all our colors","default_action":{"type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/view?item=100","messenger_extensions":false,"webview_height_ratio":"tall"}},{"title":"Classic Blue T-Shirt","image_url":"https://peterssendreceiveapp.ngrok.io/img/blue-t-shirt.png","subtitle":"100% Cotton, 200% Comfortable","default_action":{"type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/view?item=101","messenger_extensions":true,"webview_height_ratio":"tall","fallback_url":"https://peterssendreceiveapp.ngrok.io/"},"buttons":[{"title":"Shop Now","type":"web_url","url":"https://peterssendreceiveapp.ngrok.io/shop?item=101","messenger_extensions":true,"webview_height_ratio":"tall","fallback_url":"https://peterssendreceiveapp.ngrok.io/"}]}],"buttons":[{"title":"View More","type":"postback","payload":"payload"}]}}}}
if I send a single card it works, please your help
SOLVED: I formatted the array like this and I get it working.
$messagearray = array (
'speech' => 'Carousel',
'messages' => array (
0 => array (
'type' => 1,
'platform' => 'facebook',
'title' => 'Rosa Amarilla',
'imageUrl' => 'http://rosa.com/assets/imgs/rosaamarilla.jpg',
'buttons' =>
array (
0 =>array ('text' => 'Detalles de la Rosa', 'postback' => '',),
),
),
1 =>array (
'type' => 1,
'platform' => 'facebook',
'title' => 'Rosa Azul',
'imageUrl' => 'http://rosa.com/assets/imgs/rosaazul.jpg',
'buttons' =>
array (
0 => array ('text' => 'Detalles de la Rosa', 'postback' => '',),
),
),
),);
array (
0 =>
WC_Memberships_User_Membership::__set_state(array(
'id' => 52330,
'plan_id' => 18952,
'plan' =>
WC_Memberships_Membership_Plan::__set_state(array(
'id' => 18952,
'name' => 'Level 2 Access Until June',
'slug' => 'level-2-access-until-june',
'post' =>
WP_Post::__set_state(array(
'ID' => 18952,
'post_author' => '8',
'post_date' => '2017-09-11 11:05:13',
'post_date_gmt' => '2017-09-11 15:05:13',
)),
'access_method_meta' => '_access_method',
'rules' =>
array (
),
)),
'user_id' => '5213',
'status' => 'wcm-active',
'post' =>
WP_Post::__set_state(array(
'ID' => 52330,
'post_title' => 'Auto Draft',
)),
'product' => NULL,
'renewal_login_token_meta' => '_renewal_login_token',
'locked_meta' => '_locked',
)),
1 =>
WC_Memberships_User_Membership::__set_state(array(
'id' => 28639,
'plan_id' => 27786,
'plan' =>
WC_Memberships_Membership_Plan::__set_state(array(
'id' => 27786,
'name' => 'Level 1 – Ethical and Professional Standards',
'slug' => 'level-1-ethical-and-professional-standards',
'post' =>
WP_Post::__set_state(array(
'ID' => 27786,
'post_author' => '8',
'post_mime_type' => '',
'comment_count' => '0',
'filter' => 'raw',
)),
'access_method_meta' => '_access_method',
'email_content_meta' => '_email_content',
'rules' =>
array (
),
)),
'user_id' => '5213',
'status' => 'wcm-active',
'post' =>
WP_Post::__set_state(array(
'ID' => 28639,
'post_author' => '5213',
'post_date' => '2017-11-27 21:41:06',
'filter' => 'raw',
)),
'product' => NULL,
'type' => 'manually-assigned',
'locked_meta' => '_locked',
)),
);
I have this array given by woocommerce method: wc_memberships_get_user_active_memberships($user_id);
I need to extract out the name of the memberships the user has, it must be in a loop as the user can have multiple memberships. I am looking to get back name = Level 2 Access Until June, Level 1 – Ethical and Professional Standards
From what you've posted, I would try this:
$memberships_info = wc_memberships_get_user_active_memberships($user_id);
foreach ($memberships_info as $membership) {
echo $membership['plan']['name'];
}
From the woocommerce docs, it looks like you can specify what status of active memberships. So you might want to do that to include all membership types:
$args = array(
'status' => array( 'active', 'complimentary', 'pending' ),
);
$memberships_info = wc_memberships_get_user_active_memberships($user_id, $args); // adding the args bit to get all memberships
foreach ($memberships_info as $membership) {
echo $membership['plan']['name'];
}
Woocommerce docs: https://docs.woocommerce.com/document/woocommerce-memberships-function-reference/
This is what finally worked for me.
$user_id = get_current_user_id();
$memberships = wc_memberships_get_user_active_memberships($user_id);
foreach ($memberships as $membership => $val) {
echo $val->plan->name . '<br>';
};
ref: https://stackoverflow.com/a/25730860/2735734
How to Tell PayPal to automatically process the monthly payment?
UPDATE 1
here is the PayPal Reponses:
CreateAgreement result:
array (
'name' => 'my name',
'description' => 'my description',
'plan' =>
array (
'id' => 'P-95307423V8719480UI4T4SGG',
'state' => 'ACTIVE',
'name' => 'title here',
'description' => 'description here',
'type' => 'INFINITE',
'payment_definitions' =>
array (
0 =>
array (
'id' => 'PD-140035022V340531AI4T4SGG',
'name' => 'Regular Payments',
'type' => 'REGULAR',
'frequency' => 'Month',
'amount' =>
array (
'currency' => 'USD',
'value' => '15.5',
),
'cycles' => '0',
'charge_models' =>
array (
0 =>
array (
'id' => 'CHM-9G272533RU378412KI4T4SGG',
'type' => 'TAX',
'amount' =>
array (
'currency' => 'USD',
'value' => '1',
),
),
),
'frequency_interval' => '1',
),
),
'merchant_preferences' =>
array (
'setup_fee' =>
array (
'currency' => 'USD',
'value' => '0',
),
'max_fail_attempts' => '0',
'return_url' => 'http://example.com/ok',
'cancel_url' => 'http://example.com/cancel',
'auto_bill_amount' => 'YES',
'initial_fail_amount_action' => 'CONTINUE',
),
),
'links' =>
array (
0 =>
array (
'href' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-4N736816FP8632455',
'rel' => 'approval_url',
'method' => 'REDIRECT',
),
1 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/EC-4N736816FP8632455/agreement-execute',
'rel' => 'execute',
'method' => 'POST',
),
),
'start_date' => '2014-10-25T11:54:20-00:00',
)
AND after the client approved.
ExecuteAgreement result:
array (
'id' => 'I-CD3VD66KJKXX',
'state' => 'Active',
'description' => 'my description',
'plan' =>
array (
'payment_definitions' =>
array (
0 =>
array (
'type' => 'REGULAR',
'frequency' => 'Month',
'amount' =>
array (
'currency' => 'USD',
'value' => '15.50',
),
'cycles' => '0',
'charge_models' =>
array (
0 =>
array (
'type' => 'TAX',
'amount' =>
array (
'currency' => 'USD',
'value' => '1.00',
),
),
1 =>
array (
'type' => 'SHIPPING',
'amount' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
),
),
'frequency_interval' => '1',
),
),
'merchant_preferences' =>
array (
'setup_fee' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
'max_fail_attempts' => '0',
'auto_bill_amount' => 'YES',
),
),
'links' =>
array (
0 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/suspend',
'rel' => 'suspend',
'method' => 'POST',
),
1 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/re-activate',
'rel' => 're_activate',
'method' => 'POST',
),
2 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/cancel',
'rel' => 'cancel',
'method' => 'POST',
),
3 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/bill-balance',
'rel' => 'self',
'method' => 'POST',
),
4 =>
array (
'href' => 'https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-CD3VD66KJKXX/set-balance',
'rel' => 'self',
'method' => 'POST',
),
),
'start_date' => '2014-10-25T07:00:00Z',
'agreement_details' =>
array (
'outstanding_balance' =>
array (
'currency' => 'USD',
'value' => '0.00',
),
'cycles_remaining' => '0',
'cycles_completed' => '0',
'next_billing_date' => '2014-10-25T10:00:00Z',
'final_payment_date' => '1970-01-01T00:00:00Z',
'failed_payment_count' => '0',
),
)
note the start_date for the first reponse to the second...
The first payement isn't made... (And I don't know for the other, I've try today with a daily payement... I have to wait now...)
In the Pre-Approved area on the Sandbox Account, is in Active and inform about next billing correctly.
Once the user completes and submits subscription purchase page you have created, the subscription will begin and will automatically rebill the customer's account on whatever interval you have selected. You do not have to do anything.
Updated: The REST API also automatically processes subscriptions. You do not have to resubmit monthly. The PayPal sandbox was updated in July of this year to enable you to test and process subscriptions. There are no issues being reported in the dev community about this not working, so I suspect it is something on your side.
If you haven't already. please review this:
https://developer.paypal.com/docs/integration/direct/test-the-api/
There are billing plan and billing subscription sections. If you still have a problem, post your billing plan code and the response you are receiving.