0

나는 내 레일 웹 애플 리케이션에 페이팔을 통합하고 있습니다. 다음 구현 사례가 필요합니다.Paypal 적응 형 지불 자동화 된 흐름의 레일

  1. 고객이 서비스를 구입하여 내 앱에 지불합니다.
  2. 예를 들어 일주일에 며칠 후에, 나는 유료 서비스 제공 업체에 비용을 지불합니다. 이 포인트 2는 고객에게 지불 할 날짜가 왔는지 자동으로 확인하는 엔진이 있습니다. 그렇다면 공급자에게 자동으로 지불하려고 시도합니다.

나는 포인트 1을 구현하고 익스프레스 체크 아웃으로 작업하고 있습니다. 제 2 점은 적응 지불 API를 사용해야한다는 것입니다. 그러나, 나는 이해하지 못했기 때문에 잘 모르겠습니다.

내 첫 번째 질문은 모든 것이 자동화되기를 원합니다. 그래서 어떤 것을 확인하기 위해 팝업 창이 나타나기를 원하지 않습니까? 자동으로 작업을 실행할 수 있습니까?

내 코드 :

def pay(amount, paypalAccountEmail) 

    # ## Build request object 
    @pay_request = @api.build_pay() 

    # The action for this request. Possible values are: 
    # 
    # * PAY - Use this option if you are not using the Pay request in 
    # combination with ExecutePayment. 
    # * CREATE - Use this option to set up the payment instructions with 
    # SetPaymentOptions and then execute the payment at a later time with 
    # the ExecutePayment. 
    # * PAY_PRIMARY - For chained payments only, specify this value to delay 
    # payments to the secondary receivers; only the payment to the primary 
    # receiver is processed. 
    @pay_request.actionType   = "PAY" 

    # URL to redirect the sender's browser to after 
    # canceling the approval for a payment; it is always required but only 
    # used for payments that require approval (explicit payments) 
    @pay_request.cancelUrl   = "https://paypal-sdk-samples.herokuapp.com/adaptive_payments/pay" 

    # The code for the currency in which the payment is 
    # made; you can specify only one currency, regardless of the number of 
    # receivers 
    @pay_request.currencyCode  = "EUR" 

    # The payer of PayPal fees. Allowable values are: 
    # 
    # * SENDER - Sender pays all fees (for personal, implicit simple/parallel payments; do not use for chained or unilateral payments) 
    # * PRIMARYRECEIVER - Primary receiver pays all fees (chained payments only) 
    # * EACHRECEIVER - Each receiver pays their own fee (default, personal and unilateral payments) 
    # * SECONDARYONLY - Secondary receivers pay all fees (use only for chained payments with one secondary receiver) 
    @pay_request.feesPayer   = "SENDER" 

    # The URL to which you want all IPN messages for this payment to be sent. 
    @pay_request.ipnNotificationUrl = "https://paypal-sdk-samples.herokuapp.com/adaptive_payments/ipn_notify" 

    # Amount to be paid to the receiver. 
    @pay_request.receiverList.receiver[0].amount = amount 

    # Receiver's email address. This address can be unregistered with paypal.com. If so, a receiver cannot claim the payment until a PayPal account is linked to the email address. The PayRequest must pass either an email address or a phone number. 
    @pay_request.receiverList.receiver[0].email = paypalAccountEmail 

    # The URL to which the sender's browser is redirected after approving a payment on paypal.com. Specify the URL with the HTTP or HTTPS designator. 
    @pay_request.returnUrl   = "https://paypal-sdk-samples.herokuapp.com/adaptive_payments/pay" 

    # ## Make API call & get response 
    @pay_response = @api.pay(@pay_request) 

    # ## Access Response 
    # ### Success Response 

    if @pay_response.responseEnvelope.ack == "Success" 
    # Once you get success response, user has to redirect to PayPal 
    # for the payment. Construct redirectURL as follows, 
    # `redirectURL=https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" 
    # + @pay_response.payKey;` 

    # The pay key, which is a token you use in other Adaptive 
    # Payment APIs (such as the Refund Method) to identify this 
    # payment. The pay key is valid for 3 hours; the payment must 
    # be approved while the pay key is valid. 
    puts @pay_response.payKey 

    # The status of the payment. Possible values are: 
    # 
    # * CREATED - The payment request was received; funds will be transferred once the payment is approved 
    # * COMPLETED - The payment was successful 
    # * INCOMPLETE - Some transfers succeeded and some failed for a parallel payment or, for a delayed chained payment, secondary receivers have not been paid 
    # * ERROR - The payment failed and all attempted transfers failed or all completed transfers were successfully reversed 
    # * REVERSALERROR - One or more transfers failed when attempting to reverse a payment 
    # * PROCESSING - The payment is in progress 
    # * PENDING - The payment is awaiting processing 
    puts "Pay Key : " + @pay_response.paymentExecStatus 

    # ###Error Response 
    else 
    puts @pay_response.error[0].message 

    end 
    @pay_response 
