paypal verifying first payment or initamt was billed in recurring payment

前端 未结 4 1352
清歌不尽
清歌不尽 2021-02-04 14:52

I want my users to be able to subscribe to a recurring payment (using the express checkout api) The first payment needs to be billed immediately that the user subscribes, and I

4条回答
  •  情深已故
    2021-02-04 15:08

    When the profile is first created, PayPal sends an IPN named "recurring_payment_profile_created". This IPN contains a field "initial_payment_txn_id". You can use GetTransactionDetails to look up this ID and determine whether that transaction is Completed. Ensure that you mark that transaction ID as processed so that your code doesn't double-ship if/when the IPN for that transaction is sent (if that is relevant to you). This example is similar to how we approach this in our IPN listener (written in Ruby against PayPal's official Merchant SDK gem):

    case params[:txn_type]
      when 'recurring_payment_profile_created'
        # The profile has been created.  Perform any action, if necessary...
    
        initial_txn = params[:initial_payment_txn_id]
        return if ProcessedTransaction.exists?(initial_txn)
    
        request = api.build_get_transaction_details({
            :TransactionID => initial_txn
        })
    
        resp = api.get_transaction_details(request)
        if resp.success? and resp.PaymentTransactionDetails.PaymentInfo.PaymentStatus == 'Completed'
            # The initial payment is completed, perform the action...
            # Add this ID to your ProcessedTransaction table so you don't double-process...
        end
      # other 'when' statements for other transaction types, etc go here
    end
    

提交回复
热议问题