【问题标题】:PayPal payment variables for post to return url用于返回 url 的 PayPal 支付变量
【发布时间】:2016-01-27 11:26:12
【问题描述】:

我目前正在使用 PayPal 通过 API 进行支付,如下所示:

<form id="payment" method="post" action= "https://www.sandbox.paypal.com/cgi-bin/webscr">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="business" value="xxx@yahoo.com">
    <input type="hidden" name="item_name" value="Order">
    <input type="hidden" name="amount" value="1.00">
    <input type="hidden" name="return" value="http://www.example.com/callback" />
    <input type='hidden' name='rm' value='2'>
</form>

https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HI0709B 所述,rm 设置为 2 以使用POST 方法作为付款过程后的返回 url。

不过返回POST变量没有详细描述,我从chrome中得到了一些变量如:

mc_gross:1.00
mc_currency:USD

这很容易理解。但变量如下:

verify_sign:AIcINKz4gusKUvaiOqo3JiAvlEBFA-7ApBee-2bb5OtUUM5RhVUumd84
auth:AEH3nN1f7cUPFUFS4wPBRv6gOw6CV0BppygOu6y-vRHspA3a-ae-y2BnH1tQds1bwOG4EFqxZrcgNxLXKZdsDWg

我不明白这个意思。可能这应该像加密或校验和?如果是,我如何检查这些返回变量的验证?

【问题讨论】:

    标签: paypal paypal-ipn


    【解决方案1】:

    这是一个支付宝付款方式的示例。

    PayPalPayment *payment = [[PayPalPayment alloc] init];
    
    payment.amount = [self.paymentAmount decimalNumberByRoundingAccordingToBehavior:roundUp];
    
    payment.currencyCode = @"USD";
    
    self.PayPalReceiverEmail = [[self.photo objectForKey:kPAPPhotoUserKey] objectForKey:kPayPalReceiverEmailKey];
    
    payment.shortDescription = self.PayPalReceiverEmail;
    
    if (([[NSDecimalNumber notANumber] isEqualToNumber:payment.amount] ) ) {
    // This particular payment will always be processable. If, for
    // example, the amount was negative or the shortDescription was
    // empty, this payment wouldn't be processable, and you'd want
    // to handle that here.
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please enter a valid amount" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
      [alert show];
    
    }
    else {
    if  (!payment.processable)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Payment cannot be processed. Please contact technical support." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
        [alert show];
    }
    else
    {
    // Any customer identifier that you have will work here. Do NOT use a device- or
    // hardware-based identifier.
    //self.customerId = @"user-12345";
      self.customerId = [PFUser currentUser].objectId;
    
    // Set the environment:
    // - For live charges, use PayPalEnvironmentProduction (default).
    // - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
    // - For testing, use PayPalEnvironmentNoNetwork.
    [PayPalPaymentViewController setEnvironment:self.environment];
    
    
      if (self.PayPalReceiverEmail && self.PayPalReceiverEmail.length >0 )
      {
          PayPalPaymentViewController *paymentViewController;
    
          if (self.PayPalClientId && self.PayPalClientId.length > 0)
          {
    
    
       paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:self.PayPalClientId
                                                                                                   receiverEmail:self.PayPalReceiverEmail
                                                                                                         payerId:self.customerId
                                                                                                         payment:payment
                                                                                                        delegate:self];
    
              paymentViewController.hideCreditCardButton = !self.acceptCreditCards;
    
                }
        else
        {
    
           paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:kPayPalClientId
                                                                                                         receiverEmail:self.PayPalReceiverEmail
                                                                                                               payerId:self.customerId
                                                                                                               payment:payment
                                                                                                              delegate:self];
    
            paymentViewController.hideCreditCardButton = YES;
    
        }
    
    // Setting the languageOrLocale property is optional.
    //
    // If you do not set languageOrLocale, then the PayPalPaymentViewController will present
    // its user interface according to the device's current language setting.
    //
    // Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
    // locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
    // to use that language/locale.
    
    // For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
    paymentViewController.languageOrLocale = @"en";
    
    
    [self presentViewController:paymentViewController animated:YES completion:nil];
    

    【讨论】:

    • 但是返回后的变量呢?
    • 感谢韩的评论。 post 变量包含示例 IPN 消息发送的值和有关交易的其他信息。要在您可以信任消息内容之前检查这些返回变量的验证,您必须首先验证消息是否来自 PayPal。要验证消息,您必须按照接收到的确切顺序发回内容,并在其前面使用命令 _notify-validate,如 developer.paypal.com/docs/classic/ipn/integration-guide/…
    • 感谢您的耐心回复。其实我没有使用IPN,只是返回url接收支付结果详情,检查这次支付是否成功。你的意思是我必须发回变量?
    • 随时,韩。是的,如果您想检查这些返回变量的验证,您必须发回变量。如果验证不是非常重要,那么您可以忽略变量中的值,什么也不做。
    • 非常感谢。我终于让我的网站正常工作了。似乎发送回参数的唯一方法是使用 GET 请求并将所有内容编码到 URL 中。虽然它不聪明,但它仍然有效。 :)
    猜你喜欢
    • 2021-05-10
    • 2016-01-13
    • 2011-08-27
    • 2012-01-22
    • 1970-01-01
    • 2013-04-26
    • 2016-04-17
    • 2013-04-01
    • 2015-10-21
    相关资源
    最近更新 更多