How to access the response/redirect after stripe payment?

The JAVA Noob

Im trying to sell videos on my website, hosted using wordpress. I have set up a Stripe account and been using "WP Simple Pay Lite for Stripe" Plugin on my website.

The problem that i'm facing is when I get a payment on stripe I manually send my customers the video that they have purchased. I was wondering if anyone has any advice on how I can automate the process by sending my customers the product once payment has been paid.

For this "WP Simple Pay Lite for Stripe" Plugin there is a successful payment URL redirect feature. That I was using before. How ever I noticed that you can view the successful payment redirect from the Developer Tools.

<input type="hidden" name="sc-redirect" value="https://wpsimplepay.com/demo-success-page/">

shramee

As Stanimir Stoyanov said, you can use sc_after_charge but his code won't work because sc_after_charge returns Charge object, not JSON.

/**
 * Sends video url to customer when payment is successful
 * @param $response \Stripe\Charge
 */
function send_video_if_payment_successful( $response ) {
    if ( $response->paid ) {
        // Maybe check amount and or description to ensure it's same product
        $file = 'http://url_to/file_to_attach.mp4'; // Video url
        $subject = 'Find your video here - My store'; // Email subject
        $msg = '
        Thanks for buying...
        yada yada yada...
        Please find attached video.'; // Email message

        $attachments = array( $file ); // Add attachment

        $headers = 'From: My store <[email protected]>' . "\r\n"; // Set yourself in From header

        wp_mail( $response->receipt_email, $subject, $msg, $headers, $attachments ); // Send the mail
    }
}
add_action( 'sc_after_charge', 'send_video_if_payment_successful' );

Here we first check if payment was successful, if yes, we the email the file to the user :)

If you plan to sell multiple products... You can set appropriate description and send different files for different descriptions accessible by $response->description

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get the Access Token in Stripe payment gateway in PHP

From Dev

How to Connect Standalone Stripe account to platform after user authorizes access

From Dev

stripe payment - how to suspend a subscription (not cancel)

From Dev

Laravel Cashier - How to Check if Stripe Payment was Successful

From Dev

Get last 4 digits of credit card after successful Stripe payment

From Dev

Looking to Submit Rails Form Only After Successful Stripe Checkout Payment

From Dev

Get last 4 digits of credit card after successful Stripe payment

From Dev

Stripe charge issue with stripe payment

From Dev

Stripe charge issue with stripe payment

From Dev

How can I use stripe.js with jQuery.payment?

From Dev

How to disable default payment method (Credit Card) in Stripe Checkout

From Dev

Stripe payment integration on Android

From Dev

Stripe custom payment not charging

From Dev

Stripe Payment on user behalf

From Dev

Stripe payment Android

From Dev

Method for confirming Stripe payment

From Dev

Stripe Payment Amount

From Dev

I am not able to get Stripe payment Id after entering My card details

From Dev

Stripe API - Next Payment date

From Dev

stripe payment issue ruby on rails

From Dev

Stripe- Send Payment to Customers

From Dev

Stripe Cancel one payment in subscription?

From Dev

Stripe Payment Gateway - Variable Amounts

From Dev

Stripe payment integration in controller action

From Dev

Android Stripe Payment: user email?

From Dev

How do you determine if a stripe event object with the type charge.succeeded is a reocurring subscription payment

From Dev

How can I send email to customer when recurring payment fails on Stripe?

From Dev

How do I POST multiple forms when submitting payment to stripe with jQuery / ajax?

From Dev

How to avoid concurrent access to payment link in my website

Related Related

  1. 1

    Get the Access Token in Stripe payment gateway in PHP

  2. 2

    How to Connect Standalone Stripe account to platform after user authorizes access

  3. 3

    stripe payment - how to suspend a subscription (not cancel)

  4. 4

    Laravel Cashier - How to Check if Stripe Payment was Successful

  5. 5

    Get last 4 digits of credit card after successful Stripe payment

  6. 6

    Looking to Submit Rails Form Only After Successful Stripe Checkout Payment

  7. 7

    Get last 4 digits of credit card after successful Stripe payment

  8. 8

    Stripe charge issue with stripe payment

  9. 9

    Stripe charge issue with stripe payment

  10. 10

    How can I use stripe.js with jQuery.payment?

  11. 11

    How to disable default payment method (Credit Card) in Stripe Checkout

  12. 12

    Stripe payment integration on Android

  13. 13

    Stripe custom payment not charging

  14. 14

    Stripe Payment on user behalf

  15. 15

    Stripe payment Android

  16. 16

    Method for confirming Stripe payment

  17. 17

    Stripe Payment Amount

  18. 18

    I am not able to get Stripe payment Id after entering My card details

  19. 19

    Stripe API - Next Payment date

  20. 20

    stripe payment issue ruby on rails

  21. 21

    Stripe- Send Payment to Customers

  22. 22

    Stripe Cancel one payment in subscription?

  23. 23

    Stripe Payment Gateway - Variable Amounts

  24. 24

    Stripe payment integration in controller action

  25. 25

    Android Stripe Payment: user email?

  26. 26

    How do you determine if a stripe event object with the type charge.succeeded is a reocurring subscription payment

  27. 27

    How can I send email to customer when recurring payment fails on Stripe?

  28. 28

    How do I POST multiple forms when submitting payment to stripe with jQuery / ajax?

  29. 29

    How to avoid concurrent access to payment link in my website

HotTag

Archive