Title: Payment Notification API
Last modified: August 22, 2016

---

# Payment Notification API

 *  Resolved [ryantcarter](https://wordpress.org/support/users/ryantcarter/)
 * (@ryantcarter)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/payment-notification-api/)
 * Hey Guys,
 * I’m trying to get an order to populate in woocommerce when an s2member payment
   is received. I’m 90% of the way there. When a coupon is entered via s2member 
   i’ve managed to get woocommerce to recognise it and add the relevant discount
   to the order.
 * Trouble is, when there’s no discount added. The order doesn’t come through to
   woocommerce.
 * Here’s the PHP i’ve got running this part of it, obviously it’s pulling in the
   vars from further up the script.
 * Can anyone see anything glaringly obvious I’m doing wrong?
 *     ```
       $order = wc_create_order();
           $order->add_product(get_product($tier), 1);
           $order->set_address($address, 'billing');
           $order->set_address($address, 'shipping');
           if ($coupon_code == 'code135' || $coupon_code == 'code235' || $coupon_code == 'code335')
           		{
       	    	$order->add_coupon($coupon_code, 6.65);
       			$order->set_total(6.65, 'order_discount');
       			}
       	$order->calculate_totals();
       	$order->payment_complete();
       ```
   
 * [https://wordpress.org/plugins/s2member/](https://wordpress.org/plugins/s2member/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [ryantcarter](https://wordpress.org/support/users/ryantcarter/)
 * (@ryantcarter)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/payment-notification-api/#post-5624972)
 * As a work around to this, I’ve piped a fixed character through the URL string
   before the replacement code, this means I’ve always got a value to reference.

Viewing 1 replies (of 1 total)

The topic ‘Payment Notification API’ is closed to new replies.

 * ![](https://ps.w.org/s2member/assets/icon-256x256.png?rev=980067)
 * [s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions](https://wordpress.org/plugins/s2member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/s2member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/s2member/)
 * [Active Topics](https://wordpress.org/support/plugin/s2member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/s2member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/s2member/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)

 * 1 reply
 * 1 participant
 * Last reply from: [ryantcarter](https://wordpress.org/support/users/ryantcarter/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/payment-notification-api/#post-5624972)
 * Status: resolved