end 

내 로그 :

providerPayment-->begin 
Request[post]: https://svcs.sandbox.paypal.com/AdaptivePayments/Pay 
Response[200]: OK, Duration: 1.417s 
AP-1E607027P7722991V 
Pay Key : CREATED 
providerPayment-->ok 

나는 페이팔에서 예를했다하지만 난 그것을 실행할 때, 나는 결과가 괜찮 참조하십시오. 내 actionType = "PAY". 그래서 나는 돈을주고 싶다. 그러나 열쇠에서, 나는 = 창조되고 그 후 아무 일도 일어나지 않는다. 나는 창조하고 싶지 않지만 거래를 완료하고 싶지 않습니다. 내가 뭘 놓치고 있니?

답변

3

어디서나 사용자를 리디렉션하는 것으로 보이지 않습니다. ?? Pay에 전화를 걸면 사용자를 PayPal로 리디렉션하여 로그인하고 결제를 인증해야합니다. 그럴 수없는 유일한 시간은 유료 요청에 사전 승인 키를 포함하는 경우입니다. 그러나 나는 자신이 보이지 않습니다.

리디렉션 할 PayPal URL의 끝에 도착하는 paykey를 추가해야합니다. 다음은 샘플입니다. https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=AP-3VV02679XF235284R

사용자가 로그인하여 해당 paykey에 대한 지불을 완료 할 때까지 실제로 생성됩니다.

코드의 주석에 리디렉션 URL에 대한 정보가 실제로 표시되지만 실제로 리디렉션을 통해 사용자를 보내지는 않습니다.

-----

지금 당신이 암시 지불하고있는 볼 것을, 당신은 단지 요청에 SENDEREMAIL를 포함해야 할 필요가 ----- UPDATE. 다음은 암묵적 승인을 받아 작업 한 Pay 요청의 샘플입니다. 따라서 리디렉션 및 추가 인증이 필요하지 않았습니다. 이 암시 적 승인없이 것처럼중인/방금 생성하는 반대 여기

<?xml version="1.0" encoding="utf-8"?> 
<PayRequest xmlns="http://svcs.paypal.com/types/ap"> 
    <requestEnvelope xmlns=""> 
    <detailLevel>ReturnAll</detailLevel> 
    <errorLanguage>en_US</errorLanguage> 
    </requestEnvelope> 
    <actionType xmlns="">PAY</actionType> 
    <cancelUrl xmlns="">http://paypal.angelleye.com/paypal/class/1.2/Pay_Cancel.php</cancelUrl> 
    <clientDetails xmlns=""> 
    <applicationId xmlns="">APP-80W284485P519543T</applicationId> 
    <ipAddress xmlns="">192.168.1.115</ipAddress> 
    <partnerName xmlns="">Always Give Back</partnerName> 
    </clientDetails> 
    <currencyCode xmlns="">USD</currencyCode> 
    <receiverList xmlns=""> 
    <receiver xmlns=""> 
     <amount xmlns="">10.00</amount> 
     <email xmlns="">[email protected]</email> 
    </receiver> 
    <receiver xmlns=""> 
     <amount xmlns="">5.00</amount> 
     <email xmlns="">[email protected]</email> 
    </receiver> 
    </receiverList> 
    <sender> 
    <useCredentials xmlns=""></useCredentials> 
    </sender> 
    <account xmlns=""> 
    <phone xmlns=""></phone> 
    </account> 
    <returnUrl xmlns="">http://paypal.angelleye.com/paypal/class/1.2/Pay_Return.php</returnUrl> 
    <senderEmail xmlns="">[email protected]</senderEmail> 
