2016-10-18 21 views
3

Paypalの.NET SDKを使用して、自分のASP.NET MVC 5プロジェクトにPaypalの直接支払いを統合しています。以下は、手順です:Paypal REST API - 支払い処理中にパラメータを渡す

  1. 私はPayPal.Api.Payment.Create(APIContext)を呼び出し、成功したURLでPaypalサイトにリダイレクトします。
  2. 成功したURLに対応するコールバックアクションでは、PayPal.Api.Payment.Execute(APIContext、ExecutionContext)を呼び出します。私は必要なもの

)がPayment.Createを呼び出すとき)(ペイパルへの新規注文のIDを渡し、Payment.Executeで、その値を(受信なので、支払いが関連付けられている注文いると知ることができます。

それは可能ですか?どうもありがとう。

答えて

0

SDKとAPIのヘルプページに基づいて、Payments.Create()エンドポイントに送信するトランザクションのinvoice_numberプロパティを利用します。この取引は、PayPalからの返品返品の一部となります。つまり、OrderNumber(現在はinvoice_numberと呼ばれています)をAPIから取得することができます。

以下の行を見つけます。invoice_number = YOUR_ORDER_NUMBER

あなたのPayPalの要求:(taken from SDK Samples

 var apiContext = Configuration.GetAPIContext(); 

     // A transaction defines the contract of a payment - what is the payment for and who is fulfilling it. 
     var transaction = new Transaction() 
     { 
      amount = new Amount(){...}, 
      description = "This is the payment transaction description.", 
      item_list = new ItemList(){...}, 

      //SET YOUR ORDER NUMBER HERE 
      invoice_number = YOUR_ORDER_NUMBER 
     }; 

     // A resource representing a Payer that funds a payment. 
     var payer = new Payer(){...}; 

     // A Payment resource; create one using the above types and intent as `sale` or `authorize` 
     var payment = new Payment() 
     { 
      intent = "sale", 
      payer = payer, 
      transactions = new List<Transaction>() { transaction } 
     }; 
     this.flow.AddNewRequest("Create credit card payment", payment); 

     // Create a payment using a valid APIContext 
     var createdPayment = payment.Create(apiContext); 

ペイパルからの応答(Taken From Here):

enter image description here

関連する問題