Skip to content

Instantly share code, notes, and snippets.

@govindak
Created August 18, 2016 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save govindak/31dbbfb84d7a24337a0a80fa25068755 to your computer and use it in GitHub Desktop.
Save govindak/31dbbfb84d7a24337a0a80fa25068755 to your computer and use it in GitHub Desktop.
Memberpress Create transaction programatically.
$sub = new MeprSubscription();
$sub->user_id = $user_ID;
$sub->product_id = 123;
$sub->price = 12.99;
$sub->total = 12.99;
$sub->period = 1;
$sub->period_type = 'months';
$sub->status = MeprSubscription::$active_str;
$sub_id = $sub->store();
$txn = new MeprTransaction();
$txn->amount = 12.99;
$txn->total = 12.99;
$txn->user_id = $user_ID;
$txn->product_id = 123;
$txn->status = MeprTransaction::$complete_str;
$txn->txn_type = MeprTransaction::$payment_str;
$txn->gateway = 'manual';
$txn->expires_at = gmdate('Y-m-d 23:59:59', (time() + MeprUtils::months(1)));
$txn->subscription_id = $sub_id;
$txn->store();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment