Asked  7 Months ago    Answers:  5   Viewed   18 times

I have setup a PayPal IPN file. When the user is at the site and press submit details about the transaction is uploaded to the db. The relevant id is sent via PayPal as the custom field. When payment complete IPN used to update DB as transaction completed based on id.

All is fine.

However, this is the tricky bit. I also need to update another table - a discount/coupon code db. The update is based on the code entered and also the number of times the code can still be used. Basically if it was 50 times, after used once the db would be updated with 49. So I need to pass the code and the remaining uses allowed so can say update table where code = XXXX (update new value of 49 etc).

I can work out how to pass all these values in the custom field, but cannot work out how to parse them out again? Read about separating them with : etc, but need some advice from someone who has done before.

This is how IPN details currently comes back:

$custom = $_POST['custom'];

Thank you.

 Answers

38

I did just this recently,
Send your paypal custom field to data as your would, inside that custom field, use a separator to split your data. In the below example, the values are split using a "|", you can use any character you want available in your charset.

$member_id = 1;
$some_other_id = 2;
<input type="hidden" name="custom" value="<?php echo $member_id.'|'.$some_other_id ?>"/>

This will output:

<input type="hidden" name="custom" value="1|2"/>

When you get the information from paypal (the IPN response) process it like so:

$ids = explode('|', $_POST['custom']); // Split up our string by '|'
// Now $ids is an array containing your 2 values in the order you put them.
$member_id = $ids[0]; // Our member id was the first value in the hidden custom field
$some_other_ud = $ids[1]; // some_other_id was the second value in our string.

So basically, we send a string with a custom delimiter that we choose to paypal, paypal will return it to us in the IPN response. We then need to split it up (using the explode() function) and then do what you would like with it.

When you get your value from the database your select it using normal methods, then just decrement it by 1 using:

$val_from_db--; // Thats it!, Takes the current number, and minus 1 from it.
Wednesday, March 31, 2021
 
AntoineB
answered 7 Months ago
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 7 Months ago
79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 5 Months ago
92

Here is the steps to enable IPN in paypal Sandbox

  1. Log in to the Sandbox Merchant Id and click the Profile subtab under My Account.
  2. Click the More Option link under Profile.
  3. Look Selling Preferences which is third row.
  4. Click the Instant Payment Notification Preferences link under Selling Preferences
  5. Enter the IPN URL

Update the Settings....

Saturday, August 7, 2021
 
osondoar
answered 3 Months ago
44

As I (and many others I imagine) am also facing this problem, I thought I'd share some solutions I came across.

This one raised in the PayPal Community, suggests the use of the Option Variables which appear to offer a key/value pair implementation to facilitate up to 99 vars (for the record I have not actually tried this).

The most commonly accepted solution (which I also favor) is to add all of your data to a DB record, then use the custom var to store your record ID, which can obviously be used later (e.g. via IPN) to retrieve your data.

Friday, August 13, 2021
 
anon_swe
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :