{"action":"opened","issue":{"url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/issues/1647","repository_url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro","labels_url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/issues/1647/labels{/name}","comments_url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/issues/1647/comments","events_url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/issues/1647/events","html_url":"https://github.com/restrictcontentpro/restrict-content-pro/issues/1647","id":293613349,"number":1647,"title":"New PayPal Express payments don't get a subscription key","user":{"login":"nosegraze","id":6324272,"avatar_url":"https://avatars2.githubusercontent.com/u/6324272?v=4","gravatar_id":"","url":"https://api.github.com/users/nosegraze","html_url":"https://github.com/nosegraze","followers_url":"https://api.github.com/users/nosegraze/followers","following_url":"https://api.github.com/users/nosegraze/following{/other_user}","gists_url":"https://api.github.com/users/nosegraze/gists{/gist_id}","starred_url":"https://api.github.com/users/nosegraze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nosegraze/subscriptions","organizations_url":"https://api.github.com/users/nosegraze/orgs","repos_url":"https://api.github.com/users/nosegraze/repos","events_url":"https://api.github.com/users/nosegraze/events{/privacy}","received_events_url":"https://api.github.com/users/nosegraze/received_events","type":"User","site_admin":false},"labels":[{"id":5100959,"url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/milestones/85","html_url":"https://github.com/restrictcontentpro/restrict-content-pro/milestone/85","labels_url":"https://api.github.com/repos/restrictcontentpro/restrict-content-pro/milestones/85/labels","id":3037280,"number":85,"title":"2.9.10","description":null,"creator":{"login":"pippinsplugins","id":1034109,"avatar_url":"https://avatars1.githubusercontent.com/u/1034109?v=4","gravatar_id":"","url":"https://api.github.com/users/pippinsplugins","html_url":"https://github.com/pippinsplugins","followers_url":"https://api.github.com/users/pippinsplugins/followers","following_url":"https://api.github.com/users/pippinsplugins/following{/other_user}","gists_url":"https://api.github.com/users/pippinsplugins/gists{/gist_id}","starred_url":"https://api.github.com/users/pippinsplugins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pippinsplugins/subscriptions","organizations_url":"https://api.github.com/users/pippinsplugins/orgs","repos_url":"https://api.github.com/users/pippinsplugins/repos","events_url":"https://api.github.com/users/pippinsplugins/events{/privacy}","received_events_url":"https://api.github.com/users/pippinsplugins/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":5,"state":"open","created_at":"2018-01-15T20:27:32Z","updated_at":"2018-02-01T17:15:52Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-02-01T17:15:52Z","updated_at":"2018-02-01T17:15:52Z","closed_at":null,"author_association":"MEMBER","body":"Because in the webhook we set up the payment data and set the `subscription_key` to `$member->get_subscription_key()` . But when it's a user's very first payment, they don't have a subscription key yet. We need to use `$member->get_pending_subscription_key()`.\r\n\r\nThis is the overall fix:\r\n\r\n```php\r\n\t\t// setup the payment info in an array for storage\r\n\t\t$pending_key = $member->get_pending_subscription_key();\r\n\t\t$payment_data = array(\r\n\t\t\t'date'             => date( 'Y-m-d H:i:s', strtotime( $posted['payment_date'] ) ),\r\n\t\t\t'subscription'     => $subscription_level->name,\r\n\t\t\t'payment_type'     => $posted['txn_type'],\r\n\t\t\t'subscription_key' => ! empty( $pending_key ) ? $pending_key : $member->get_subscription_key(),\r\n\t\t\t'amount'           => $amount,\r\n\t\t\t'user_id'          => $user_id,\r\n\t\t\t'transaction_id'   => $posted['txn_id'],\r\n\t\t\t'status'           => 'complete'\r\n\t\t);\r\n```"}}
{"actor":{"display_login":"nosegraze"}}