</PayRequest> 

는 paymentExecStatus을 보여줍니다 응답이 완전히 완료입니다.

<?xml version='1.0' encoding='UTF-8'?> 
<ns2:PayResponse xmlns:ns2="http://svcs.paypal.com/types/ap"> 
    <responseEnvelope> 
    <timestamp>2014-01-20T07:53:08.420-08:00</timestamp> 
    <ack>Success</ack> 
    <correlationId>c74cd2a669678</correlationId> 
    <build>7935900</build> 
    </responseEnvelope> 
    <payKey>AP-39D64611TH198910V</payKey> 
    <paymentExecStatus>COMPLETED</paymentExecStatus> 
    <paymentInfoList> 
    <paymentInfo> 
     <transactionId>0M064165EV3552504</transactionId> 
     <transactionStatus>COMPLETED</transactionStatus> 
     <receiver> 
     <amount>10.00</amount> 
     <email>[email protected]</email> 
     <primary>false</primary> 
     <accountId>E7BTGVXBFSUAU</accountId> 
     </receiver> 
     <pendingRefund>false</pendingRefund> 
     <senderTransactionId>43F26555RA073153C</senderTransactionId> 
     <senderTransactionStatus>COMPLETED</senderTransactionStatus> 
    </paymentInfo> 
    <paymentInfo> 
     <transactionId>7K9309808X980452U</transactionId> 
     <transactionStatus>COMPLETED</transactionStatus> 
     <receiver> 
     <amount>5.00</amount> 
     <email>[email protected]</email> 
     <primary>false</primary> 
     <accountId>C9TAVNJFATXCS</accountId> 
     </receiver> 
     <pendingRefund>false</pendingRefund> 
     <senderTransactionId>0M822840XM282203C</senderTransactionId> 
     <senderTransactionStatus>COMPLETED</senderTransactionStatus> 
    </paymentInfo> 
    </paymentInfoList> 
    <sender> 
    <accountId>ATSCG2QMC9KAU</accountId> 
    </sender> 
</ns2:PayResponse> 

따라서 어떤 클래스 라이브러리를 사용하든 senderEmail 매개 변수를 쉽게 추가 할 수 있어야 문제가 해결됩니다.

+0

Adaptative payment flow가 말하는대로 작동하는 경우이 API는 저에게 적합하지 않습니다.위의 사용 사례를 참조하십시오. 클라이언트는 이미 급행 결제 일을 지불했습니다. 일주일 후, 나는 공급자에게 돈을 지불해야하며 이것은 자동적이어야합니다. 내 사이트 (내 페이팔 비즈니스 계정, 공급자 계정)에서 지불하는 것입니다. 아무도 결제를 인증하기 위해 로그인해야합니다 ... 알고 계시다면 다른 API 또는 방법을 사용해야하는지 알려 주시기 바랍니다. – Rober

+0

아, 죄송합니다. 간과 한 것 같습니다. 예, 리디렉션 및 추가 승인없이 진행되도록 Pay 요청을 암시 적으로 승인 할 수 있습니다. 나에게 최소한의 시간을 주면 그걸 샘플로 요청 해줄거야. –

+0

암묵적 지불을하기 위해 요청에 senderEmail을 포함하면됩니다. 샘플을 사용하여 답변을 업데이트했습니다. –

관련 문제